From 07399029d7fc80a5104791c4abbb2d36be7e620c Mon Sep 17 00:00:00 2001 From: Dan Lutker Date: Tue, 6 Dec 2022 21:40:19 +0000 Subject: [PATCH 001/205] 8258005: JDK build fails with incorrect fixpath script Backport-of: 0890620c94cd9d0aca6289e85b3980b64cd122ed --- make/autoconf/basic_windows.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/autoconf/basic_windows.m4 b/make/autoconf/basic_windows.m4 index c85aab19b04..dc19b631cc6 100644 --- a/make/autoconf/basic_windows.m4 +++ b/make/autoconf/basic_windows.m4 @@ -121,7 +121,7 @@ AC_DEFUN([BASIC_SETUP_PATHS_WINDOWS], else WINENV_PREFIX_ARG="$WINENV_PREFIX" fi - FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT/\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD -q" + FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD -q" FIXPATH_BASE="$BASH $FIXPATH_DIR/fixpath.sh $FIXPATH_ARGS" FIXPATH="$FIXPATH_BASE exec" @@ -166,7 +166,7 @@ AC_DEFUN([BASIC_WINDOWS_FINALIZE_FIXPATH], [ if test "x$OPENJDK_BUILD_OS" = xwindows; then FIXPATH_CMDLINE=". $TOPDIR/make/scripts/fixpath.sh -e $PATHTOOL \ - -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT/\\/\\\\} -t $WINENV_TEMP_DIR \ + -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR \ -c $CMD -q" $ECHO > $OUTPUTDIR/fixpath '#!/bin/bash' $ECHO >> $OUTPUTDIR/fixpath export PATH='"[$]PATH:'$PATH'"' From 89f9f91d3a69b473a61d98fab859b751dd6755c2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 7 Dec 2022 09:16:30 +0000 Subject: [PATCH 002/205] 8297257: Bump update version for OpenJDK: jdk-11.0.19 Reviewed-by: sgehwolf --- .jcheck/conf | 2 +- make/autoconf/version-numbers | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.jcheck/conf b/.jcheck/conf index 9f935c25e34..40d493a9dc8 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=11.0.18 +version=11.0.19 [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 f750f1df5d8..6ca0433951f 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=18 +DEFAULT_VERSION_UPDATE=19 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2023-01-17 +DEFAULT_VERSION_DATE=2023-04-18 DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" From 9197181f4e3e1e000879541678aa7659928da410 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 12 Dec 2022 09:25:42 +0000 Subject: [PATCH 003/205] 8296878: Document Filter attached to JPasswordField and setText("") is not cleared instead inserted characters replaced with unicode null characters Reviewed-by: phh Backport-of: 87f00f4a1bfb392be0684edcdfa0254caec4ca03 --- .../classes/javax/swing/JPasswordField.java | 36 ++++++---- .../OldPasswordInDocumentFilter.java | 69 +++++++++++++++++++ 2 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 test/jdk/javax/swing/JPasswordField/OldPasswordInDocumentFilter.java diff --git a/src/java.desktop/share/classes/javax/swing/JPasswordField.java b/src/java.desktop/share/classes/javax/swing/JPasswordField.java index 2a3cc4c6631..704bac827cc 100644 --- a/src/java.desktop/share/classes/javax/swing/JPasswordField.java +++ b/src/java.desktop/share/classes/javax/swing/JPasswordField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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,21 +285,27 @@ public String getText(int offs, int len) throws BadLocationException { public void setText(String t) { // overwrite the old data first Document doc = getDocument(); - int nleft = doc.getLength(); - Segment text = new Segment(); - // we would like to get direct data array access, not a copy of it - text.setPartialReturn(true); - int offs = 0; - try { - while (nleft > 0) { - doc.getText(offs, nleft, text); - Arrays.fill(text.array, text.offset, - text.count + text.offset, '\u0000'); - nleft -= text.count; - offs += text.count; + DocumentFilter filter = null; + if (doc instanceof AbstractDocument) { + filter = ((AbstractDocument) doc).getDocumentFilter(); + } + if (filter == null) { + int nleft = doc.getLength(); + Segment text = new Segment(); + // we would like to get direct data array access, not a copy of it + text.setPartialReturn(true); + int offs = 0; + try { + while (nleft > 0) { + doc.getText(offs, nleft, text); + Arrays.fill(text.array, text.offset, + text.count + text.offset, '\u0000'); + nleft -= text.count; + offs += text.count; + } + } catch (BadLocationException ignored) { + // we tried } - } catch (BadLocationException ignored) { - // we tried } super.setText(t); } diff --git a/test/jdk/javax/swing/JPasswordField/OldPasswordInDocumentFilter.java b/test/jdk/javax/swing/JPasswordField/OldPasswordInDocumentFilter.java new file mode 100644 index 00000000000..3507e30125d --- /dev/null +++ b/test/jdk/javax/swing/JPasswordField/OldPasswordInDocumentFilter.java @@ -0,0 +1,69 @@ +/* + * 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.util.Arrays; + +import javax.swing.JPasswordField; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.DocumentFilter; +import javax.swing.text.PlainDocument; + +/** + * @test + * @bug 8296878 + * @summary can the old password be accessed in the DocumentFilter + */ +public final class OldPasswordInDocumentFilter { + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(OldPasswordInDocumentFilter::test); + } + + private static void test() { + JPasswordField test = new JPasswordField(); + PlainDocument document = (PlainDocument) test.getDocument(); + document.setDocumentFilter(new DocumentFilter() { + @Override + public void replace(FilterBypass fb, int offset, + int length, String text, AttributeSet attrs) + throws BadLocationException + { + Document doc = fb.getDocument(); + String string = doc.getText(0, doc.getLength()) + text; + if (string.length() <= 6 && string.matches("[0-9]+")) { + super.replace(fb, offset, length, text, attrs); + } + } + }); + test.setText("123456"); + test.setText(""); + + char[] password = test.getPassword(); + if (password.length != 0) { + throw new RuntimeException(Arrays.toString(password)); + } + } +} From 7d50d5199b82c041b473bc83901ac299784e6414 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 14 Dec 2022 16:37:47 +0000 Subject: [PATCH 004/205] 8259267: Refactor LoaderLeak shell test as java test. 8225648: [TESTBUG] java/lang/annotation/loaderLeak/Main.java fails with -Xcomp Reviewed-by: mdoerr Backport-of: 75aa15467ec3d88a26f7c28518a24caf132818bf --- .../java/lang/annotation/LoaderLeakTest.java | 137 ++++++++++++++++++ .../java/lang/annotation/loaderLeak/A.java | 28 ---- .../java/lang/annotation/loaderLeak/B.java | 24 --- .../java/lang/annotation/loaderLeak/C.java | 24 --- .../lang/annotation/loaderLeak/LoaderLeak.sh | 93 ------------ .../java/lang/annotation/loaderLeak/Main.java | 135 ----------------- 6 files changed, 137 insertions(+), 304 deletions(-) create mode 100644 test/jdk/java/lang/annotation/LoaderLeakTest.java delete mode 100644 test/jdk/java/lang/annotation/loaderLeak/A.java delete mode 100644 test/jdk/java/lang/annotation/loaderLeak/B.java delete mode 100644 test/jdk/java/lang/annotation/loaderLeak/C.java delete mode 100644 test/jdk/java/lang/annotation/loaderLeak/LoaderLeak.sh delete mode 100644 test/jdk/java/lang/annotation/loaderLeak/Main.java diff --git a/test/jdk/java/lang/annotation/LoaderLeakTest.java b/test/jdk/java/lang/annotation/LoaderLeakTest.java new file mode 100644 index 00000000000..d18643bf8ad --- /dev/null +++ b/test/jdk/java/lang/annotation/LoaderLeakTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2004, 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 + * 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 5040740 + * @summary annotations cause memory leak + * @library /test/lib + * @build jdk.test.lib.process.* + * @run testng LoaderLeakTest + */ + +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.io.FileInputStream; +import java.lang.annotation.Retention; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; +import java.nio.file.*; +import java.util.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +public class LoaderLeakTest { + + @Test + public void testWithoutReadingAnnotations() throws Throwable { + runJavaProcessExpectSuccessExitCode("Main"); + } + + @Test + public void testWithReadingAnnotations() throws Throwable { + runJavaProcessExpectSuccessExitCode("Main", "foo"); + } + + private void runJavaProcessExpectSuccessExitCode(String ... command) throws Throwable { + var processBuilder = ProcessTools.createJavaProcessBuilder(command) + .directory(Paths.get(Utils.TEST_CLASSES).toFile()); + ProcessTools.executeCommand(processBuilder).shouldHaveExitValue(0); + } + +} + +class Main { + + public static void main(String[] args) throws Exception { + for (int i = 0; i < 100; i++) { + doTest(args.length != 0); + } + } + + static void doTest(boolean readAnn) throws Exception { + ClassLoader loader = new SimpleClassLoader(); + var c = new WeakReference>(loader.loadClass("C")); + if (c.get() == null) throw new AssertionError("class missing after loadClass"); + // c.get() should never return null here since we hold a strong + // reference to the class loader that loaded the class referred by c. + if (c.get().getClassLoader() != loader) throw new AssertionError("wrong classloader"); + if (readAnn) System.out.println(c.get().getAnnotations()[0]); + if (c.get() == null) throw new AssertionError("class missing before GC"); + System.gc(); + System.gc(); + if (c.get() == null) throw new AssertionError("class missing after GC but before loader is unreachable"); + System.gc(); + System.gc(); + Reference.reachabilityFence(loader); + loader = null; + + // Might require multiple calls to System.gc() for weak-references + // processing to be complete. If the weak-reference is not cleared as + // expected we will hang here until timed out by the test harness. + while (true) { + System.gc(); + Thread.sleep(20); + if (c.get() == null) { + break; + } + } + } +} + +@Retention(RUNTIME) +@interface A { + B b(); +} + +@interface B { } + +@A(b=@B()) class C { } + +class SimpleClassLoader extends ClassLoader { + public SimpleClassLoader() { } + + private byte[] getClassImplFromDataBase(String className) { + try { + return Files.readAllBytes(Paths.get(className + ".class")); + } catch (Exception e) { + throw new Error("could not load class " + className, e); + } + } + + @Override + public Class loadClass(String className, boolean resolveIt) + throws ClassNotFoundException { + switch (className) { + case "A": + case "B": + case "C": { + var classData = getClassImplFromDataBase(className); + return defineClass(className, classData, 0, classData.length); + } + } + return super.loadClass(className, resolveIt); + } + +} diff --git a/test/jdk/java/lang/annotation/loaderLeak/A.java b/test/jdk/java/lang/annotation/loaderLeak/A.java deleted file mode 100644 index c50965c6cf6..00000000000 --- a/test/jdk/java/lang/annotation/loaderLeak/A.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * 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. - */ - -public -@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) -@interface A { - B b(); -} diff --git a/test/jdk/java/lang/annotation/loaderLeak/B.java b/test/jdk/java/lang/annotation/loaderLeak/B.java deleted file mode 100644 index 53b099e16e2..00000000000 --- a/test/jdk/java/lang/annotation/loaderLeak/B.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * 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. - */ - -public @interface B {} diff --git a/test/jdk/java/lang/annotation/loaderLeak/C.java b/test/jdk/java/lang/annotation/loaderLeak/C.java deleted file mode 100644 index a0bce10049c..00000000000 --- a/test/jdk/java/lang/annotation/loaderLeak/C.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * 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. - */ - -public @A(b=@B()) class C {} diff --git a/test/jdk/java/lang/annotation/loaderLeak/LoaderLeak.sh b/test/jdk/java/lang/annotation/loaderLeak/LoaderLeak.sh deleted file mode 100644 index 915aa9558ff..00000000000 --- a/test/jdk/java/lang/annotation/loaderLeak/LoaderLeak.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. -# 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. - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${COMPILEJAVA}" = "" ]; then - COMPILEJAVA="${TESTJAVA}" -fi -echo "COMPILEJAVA=${COMPILEJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) - NULL=/dev/null - PS=":" - FS="/" - ;; - CYGWIN* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -mkdir -p classes -cp ${TESTSRC}${FS}*.java . -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d classes A.java B.java C.java -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Main.java -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} Main -result=$? -if [ $result -eq 0 ] -then - echo "Passed 1 of 2" -else - echo "Failed 1 of 2" - exit $result -fi -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} Main foo -result=$? -if [ $result -eq 0 ] -then - echo "Passed 2 of 2" -else - echo "Failed 2 of 2" -fi -exit $result diff --git a/test/jdk/java/lang/annotation/loaderLeak/Main.java b/test/jdk/java/lang/annotation/loaderLeak/Main.java deleted file mode 100644 index 7e249ebc106..00000000000 --- a/test/jdk/java/lang/annotation/loaderLeak/Main.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. - * 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 5040740 - * @summary annotations cause memory leak - * @author gafter - * - * @run shell LoaderLeak.sh - */ - -import java.net.*; -import java.lang.ref.*; -import java.util.*; -import java.io.*; - -public class Main { - public static void main(String[] args) throws Exception { - for (int i=0; i<100; i++) - doTest(args.length != 0); - } - - static void doTest(boolean readAnn) throws Exception { - // URL classes = new URL("file://" + System.getProperty("user.dir") + "/classes"); - // URL[] path = { classes }; - // URLClassLoader loader = new URLClassLoader(path); - ClassLoader loader = new SimpleClassLoader(); - WeakReference> c = new WeakReference(loader.loadClass("C")); - if (c.get() == null) throw new AssertionError(); - if (c.get().getClassLoader() != loader) throw new AssertionError(); - if (readAnn) System.out.println(c.get().getAnnotations()[0]); - if (c.get() == null) throw new AssertionError(); - System.gc(); - System.gc(); - if (c.get() == null) throw new AssertionError(); - System.gc(); - System.gc(); - loader = null; - - // Might require multiple calls to System.gc() for weak-references - // processing to be complete. If the weak-reference is not cleared as - // expected we will hang here until timed out by the test harness. - while (true) { - System.gc(); - Thread.sleep(20); - if (c.get() == null) { - break; - } - } - } -} - -class SimpleClassLoader extends ClassLoader { - private Hashtable classes = new Hashtable(); - - public SimpleClassLoader() { - } - private byte getClassImplFromDataBase(String className)[] { - byte result[]; - try { - FileInputStream fi = new FileInputStream("classes/"+className+".class"); - result = new byte[fi.available()]; - fi.read(result); - return result; - } catch (Exception e) { - - /* - * If we caught an exception, either the class wasnt found or it - * was unreadable by our process. - */ - return null; - } - } - public Class loadClass(String className) throws ClassNotFoundException { - return (loadClass(className, true)); - } - public synchronized Class loadClass(String className, boolean resolveIt) - throws ClassNotFoundException { - Class result; - byte classData[]; - - /* Check our local cache of classes */ - result = (Class)classes.get(className); - if (result != null) { - return result; - } - - /* Check with the primordial class loader */ - try { - result = super.findSystemClass(className); - return result; - } catch (ClassNotFoundException e) { - } - - /* Try to load it from our repository */ - classData = getClassImplFromDataBase(className); - if (classData == null) { - throw new ClassNotFoundException(); - } - - /* Define it (parse the class file) */ - result = defineClass(classData, 0, classData.length); - if (result == null) { - throw new ClassFormatError(); - } - - if (resolveIt) { - resolveClass(result); - } - - classes.put(className, result); - return result; - } -} From 604dd4d9c683b67de6ec77fadafc82aae202eadc Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 14 Dec 2022 16:56:36 +0000 Subject: [PATCH 005/205] 8179317: [TESTBUG] rewrite runtime shell tests in java 8247741: Test test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java fails when -XX:+IgnoreUnrecognizedVMOptions is set Converted shell tests to Java Reviewed-by: mdoerr Backport-of: ccb4ab5499275888e6a088d8bec2faccd6b4db28 --- make/test/JtregNativeHotspot.gmk | 5 +- test/hotspot/jtreg/TEST.groups | 2 +- .../jtreg/runtime/7162488/Test7162488.sh | 63 --------------- .../7162488/TestUnrecognizedVmOption.java | 45 +++++++++++ .../jtreg/runtime/StackGap/TestStackGap.java | 53 +++++++++++++ test/hotspot/jtreg/runtime/StackGap/testme.sh | 49 ------------ .../StackGuardPages/TestStackGuardPages.java | 52 +++++++++++++ .../jtreg/runtime/StackGuardPages/testme.sh | 51 ------------- .../jtreg/runtime/signal/SigTestDriver.java | 31 +------- .../process/Test.java} | 19 ++--- .../process/TestNativeProcessBuilder.java | 44 +++++++++++ .../process/exejvm-test-launcher.c | 76 +++++++++++++++++++ .../TestMaxMetaspaceSize.java | 54 +++++++++++++ .../maxMetaspaceSize/maxMetaspaceSize.sh | 45 ----------- test/lib/jdk/test/lib/Platform.java | 31 +++++++- .../jdk/test/lib/process/ProcessTools.java | 47 +++++++++++- 16 files changed, 414 insertions(+), 253 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/7162488/Test7162488.sh create mode 100644 test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java create mode 100644 test/hotspot/jtreg/runtime/StackGap/TestStackGap.java delete mode 100644 test/hotspot/jtreg/runtime/StackGap/testme.sh create mode 100644 test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java delete mode 100644 test/hotspot/jtreg/runtime/StackGuardPages/testme.sh rename test/hotspot/jtreg/{vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java => testlibrary_tests/process/Test.java} (73%) create mode 100644 test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java create mode 100644 test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c create mode 100644 test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java delete mode 100644 test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/maxMetaspaceSize.sh diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 58bd7bf940a..016be08ac90 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -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 @@ -878,7 +878,10 @@ ifeq ($(OPENJDK_TARGET_OS), windows) BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit := jvm.lib + BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib + else + BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libbootclssearch_agent += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libsystemclssearch_agent += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libgetsysprop001 += -lpthread diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 1aea985ab5a..c61ffb2987a 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -504,7 +504,7 @@ vmTestbase_largepages = \ vmTestbase/metaspace/stressDictionary/StressDictionary.java \ vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java \ vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java \ - vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java \ + vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java \ vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java \ vmTestbase/metaspace/shrink_grow/ShrinkGrowMultiJVM/ShrinkGrowMultiJVM.java \ vmTestbase/metaspace/shrink_grow/CompressedClassSpaceSize/TestDescription.java diff --git a/test/hotspot/jtreg/runtime/7162488/Test7162488.sh b/test/hotspot/jtreg/runtime/7162488/Test7162488.sh deleted file mode 100644 index b87d92b8d0c..00000000000 --- a/test/hotspot/jtreg/runtime/7162488/Test7162488.sh +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. -# 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 Test7162488.sh -# @bug 7162488 -# @summary VM not printing unknown -XX options -# @run shell Test7162488.sh -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -JAVA=${TESTJAVA}${FS}bin${FS}java - -# -# Just run with an option we are confident will not be recognized, -# and check for the message: -# -OPTION=this_is_not_an_option - -${JAVA} -showversion -XX:${OPTION} 2>&1 | grep "Unrecognized VM option" -if [ "$?" != "0" ] -then - printf "FAILED: option not flagged as unrecognized.\n" - exit 1 -fi - -${JAVA} -showversion -XX:${OPTION} 2>&1 | grep ${OPTION} -if [ "$?" != "0" ] -then - printf "FAILED: bad option not named as being bad.\n" - exit 1 -fi - -printf "Passed.\n" - diff --git a/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java new file mode 100644 index 00000000000..43b837b1d07 --- /dev/null +++ b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +/* + * @test + * @bug 7162488 + * @summary VM should print unrecognized -XX option + * @library /test/lib + * @run driver TestUnrecognizedVmOption + */ +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestUnrecognizedVmOption { + static final String OPTION="this_is_not_an_option"; + + public static void main(String[] args) throws Exception { + ProcessBuilder pb = + ProcessTools.createJavaProcessBuilder("-showversion", "-XX:" + OPTION); + new OutputAnalyzer(pb.start()) + .shouldNotHaveExitValue(0) + .shouldContain("Unrecognized VM option") + .shouldContain(OPTION); + } +} diff --git a/test/hotspot/jtreg/runtime/StackGap/TestStackGap.java b/test/hotspot/jtreg/runtime/StackGap/TestStackGap.java new file mode 100644 index 00000000000..94f30d5f9b3 --- /dev/null +++ b/test/hotspot/jtreg/runtime/StackGap/TestStackGap.java @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/* + * @test + * @summary Linux kernel stack guard should not cause segfaults on x86-32 + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @requires os.family == "linux" + * @compile T.java + * @run main/native TestStackGap + */ + + +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestStackGap { + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("stack-gap"); + pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); + new OutputAnalyzer(pb.start()) + .shouldHaveExitValue(0); + + pb = ProcessTools.createNativeTestProcessBuilder("stack-gap", + "-XX:+DisablePrimordialThreadGuardPages"); + pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); + new OutputAnalyzer(pb.start()) + .shouldHaveExitValue(0); + } +} + diff --git a/test/hotspot/jtreg/runtime/StackGap/testme.sh b/test/hotspot/jtreg/runtime/StackGap/testme.sh deleted file mode 100644 index 23e32e6f2a0..00000000000 --- a/test/hotspot/jtreg/runtime/StackGap/testme.sh +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2014, 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. -#!/bin/sh - -# -# @test testme.sh -# @summary Linux kernel stack guard should not cause segfaults on x86-32 -# @compile T.java -# @run shell testme.sh -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -if [ "${VM_OS}" != "linux" ] -then - echo "Test only valid for Linux" - exit 0 -fi - -LD_LIBRARY_PATH=.:${TESTJAVA}/lib/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH - -${TESTNATIVEPATH}/stack-gap || exit $? -${TESTNATIVEPATH}/stack-gap -XX:+DisablePrimordialThreadGuardPages || exit $? diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java new file mode 100644 index 00000000000..4877a3433a7 --- /dev/null +++ b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/* + * @test + * @summary Stack guard pages should be installed correctly and removed when thread is detached + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @requires os.family == "linux" + * @compile DoOverflow.java + * @run main/native TestStackGuardPages + */ +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + + +public class TestStackGuardPages { + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("invoke", + "test_java_overflow"); + pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); + new OutputAnalyzer(pb.start()) + .shouldHaveExitValue(0); + + pb = ProcessTools.createNativeTestProcessBuilder("invoke", "test_native_overflow"); + pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); + new OutputAnalyzer(pb.start()) + .shouldHaveExitValue(0); + } +} + diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/testme.sh b/test/hotspot/jtreg/runtime/StackGuardPages/testme.sh deleted file mode 100644 index 96759ad9eb1..00000000000 --- a/test/hotspot/jtreg/runtime/StackGuardPages/testme.sh +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2014, 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. -#!/bin/sh - -# -# @test testme.sh -# @summary Stack guard pages should be installed correctly and removed when thread is detached -# @compile DoOverflow.java -# @run shell testme.sh -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -if [ "${VM_OS}" != "linux" ] -then - echo "Test only valid for Linux" - exit 0 -fi - -LD_LIBRARY_PATH=.:${TESTJAVA}/lib/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH - -# Run the test for a java and native overflow -${TESTNATIVEPATH}/invoke test_java_overflow -${TESTNATIVEPATH}/invoke test_native_overflow -exit $? diff --git a/test/hotspot/jtreg/runtime/signal/SigTestDriver.java b/test/hotspot/jtreg/runtime/signal/SigTestDriver.java index e1613b269d8..8d4cd38c516 100644 --- a/test/hotspot/jtreg/runtime/signal/SigTestDriver.java +++ b/test/hotspot/jtreg/runtime/signal/SigTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -100,7 +100,7 @@ public static void main(String[] args) { System.out.printf("Do execute: %s%n", cmd.toString()); ProcessBuilder pb = new ProcessBuilder(cmd); - pb.environment().merge(envVar, jvmLibDir().toString(), + pb.environment().merge(envVar, Platform.jvmLibDir().toString(), (x, y) -> y + File.pathSeparator + x); pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); @@ -143,32 +143,7 @@ private static List vmargs() { } private static Path libjsig() { - return jvmLibDir().resolve((Platform.isWindows() ? "" : "lib") + return Platform.jvmLibDir().resolve((Platform.isWindows() ? "" : "lib") + "jsig." + Platform.sharedLibraryExt()); } - - private static Path jvmLibDir() { - Path dir = Paths.get(Utils.TEST_JDK); - if (Platform.isWindows()) { - return dir.resolve("bin") - .resolve(variant()) - .toAbsolutePath(); - } else { - return dir.resolve("lib") - .resolve(variant()) - .toAbsolutePath(); - } - } - - private static String variant() { - if (Platform.isServer()) { - return "server"; - } else if (Platform.isClient()) { - return "client"; - } else if (Platform.isMinimal()) { - return "minimal"; - } else { - throw new Error("TESTBUG: unsupported vm variant"); - } - } } diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java b/test/hotspot/jtreg/testlibrary_tests/process/Test.java similarity index 73% rename from test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java rename to test/hotspot/jtreg/testlibrary_tests/process/Test.java index d7a7cfe096a..17375e305dd 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java +++ b/test/hotspot/jtreg/testlibrary_tests/process/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,15 +21,8 @@ * questions. */ - -/* - * @test - * - * @summary converted from VM Testbase metaspace/flags/maxMetaspaceSize. - * - * @library /vmTestbase /test/lib - * @run driver jdk.test.lib.FileInstaller . . - * @build metaspace.flags.maxMetaspaceSize.maxMetaspaceSize - * @run shell maxMetaspaceSize.sh - */ - +public class Test { + public static void test() { + System.out.println ("Hello Test"); + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java b/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java new file mode 100644 index 00000000000..9acd6a64c18 --- /dev/null +++ b/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java @@ -0,0 +1,44 @@ +/* + * 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. + */ + +/* + * @test + * @summary Test the native process builder API. + * @library /test/lib + * @build Test + * @run main/native TestNativeProcessBuilder + */ + + +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestNativeProcessBuilder { + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("jvm-test-launcher"); + pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); + new OutputAnalyzer(pb.start()) + .shouldHaveExitValue(0); + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c b/test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c new file mode 100644 index 00000000000..dee0bb0ff5a --- /dev/null +++ b/test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c @@ -0,0 +1,76 @@ +/* + * 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 +#include +#include + +JNIEnv* create_vm(JavaVM **jvm) +{ + JNIEnv* env; + JavaVMInitArgs args; + JavaVMOption options[1]; + + char classpath[4096]; + snprintf(classpath, sizeof classpath, + "-Djava.class.path=%s", getenv("CLASSPATH")); + options[0].optionString = classpath; + + args.version = JNI_VERSION_1_8; + args.nOptions = 1; + args.options = &options[0]; + args.ignoreUnrecognized = 0; + + int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args); + if (ret < 0) + exit(10); + + return env; +} + + +void run(JNIEnv *env) { + jclass test_class; + jmethodID test_method; + + test_class = (*env)->FindClass(env, "Test"); + if (test_class == NULL) + exit(11); + + test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V"); + if (test_method == NULL) + exit(12); + + (*env)->CallStaticVoidMethod(env, test_class, test_method); +} + + +int main(int argc, char **argv) +{ + JavaVM *jvm; + JNIEnv *env = create_vm(&jvm); + + run(env); + + return 0; +} diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java new file mode 100644 index 00000000000..d67d77e5b08 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java @@ -0,0 +1,54 @@ +/* + * 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 + * 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 + * + * @summary converted from VM Testbase metaspace/flags/maxMetaspaceSize. + * + * @library /vmTestbase /test/lib + * @build metaspace.flags.maxMetaspaceSize.maxMetaspaceSize + * @run driver metaspace.flags.maxMetaspaceSize.TestMaxMetaspaceSize + */ +package metaspace.flags.maxMetaspaceSize; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestMaxMetaspaceSize { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = + ProcessTools.createJavaProcessBuilder(true, "-XX:MaxMetaspaceSize=100m", + maxMetaspaceSize.class.getName()); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + + if (out.getExitValue() == 0) { + // test passed + return; + } else { + System.out.println("Non-zero exit value from child process. Could be OOM, which is OK"); + out.shouldContain("Out of Memory Error"); + } + } +} diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/maxMetaspaceSize.sh b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/maxMetaspaceSize.sh deleted file mode 100644 index cc95ca7756c..00000000000 --- a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/maxMetaspaceSize.sh +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2013, 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. - -JAVA="$TESTJAVA/bin/java" -JAVA_OPTS="$TESTJAVAOPTS $TESTVMOPTS -cp $TESTCLASSPATH" - -TST="metaspace.flags.maxMetaspaceSize.maxMetaspaceSize" -echo "" -echo "$JAVA $JAVA_OPTS -XX:MaxMetaspaceSize=100m $TST" -echo "" -$JAVA $JAVA_OPTS -XX:MaxMetaspaceSize=100m $TST -res=$? - -printf "\n\n" -if [ $res -eq 0 ]; then - echo Test passed -else - grep -s "Out of Memory Error" hs_err_pid*.log - res2=$? - if [ $res2 -eq 0 ]; then - echo JAVA crashed with expected Out of Memory Error error. - echo Test passed - else - echo Test failed - exit 1 - fi -fi diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 739c351806b..f4ee0546c70 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, 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 @@ -46,6 +46,7 @@ public class Platform { private static final String osArch = privilegedGetProperty("os.arch"); private static final String userName = privilegedGetProperty("user.name"); private static final String compiler = privilegedGetProperty("sun.management.compiler"); + private static final String testJdk = privilegedGetProperty("test.jdk"); private static String privilegedGetProperty(String key) { return AccessController.doPrivileged(( @@ -340,6 +341,34 @@ public static String sharedLibraryPathVariableName() { } } + /** + * Returns absolute path to directory containing JVM shared library. + */ + public static Path jvmLibDir() { + Path dir = Paths.get(testJdk); + if (Platform.isWindows()) { + return dir.resolve("bin") + .resolve(variant()) + .toAbsolutePath(); + } else { + return dir.resolve("lib") + .resolve(variant()) + .toAbsolutePath(); + } + } + + private static String variant() { + if (Platform.isServer()) { + return "server"; + } else if (Platform.isClient()) { + return "client"; + } else if (Platform.isMinimal()) { + return "minimal"; + } else { + throw new Error("TESTBUG: unsupported vm variant"); + } + } + /* * This should match the #if condition in ClassListParser::load_class_from_source(). */ diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index eb7e2bfef5d..e770b6c3a53 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 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 @@ -23,10 +23,12 @@ package jdk.test.lib.process; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -45,6 +47,7 @@ import java.security.PrivilegedExceptionAction; import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Platform; import jdk.test.lib.Utils; public final class ProcessTools { @@ -513,6 +516,48 @@ public static OutputAnalyzer executeCommand(ProcessBuilder pb) return analyzer; } + /** + * Helper method to create a process builder for launching native executable + * test that uses/loads JVM. + * + * @param executableName The name of an executable to be launched. + * @param args Arguments for the executable. + * @return New ProcessBuilder instance representing the command. + */ + public static ProcessBuilder createNativeTestProcessBuilder(String executableName, + String... args) throws Exception { + executableName = Platform.isWindows() ? executableName + ".exe" : executableName; + String executable = Paths.get(System.getProperty("test.nativepath"), executableName) + .toAbsolutePath() + .toString(); + + ProcessBuilder pb = new ProcessBuilder(executable); + pb.command().addAll(Arrays.asList(args)); + addJvmLib(pb); + return pb; + } + + /** + * Adds JVM library path to the native library path. + * + * @param pb ProcessBuilder to be updated with JVM library path. + * @return pb Update ProcessBuilder instance. + */ + public static ProcessBuilder addJvmLib(ProcessBuilder pb) throws Exception { + String jvmLibDir = Platform.jvmLibDir().toString(); + String libPathVar = Platform.sharedLibraryPathVariableName(); + String currentLibPath = pb.environment().get(libPathVar); + + String newLibPath = jvmLibDir; + if ( (currentLibPath != null) && !currentLibPath.isEmpty() ) { + newLibPath = currentLibPath + File.pathSeparator + jvmLibDir; + } + + pb.environment().put(libPathVar, newLibPath); + + return pb; + } + private static Process privilegedStart(ProcessBuilder pb) throws IOException { try { return AccessController.doPrivileged( From b3c7b287c3843444690669cccfc73785b5970ca4 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 14 Dec 2022 17:10:31 +0000 Subject: [PATCH 006/205] 8298459: Fix msys2 linking and handling out of tree build directory for source zip creation Reviewed-by: mdoerr Backport-of: d624debe23f60d778d7be43f28d06e9454057217 --- make/ZipSource.gmk | 7 ++++--- make/common/MakeBase.gmk | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/make/ZipSource.gmk b/make/ZipSource.gmk index b4aabdacbb6..ff29a05826f 100644 --- a/make/ZipSource.gmk +++ b/make/ZipSource.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2019, 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 @@ -31,6 +31,7 @@ include JavaCompilation.gmk include Modules.gmk SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src +$(if $(filter $(TOPDIR)/%, $(SUPPORT_OUTPUTDIR)), $(eval SRC_ZIP_BASE := $(TOPDIR)), $(eval SRC_ZIP_BASE := $(SUPPORT_OUTPUTDIR))) # Hook to include the corresponding custom file, if present. $(eval $(call IncludeCustomExtension, ZipSource.gmk)) @@ -51,10 +52,10 @@ ALL_MODULES := $(FindAllModules) # again to create src.zip. $(foreach m, $(ALL_MODULES), \ $(foreach d, $(call FindModuleSrcDirs, $m) $(call ExtraSrcDirs, $m), \ - $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \ + $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d))/$m) \ $(if $(SRC_GENERATED), , \ $(eval $$($d_TARGET): $d ; \ - $$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \ + $$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \ ) \ ) \ $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \ diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index a96edc2f978..49fbccd640a 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -626,17 +626,36 @@ RelativePath = \ # There are two versions, either creating a relative or an absolute link. Be # careful when using this on Windows since the symlink created is only valid in # the unix emulation environment. -define link-file-relative +# In msys2 we use mklink /J because its ln would perform a deep copy of the target. +# This inhibits performance and can lead to issues with long paths. With mklink /J +# relative linking does not work, so we handle the link as absolute path. +ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2) + define link-file-relative + $(call MakeTargetDir) + $(RM) '$(call DecodeSpace, $@)' + cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))" + endef +else + define link-file-relative $(call MakeTargetDir) $(RM) '$(call DecodeSpace, $@)' $(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)' -endef + endef +endif -define link-file-absolute +ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2) + define link-file-absolute + $(call MakeTargetDir) + $(RM) '$(call DecodeSpace, $@)' + cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))" + endef +else + define link-file-absolute $(call MakeTargetDir) $(RM) '$(call DecodeSpace, $@)' $(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' -endef + endef +endif ################################################################################ # Filter out duplicate sub strings while preserving order. Keeps the first occurance. From 12eca2f8ac6e8127f1d698aef50db03cf278a7b8 Mon Sep 17 00:00:00 2001 From: Pankaj Bansal Date: Wed, 14 Dec 2022 18:58:31 +0000 Subject: [PATCH 007/205] 8256126: Create implementation for NSAccessibilityImage protocol peer Backport-of: bbb93ca3c80968d4f167bb4cd9e5d3e60e4a6a5b --- .../awt/a11y/CommonComponentAccessibility.m | 4 +- .../awt/a11y/ImageAccessibility.h | 35 ++++++++++++++++++ .../awt/a11y/ImageAccessibility.m | 37 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 3aa7e7aef8e..9fa49731e62 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -46,9 +46,11 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:1]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:3]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; + [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; + [rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"]; } /* diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.h new file mode 100644 index 00000000000..fcfe9ef281c --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "JavaComponentAccessibility.h" +#import "CommonComponentAccessibility.h" + +#import + +@interface ImageAccessibility : CommonComponentAccessibility { + +}; +- (nullable NSString *)accessibilityLabel; +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.m new file mode 100644 index 00000000000..de6fcc951f7 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ImageAccessibility.m @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "ImageAccessibility.h" + +/* + * Implementation of the accessibility peer for the icon role + */ +@implementation ImageAccessibility +- (nullable NSString *)accessibilityLabel +{ + return [self accessibilityTitleAttribute]; +} + +@end From 01f5a197102c377c6ce29b1e695657a75c414c3a Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 15 Dec 2022 07:54:11 +0000 Subject: [PATCH 008/205] 8287011: Improve container information Backport-of: e60939850e5328b9c0f2002ac5ed7744375bf18b --- .../os/linux/cgroupSubsystem_linux.hpp | 3 ++ .../os/linux/cgroupV1Subsystem_linux.cpp | 34 ++++++++++++++++++- .../os/linux/cgroupV1Subsystem_linux.hpp | 7 ++++ .../os/linux/cgroupV2Subsystem_linux.cpp | 21 ++++++++++++ .../os/linux/cgroupV2Subsystem_linux.hpp | 6 +++- src/hotspot/os/linux/osContainer_linux.cpp | 20 ++++++++++- src/hotspot/os/linux/osContainer_linux.hpp | 4 +++ src/hotspot/os/linux/os_linux.cpp | 25 ++++---------- .../jtreg/containers/docker/TestMisc.java | 13 +++++++ 9 files changed, 112 insertions(+), 21 deletions(-) diff --git a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index db5eb59edd3..d4efc0f3d83 100644 --- a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -252,12 +252,15 @@ class CgroupSubsystem: public CHeapObj { virtual jlong memory_and_swap_limit_in_bytes() = 0; virtual jlong memory_soft_limit_in_bytes() = 0; virtual jlong memory_max_usage_in_bytes() = 0; + virtual char * cpu_cpuset_cpus() = 0; virtual char * cpu_cpuset_memory_nodes() = 0; virtual jlong read_memory_limit_in_bytes() = 0; virtual const char * container_type() = 0; virtual CachingCgroupController* memory_controller() = 0; virtual CachingCgroupController* cpu_controller() = 0; + + virtual void print_version_specific_info(outputStream* st) = 0; }; // Utility class for storing info retrieved from /proc/cgroups, diff --git a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index 17f54d7d0db..79dd256ac61 100644 --- a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, 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 @@ -212,6 +212,38 @@ jlong CgroupV1Subsystem::memory_max_usage_in_bytes() { return memmaxusage; } + +jlong CgroupV1Subsystem::kernel_memory_usage_in_bytes() { + GET_CONTAINER_INFO(jlong, _memory->controller(), "/memory.kmem.usage_in_bytes", + "Kernel Memory Usage is: " JLONG_FORMAT, JLONG_FORMAT, kmem_usage); + return kmem_usage; +} + +jlong CgroupV1Subsystem::kernel_memory_limit_in_bytes() { + GET_CONTAINER_INFO(julong, _memory->controller(), "/memory.kmem.limit_in_bytes", + "Kernel Memory Limit is: " JULONG_FORMAT, JULONG_FORMAT, kmem_limit); + if (kmem_limit >= os::Linux::physical_memory()) { + return (jlong)-1; + } + return (jlong)kmem_limit; +} + +jlong CgroupV1Subsystem::kernel_memory_max_usage_in_bytes() { + GET_CONTAINER_INFO(jlong, _memory->controller(), "/memory.kmem.max_usage_in_bytes", + "Maximum Kernel Memory Usage is: " JLONG_FORMAT, JLONG_FORMAT, kmem_max_usage); + return kmem_max_usage; +} + +void CgroupV1Subsystem::print_version_specific_info(outputStream* st) { + jlong kmem_usage = kernel_memory_usage_in_bytes(); + jlong kmem_limit = kernel_memory_limit_in_bytes(); + jlong kmem_max_usage = kernel_memory_max_usage_in_bytes(); + + OSContainer::print_container_helper(st, kmem_usage, "kernel_memory_usage_in_bytes"); + OSContainer::print_container_helper(st, kmem_limit, "kernel_memory_max_usage_in_bytes"); + OSContainer::print_container_helper(st, kmem_max_usage, "kernel_memory_limit_in_bytes"); +} + char * CgroupV1Subsystem::cpu_cpuset_cpus() { GET_CONTAINER_INFO_CPTR(cptr, _cpuset, "/cpuset.cpus", "cpuset.cpus is: %s", "%1023s", cpus, 1024); diff --git a/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index ce92deb0084..07fac4a9461 100644 --- a/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -79,6 +79,11 @@ class CgroupV1Subsystem: public CgroupSubsystem { jlong memory_soft_limit_in_bytes(); jlong memory_usage_in_bytes(); jlong memory_max_usage_in_bytes(); + + jlong kernel_memory_usage_in_bytes(); + jlong kernel_memory_limit_in_bytes(); + jlong kernel_memory_max_usage_in_bytes(); + char * cpu_cpuset_cpus(); char * cpu_cpuset_memory_nodes(); @@ -90,6 +95,8 @@ class CgroupV1Subsystem: public CgroupSubsystem { jlong pids_max(); jlong pids_current(); + void print_version_specific_info(outputStream* st); + const char * container_type() { return "cgroupv1"; } diff --git a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index ad0ac6ed5e9..e6c7632032d 100644 --- a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -182,6 +182,16 @@ char* CgroupV2Subsystem::mem_swp_limit_val() { return os::strdup(mem_swp_limit_str); } +// memory.swap.current : total amount of swap currently used by the cgroup and its descendants +char* CgroupV2Subsystem::mem_swp_current_val() { + GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.swap.current", + "Swap currently used is: %s", "%s", mem_swp_current_str, 1024); + if (mem_swp_current_str == NULL) { + return NULL; + } + return os::strdup(mem_swp_current_str); +} + /* memory_limit_in_bytes * * Return the limit of available memory for this process. @@ -212,6 +222,17 @@ char* CgroupV2Subsystem::mem_limit_val() { return os::strdup(mem_limit_str); } +void CgroupV2Subsystem::print_version_specific_info(outputStream* st) { + char* mem_swp_current_str = mem_swp_current_val(); + jlong swap_current = limit_from_str(mem_swp_current_str); + + char* mem_swp_limit_str = mem_swp_limit_val(); + jlong swap_limit = limit_from_str(mem_swp_limit_str); + + OSContainer::print_container_helper(st, swap_current, "memory_swap_current_in_bytes"); + OSContainer::print_container_helper(st, swap_limit, "memory_swap_max_limit_in_bytes"); +} + char* CgroupV2Controller::construct_path(char* mount_path, char *cgroup_path) { char buf[MAXPATHLEN+1]; int buflen; diff --git a/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index beb78c21743..bda5872bbbc 100644 --- a/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Red Hat Inc. + * Copyright (c) 2020, 2022, 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 @@ -58,6 +58,7 @@ class CgroupV2Subsystem: public CgroupSubsystem { char *mem_limit_val(); char *mem_swp_limit_val(); + char *mem_swp_current_val(); char *mem_soft_limit_val(); char *cpu_quota_val(); char *pids_max_val(); @@ -77,11 +78,14 @@ class CgroupV2Subsystem: public CgroupSubsystem { jlong memory_soft_limit_in_bytes(); jlong memory_usage_in_bytes(); jlong memory_max_usage_in_bytes(); + char * cpu_cpuset_cpus(); char * cpu_cpuset_memory_nodes(); jlong pids_max(); jlong pids_current(); + void print_version_specific_info(outputStream* st); + const char * container_type() { return "cgroupv2"; } diff --git a/src/hotspot/os/linux/osContainer_linux.cpp b/src/hotspot/os/linux/osContainer_linux.cpp index 46fc76c27b1..29e0f0b1bbc 100644 --- a/src/hotspot/os/linux/osContainer_linux.cpp +++ b/src/hotspot/os/linux/osContainer_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -100,6 +100,11 @@ jlong OSContainer::memory_max_usage_in_bytes() { return cgroup_subsystem->memory_max_usage_in_bytes(); } +void OSContainer::print_version_specific_info(outputStream* st) { + assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); + cgroup_subsystem->print_version_specific_info(st); +} + char * OSContainer::cpu_cpuset_cpus() { assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); return cgroup_subsystem->cpu_cpuset_cpus(); @@ -139,3 +144,16 @@ jlong OSContainer::pids_current() { assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); return cgroup_subsystem->pids_current(); } + +void OSContainer::print_container_helper(outputStream* st, jlong j, const char* metrics) { + st->print("%s: ", metrics); + if (j > 0) { + if (j >= 1024) { + st->print_cr(UINT64_FORMAT " k", uint64_t(j) / 1024); + } else { + st->print_cr(UINT64_FORMAT, uint64_t(j)); + } + } else { + st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited"); + } +} diff --git a/src/hotspot/os/linux/osContainer_linux.hpp b/src/hotspot/os/linux/osContainer_linux.hpp index cdd2eb5e260..427d011b95a 100644 --- a/src/hotspot/os/linux/osContainer_linux.hpp +++ b/src/hotspot/os/linux/osContainer_linux.hpp @@ -27,6 +27,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +#include "utilities/ostream.hpp" #include "memory/allocation.hpp" #define OSCONTAINER_ERROR (-2) @@ -43,6 +44,9 @@ class OSContainer: AllStatic { public: static void init(); + static void print_version_specific_info(outputStream* st); + static void print_container_helper(outputStream* st, jlong j, const char* metrics); + static inline bool is_containerized(); static const char * container_type(); diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index f89a8c360b8..74945999e75 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -2460,19 +2460,6 @@ void os::Linux::print_uptime_info(outputStream* st) { } } -static void print_container_helper(outputStream* st, jlong j, const char* metrics) { - st->print("%s: ", metrics); - if (j > 0) { - if (j >= 1024) { - st->print_cr(UINT64_FORMAT " k", uint64_t(j) / 1024); - } else { - st->print_cr(UINT64_FORMAT, uint64_t(j)); - } - } else { - st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited"); - } -} - void os::Linux::print_container_info(outputStream* st) { if (!OSContainer::is_containerized()) { st->print_cr("container information not found."); @@ -2528,11 +2515,13 @@ void os::Linux::print_container_info(outputStream* st) { st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no shares"); } - print_container_helper(st, OSContainer::memory_limit_in_bytes(), "memory_limit_in_bytes"); - print_container_helper(st, OSContainer::memory_and_swap_limit_in_bytes(), "memory_and_swap_limit_in_bytes"); - print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes"); - print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes"); - print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_limit_in_bytes(), "memory_limit_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_and_swap_limit_in_bytes(), "memory_and_swap_limit_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes"); + + OSContainer::print_version_specific_info(st); jlong j = OSContainer::pids_max(); st->print("maximum number of tasks: "); diff --git a/test/hotspot/jtreg/containers/docker/TestMisc.java b/test/hotspot/jtreg/containers/docker/TestMisc.java index 27e865f98fc..564c64e63fc 100644 --- a/test/hotspot/jtreg/containers/docker/TestMisc.java +++ b/test/hotspot/jtreg/containers/docker/TestMisc.java @@ -123,6 +123,19 @@ private static void checkContainerInfo(OutputAnalyzer out) throws Exception { for (String s : expectedToContain) { out.shouldContain(s); } + String str = out.getOutput(); + if (str.contains("cgroupv1")) { + out.shouldContain("kernel_memory_usage_in_bytes"); + out.shouldContain("kernel_memory_max_usage_in_bytes"); + out.shouldContain("kernel_memory_limit_in_bytes"); + } else { + if (str.contains("cgroupv2")) { + out.shouldContain("memory_swap_current_in_bytes"); + out.shouldContain("memory_swap_max_limit_in_bytes"); + } else { + throw new RuntimeException("Output has to contain information about cgroupv1 or cgroupv2"); + } + } } } From 3f66b16257c0c444209fa5c8cf00c9b8c08c0fd0 Mon Sep 17 00:00:00 2001 From: Richard Reingruber Date: Thu, 15 Dec 2022 08:23:30 +0000 Subject: [PATCH 009/205] 8294580: frame::interpreter_frame_print_on() crashes if free BasicObjectLock exists in frame Reviewed-by: mdoerr Backport-of: bdb4ed0fb136e9e5391cfa520048de6b7f83067d --- src/hotspot/share/runtime/frame.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/frame.cpp b/src/hotspot/share/runtime/frame.cpp index 9c02ab3c873..83ead2e248c 100644 --- a/src/hotspot/share/runtime/frame.cpp +++ b/src/hotspot/share/runtime/frame.cpp @@ -579,8 +579,8 @@ void frame::interpreter_frame_print_on(outputStream* st) const { for (BasicObjectLock* current = interpreter_frame_monitor_end(); current < interpreter_frame_monitor_begin(); current = next_monitor_in_interpreter_frame(current)) { - st->print(" - obj ["); - current->obj()->print_value_on(st); + st->print(" - obj [%s", current->obj() == NULL ? "null" : ""); + if (current->obj() != NULL) current->obj()->print_value_on(st); st->print_cr("]"); st->print(" - lock ["); current->lock()->print_on(st); From 5f4b38a490ca41ce7d868cb46acfacdb4e7937f6 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 19 Dec 2022 08:21:21 +0000 Subject: [PATCH 010/205] 8290899: java/lang/String/StringRepeat.java test requests too much heap on windows x86 Backport-of: 2bb727c4eaf8a948f17f6416a1e6fbaeade4d7ce --- test/jdk/java/lang/String/StringRepeat.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/lang/String/StringRepeat.java b/test/jdk/java/lang/String/StringRepeat.java index 491bfe9f86f..c36e512f8ba 100644 --- a/test/jdk/java/lang/String/StringRepeat.java +++ b/test/jdk/java/lang/String/StringRepeat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -31,6 +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") * @run main/othervm -Xmx2g StringRepeat 16777216 */ From 8a4915e5e0fae857106b4a461d07cedbb7fc730a Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 19 Dec 2022 09:12:15 +0000 Subject: [PATCH 011/205] 8296904: Improve handling of macos xcode toolchain Reviewed-by: mbaesken Backport-of: 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a --- doc/building.html | 83 ++++++++++++++++++++++++------------------ doc/building.md | 44 +++++++++++----------- doc/testing.html | 16 ++++---- make/autoconf/basic.m4 | 14 ++++++- 4 files changed, 90 insertions(+), 67 deletions(-) diff --git a/doc/building.html b/doc/building.html index 7d6f18cd65d..79596224748 100644 --- a/doc/building.html +++ b/doc/building.html @@ -1,19 +1,24 @@ - + - - - + + + Building the JDK - - + + -
+

Building the JDK

Using the run-test framework

This new way of running tests is developer-centric. It assumes that you have built a JDK locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.

-

The main target “run-test” uses the jdk-image as the tested product. There is also an alternate target “exploded-run-test” that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.

+

The main target "run-test" uses the jdk-image as the tested product. There is also an alternate target "exploded-run-test" that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.

Some example command-lines:

$ make run-test-tier1
 $ make run-test-jdk_lang JTREG="JOBS=8"
@@ -55,7 +55,7 @@ 

Using the run-test framework

$ make run-test TEST="jtreg:test/hotspot:hotspot_gc test/hotspot/jtreg/native_sanity/JniVersion.java" $ make exploded-run-test TEST=tier2

Configuration

-

To be able to run JTReg tests, configure needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the --with-jtreg=<path to jtreg home> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing lib/jtreg.jar etc. (An alternative is to set the JT_HOME environment variable to point to the JTReg home before running configure.)

+

To be able to run JTReg tests, configure needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the --with-jtreg=<path to jtreg home> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing lib/jtreg.jar etc. (An alternative is to set the JT_HOME environment variable to point to the JTReg home before running configure.)

Test selection

All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the TEST variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.

For some common top-level tests, direct make targets have been generated. This includes all JTReg test groups, the hotspot gtest, and custom tests (if present). This means that make run-test-tier1 is equivalent to make run-test TEST="tier1", but the latter is more tab-completion friendly. For more complex test runs, the run-test TEST="x" solution needs to be used.

@@ -82,7 +82,7 @@

JTReg

Gtest

Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just gtest, or as a fully qualified test descriptor gtest:all.

If you want, you can single out an individual test or a group of tests, for instance gtest:LogDecorations or gtest:LogDecorations.level_test_vm. This can be particularly useful if you want to run a shaky test repeatedly.

-

For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant> to the test descriptor, e.g. gtest:Log/client. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all will be equivalent to gtest:all/server.

+

For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant> to the test descriptor, e.g. gtest:Log/client. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all will be equivalent to gtest:all/server.

Test results and summary

At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:

==============================
@@ -97,16 +97,16 @@ 

Test results and summary

Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the >> ... << marker for easy identification.

The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.

In case of test failures, make run-test will exit with a non-zero exit value.

-

All tests have their result stored in build/$BUILD/test-results/$TEST_ID, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID is jtreg_jdk_test_tier1. This path is also printed in the log at the end of the test run.

+

All tests have their result stored in build/$BUILD/test-results/$TEST_ID, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID is jtreg_jdk_test_tier1. This path is also printed in the log at the end of the test run.

Additional work data is stored in build/$BUILD/test-support/$TEST_ID. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.

Test suite control

It is possible to control various aspects of the test suites using make control variables.

These variables use a keyword=value approach to allow multiple values to be set. So, for instance, JTREG="JOBS=1;TIMEOUT=8" will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting JTREG_JOBS=1 JTREG_TIMEOUT=8, but using the keyword format means that the JTREG variable is parsed and verified for correctness, so JTREG="TMIEOUT=8" would give an error, while JTREG_TMIEOUT=8 would just pass unnoticed.

To separate multiple keyword=value pairs, use ; (semicolon). Since the shell normally eats ;, the recommended usage is to write the assignment inside qoutes, e.g. JTREG="...;...". This will also make sure spaces are preserved, as in JTREG="VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug".

-

(Other ways are possible, e.g. using backslash: JTREG=JOBS=1\;TIMEOUT=8. Also, as a special technique, the string %20 will be replaced with space for certain options, e.g. JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)

+

(Other ways are possible, e.g. using backslash: JTREG=JOBS=1\;TIMEOUT=8. Also, as a special technique, the string %20 will be replaced with space for certain options, e.g. JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)

As far as possible, the names of the keywords have been standardized between test suites.

General keywords (TEST_OPTS)

-

Some keywords are valid across different test suites. If you want to run tests from multiple test suites, or just don’t want to care which test suite specific control variable to use, then you can use the general TEST_OPTS control variable.

+

Some keywords are valid across different test suites. If you want to run tests from multiple test suites, or just don't want to care which test suite specific control variable to use, then you can use the general TEST_OPTS control variable.

There are also some keywords that applies globally to the test runner system, not to any specific test suites. These are also available as TEST_OPTS keywords.

JOBS

Currently only applies to JTReg.

@@ -179,11 +179,11 @@

Client UI Tests

Some Client UI tests use key sequences which may be reserved by the operating system. Usually that causes the test failure. So it is highly recommended to disable system key shortcuts prior testing. The steps to access and disable system key shortcuts for various platforms are provided below.

MacOS

Choose Apple menu; System Preferences, click Keyboard, then click Shortcuts; select or deselect desired shortcut.

-

For example, test/jdk/javax/swing/TooltipManager/JMenuItemToolTipKeyBindingsTest/JMenuItemToolTipKeyBindingsTest.java fails on MacOS because it uses CTRL + F1 key sequence to show or hide tooltip message but the key combination is reserved by the operating system. To run the test correctly the default global key shortcut should be disabled using the steps described above, and then deselect “Turn keyboard access on or off” option which is responsible for CTRL + F1 combination.

+

For example, test/jdk/javax/swing/TooltipManager/JMenuItemToolTipKeyBindingsTest/JMenuItemToolTipKeyBindingsTest.java fails on MacOS because it uses CTRL + F1 key sequence to show or hide tooltip message but the key combination is reserved by the operating system. To run the test correctly the default global key shortcut should be disabled using the steps described above, and then deselect "Turn keyboard access on or off" option which is responsible for CTRL + F1 combination.

Linux

Open the Activities overview and start typing Settings; Choose Settings, click Devices, then click Keyboard; set or override desired shortcut.

Windows

-

Type gpedit in the Search and then click Edit group policy; navigate to User Configuration -> Administrative Templates -> Windows Components -> File Explorer; in the right-side pane look for “Turn off Windows key hotkeys” and double click on it; enable or disable hotkeys.

+

Type gpedit in the Search and then click Edit group policy; navigate to User Configuration -> Administrative Templates -> Windows Components -> File Explorer; in the right-side pane look for "Turn off Windows key hotkeys" and double click on it; enable or disable hotkeys.

Note: restart is required to make the settings take effect.

diff --git a/make/autoconf/basic.m4 b/make/autoconf/basic.m4 index a3a4e132a4f..dc02d44c630 100644 --- a/make/autoconf/basic.m4 +++ b/make/autoconf/basic.m4 @@ -220,6 +220,18 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], [UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)] ) + AC_ARG_WITH([xcode-path], [AS_HELP_STRING([--with-xcode-path], + [set up toolchain on Mac OS using a path to an Xcode installation])]) + + if test "x$with_xcode_path" != x; then + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH], + $with_xcode_path/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$with_xcode_path/Contents/Developer/usr/bin) + else + AC_MSG_WARN([Option --with-xcode-path is only valid on Mac OS, ignoring.]) + fi + fi + AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path], [prepend these directories to the default path])], [UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)] @@ -230,7 +242,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], # If not, detect if Xcode is installed by running xcodebuild -version # if no Xcode installed, xcodebuild exits with 1 # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 - if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then + if test "x$DEVKIT_ROOT" != x || test "x$TOOLCHAIN_PATH" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then # We need to use xcodebuild in the toolchain dir provided by the user UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild, $TOOLCHAIN_PATH) if test x$XCODEBUILD = x; then From 674218b0b0ff3602f2082a70f752f05c29732ec6 Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 19 Dec 2022 09:29:52 +0000 Subject: [PATCH 012/205] 8287906: Rewrite of GitHub Actions (GHA) sanity tests 8288499: Restore cancel-in-progress in GHA Reviewed-by: phh, clanger Backport-of: 881ff368ceaff83ae78b1a17896c1ee45524bc84 --- .github/actions/config/action.yml | 46 + .github/actions/do-build/action.yml | 80 + .github/actions/get-bootjdk/action.yml | 109 + .github/actions/get-bundles/action.yml | 109 + .github/actions/get-jtreg/action.yml | 72 + .github/actions/get-msys2/action.yml | 44 + .github/actions/upload-bundles/action.yml | 77 + .github/scripts/gen-build-failure-report.sh | 51 + .github/scripts/gen-test-results.sh | 92 + .github/scripts/gen-test-summary.sh | 70 + .github/workflows/build-cross-compile.yml | 154 ++ .github/workflows/build-linux.yml | 127 + .github/workflows/build-macos.yml | 109 + .github/workflows/build-windows.yml | 126 + .github/workflows/main.yml | 331 +++ .github/workflows/submit.yml | 2038 ----------------- .github/workflows/test.yml | 205 ++ ...{test-dependencies => github-actions.conf} | 12 +- 18 files changed, 1807 insertions(+), 2045 deletions(-) create mode 100644 .github/actions/config/action.yml create mode 100644 .github/actions/do-build/action.yml create mode 100644 .github/actions/get-bootjdk/action.yml create mode 100644 .github/actions/get-bundles/action.yml create mode 100644 .github/actions/get-jtreg/action.yml create mode 100644 .github/actions/get-msys2/action.yml create mode 100644 .github/actions/upload-bundles/action.yml create mode 100644 .github/scripts/gen-build-failure-report.sh create mode 100644 .github/scripts/gen-test-results.sh create mode 100644 .github/scripts/gen-test-summary.sh create mode 100644 .github/workflows/build-cross-compile.yml create mode 100644 .github/workflows/build-linux.yml create mode 100644 .github/workflows/build-macos.yml create mode 100644 .github/workflows/build-windows.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/submit.yml create mode 100644 .github/workflows/test.yml rename make/conf/{test-dependencies => github-actions.conf} (85%) diff --git a/.github/actions/config/action.yml b/.github/actions/config/action.yml new file mode 100644 index 00000000000..5f648ffc022 --- /dev/null +++ b/.github/actions/config/action.yml @@ -0,0 +1,46 @@ +# +# 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. 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. +# + +name: 'Config' +description: 'Read JDK Configuration Variables' +inputs: + var: + description: 'The name of the variable to read' + required: true +outputs: + value: + description: 'The value of the configuration variable' + value: ${{ steps.read-config.outputs.value }} + +runs: + using: composite + steps: + - name: 'Read configuration variable from repo' + id: read-config + run: | + # Extract value from configuration file + value="$(grep -h ${{ inputs.var }}= make/conf/github-actions.conf | cut -d '=' -f 2-)" + echo "value=$value" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/do-build/action.yml b/.github/actions/do-build/action.yml new file mode 100644 index 00000000000..3deb7f4b8f8 --- /dev/null +++ b/.github/actions/do-build/action.yml @@ -0,0 +1,80 @@ +# +# 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. 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. +# + +name: 'Do build' +description: 'Build the JDK using make' +inputs: + make-target: + description: 'Make target(s)' + required: true + platform: + description: 'Platform name' + required: true + debug-suffix: + description: 'File name suffix denoting debug level, possibly empty' + required: false + +runs: + using: composite + steps: + - name: 'Build' + id: build + run: > + make LOG=info ${{ inputs.make-target }} + || bash ./.github/scripts/gen-build-failure-report.sh "$GITHUB_STEP_SUMMARY" + shell: bash + + - name: 'Check for failure' + id: check + run: | + # Check for failure marker file + build_dir="$(ls -d build/*)" + if [[ -e $build_dir/build-failure ]]; then + # Collect relevant log files + mkdir failure-logs + cp \ + $build_dir/spec.gmk \ + $build_dir/build.log \ + $build_dir/configure.log \ + $build_dir/make-support/failure-summary.log \ + $build_dir/make-support/failure-logs/* \ + failure-logs/ 2> /dev/null || true + echo 'failure=true' >> $GITHUB_OUTPUT + fi + shell: bash + + - name: 'Upload build logs' + uses: actions/upload-artifact@v3 + with: + name: failure-logs-${{ inputs.platform }}${{ inputs.debug-suffix }} + path: failure-logs + if: steps.check.outputs.failure == 'true' + + # 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 + 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 new file mode 100644 index 00000000000..19c3a0128f4 --- /dev/null +++ b/.github/actions/get-bootjdk/action.yml @@ -0,0 +1,109 @@ +# +# 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. 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. +# + +name: 'Get BootJDK' +description: 'Download the BootJDK from cache or source location' +inputs: + platform: + description: 'Platform' + required: true +outputs: + path: + description: 'Path to the installed BootJDK' + value: ${{ steps.path-name.outputs.path }} + +runs: + using: composite + steps: + - name: 'Determine platform prefix' + id: platform-prefix + run: | + # Convert platform name to upper case + platform_prefix="$(echo ${{ inputs.platform }} | tr [a-z-] [A-Z_])" + echo "value=$platform_prefix" >> $GITHUB_OUTPUT + shell: bash + + - name: 'Get URL configuration' + id: url + uses: ./.github/actions/config + with: + var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_URL + + - name: 'Get SHA256 configuration' + id: sha256 + uses: ./.github/actions/config + with: + var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_SHA256 + + - name: 'Get file extension configuration' + id: ext + uses: ./.github/actions/config + with: + var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_EXT + + - name: 'Check cache for BootJDK' + id: get-cached-bootjdk + uses: actions/cache@v3 + with: + path: bootjdk/jdk + key: boot-jdk-${{ inputs.platform }}-${{ steps.sha256.outputs.value }} + + # macOS is missing sha256sum + - name: 'Install sha256sum' + run: | + # Run Homebrew installation + brew install coreutils + shell: bash + if: steps.get-cached-bootjdk.outputs.cache-hit != 'true' && runner.os == 'macOS' + + - name: 'Download BootJDK' + run: | + # Download BootJDK and verify checksum + mkdir -p bootjdk/jdk + mkdir -p bootjdk/unpacked + wget --progress=dot:mega -O bootjdk/jdk.${{ steps.ext.outputs.value }} '${{ steps.url.outputs.value }}' + echo '${{ steps.sha256.outputs.value }} bootjdk/jdk.${{ steps.ext.outputs.value }}' | sha256sum -c >/dev/null - + shell: bash + if: steps.get-cached-bootjdk.outputs.cache-hit != 'true' + + - name: 'Unpack BootJDK' + run: | + # Unpack the BootJDK and move files to a common location + if [[ '${{ steps.ext.outputs.value }}' == 'tar.gz' ]]; then + tar -xf bootjdk/jdk.${{ steps.ext.outputs.value }} -C bootjdk/unpacked + else + unzip -q bootjdk/jdk.${{ steps.ext.outputs.value }} -d bootjdk/unpacked + fi + jdk_root="$(dirname $(find bootjdk/unpacked -name bin -type d))" + mv "$jdk_root"/* bootjdk/jdk/ + shell: bash + if: steps.get-cached-bootjdk.outputs.cache-hit != 'true' + + - name: 'Export path to where BootJDK is installed' + id: path-name + run: | + # Export the path + echo 'path=bootjdk/jdk' >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml new file mode 100644 index 00000000000..956e1520cfb --- /dev/null +++ b/.github/actions/get-bundles/action.yml @@ -0,0 +1,109 @@ +# +# 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. 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. +# + +name: 'Get bundles' +description: 'Download resulting JDK bundles' +inputs: + platform: + description: 'Platform name' + required: true + debug-suffix: + description: 'File name suffix denoting debug level, possibly empty' + required: false +outputs: + jdk-path: + description: 'Path to the installed JDK bundle' + value: ${{ steps.path-name.outputs.jdk }} + symbols-path: + description: 'Path to the installed symbols bundle' + value: ${{ steps.path-name.outputs.symbols }} + tests-path: + description: 'Path to the installed tests bundle' + value: ${{ steps.path-name.outputs.tests }} + +runs: + using: composite + steps: + - name: 'Download bundles artifact' + id: download-bundles + uses: actions/download-artifact@v3 + with: + name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} + path: bundles + continue-on-error: true + + - name: 'Download bundles artifact (retry)' + uses: actions/download-artifact@v3 + with: + name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} + path: bundles + if: steps.download-bundles.outcome == 'failure' + + - name: 'Unpack bundles' + run: | + if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then + echo 'Unpacking jdk bundle...' + mkdir -p bundles/jdk + unzip -q bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d bundles/jdk + fi + + if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + echo 'Unpacking jdk bundle...' + mkdir -p bundles/jdk + tar -xf bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/jdk + fi + + if [[ -e bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + echo 'Unpacking symbols bundle...' + mkdir -p bundles/symbols + tar -xf bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/symbols + fi + + if [[ -e bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + echo 'Unpacking tests bundle...' + mkdir -p bundles/tests + tar -xf bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/tests + fi + shell: bash + + - name: 'Export paths to where bundles are installed' + id: path-name + run: | + # Export the paths + + jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/jdk -name bin -type d))" + symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/symbols -name bin -type d))" + tests_dir="$GITHUB_WORKSPACE/bundles/tests" + + if [[ '${{ runner.os }}' == 'Windows' ]]; then + jdk_dir="$(cygpath $jdk_dir)" + symbols_dir="$(cygpath $symbols_dir)" + tests_dir="$(cygpath $tests_dir)" + fi + + echo "jdk=$jdk_dir" >> $GITHUB_OUTPUT + echo "symbols=$symbols_dir" >> $GITHUB_OUTPUT + echo "tests=$tests_dir" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml new file mode 100644 index 00000000000..7c49b1054ec --- /dev/null +++ b/.github/actions/get-jtreg/action.yml @@ -0,0 +1,72 @@ +# +# 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. 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. +# + +name: 'Get JTReg' +description: 'Download JTReg from cache or source location' +outputs: + path: + description: 'Path to the installed JTReg' + value: ${{ steps.path-name.outputs.path }} + +runs: + using: composite + steps: + - name: 'Get JTReg version configuration' + id: version + uses: ./.github/actions/config + with: + var: JTREG_VERSION + + - name: 'Check cache for JTReg' + id: get-cached-jtreg + uses: actions/cache@v3 + with: + path: jtreg/installed + key: jtreg-${{ steps.version.outputs.value }} + + - name: 'Checkout the JTReg source' + uses: actions/checkout@v3 + with: + repository: openjdk/jtreg + ref: jtreg-${{ steps.version.outputs.value }} + path: jtreg/src + if: steps.get-cached-jtreg.outputs.cache-hit != 'true' + + - name: 'Build JTReg' + run: | + # Build JTReg and move files to the proper locations + bash make/build.sh --jdk "$JAVA_HOME_11_X64" + mkdir ../installed + mv build/images/jtreg/* ../installed + working-directory: jtreg/src + shell: bash + if: steps.get-cached-jtreg.outputs.cache-hit != 'true' + + - name: 'Export path to where JTReg is installed' + id: path-name + run: | + # Export the path + echo 'path=jtreg/installed' >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/get-msys2/action.yml b/.github/actions/get-msys2/action.yml new file mode 100644 index 00000000000..3e6c3417a31 --- /dev/null +++ b/.github/actions/get-msys2/action.yml @@ -0,0 +1,44 @@ +# +# 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. 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. +# + +name: 'Get MSYS2' +description: 'Download MSYS2 and prepare a Windows host' + +runs: + using: composite + steps: + - name: 'Install MSYS2' + uses: msys2/setup-msys2@v2 + with: + install: 'autoconf tar unzip zip make' + path-type: minimal + location: msys2 + + # We can't run bash until this is completed, so stick with pwsh + - name: 'Set MSYS2 path' + run: | + # Prepend msys2/msys64/usr/bin to the PATH + echo "$env:GITHUB_WORKSPACE/msys2/msys64/usr/bin" >> $env:GITHUB_PATH + shell: pwsh diff --git a/.github/actions/upload-bundles/action.yml b/.github/actions/upload-bundles/action.yml new file mode 100644 index 00000000000..88f7f6e8107 --- /dev/null +++ b/.github/actions/upload-bundles/action.yml @@ -0,0 +1,77 @@ +# +# 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. 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. +# + +name: 'Upload bundles' +description: 'Upload resulting JDK bundles' +inputs: + platform: + description: 'Platform name' + required: true + debug-suffix: + description: 'File name suffix denoting debug level, possibly empty' + required: false + +runs: + using: composite + steps: + + - name: 'Determine bundle names' + id: bundles + run: | + # Rename bundles to consistent names + jdk_bundle_zip="$(ls build/*/bundles/jdk-*_bin${{ inputs.debug-suffix }}.zip 2> /dev/null || true)" + jdk_bundle_tar_gz="$(ls build/*/bundles/jdk-*_bin${{ inputs.debug-suffix }}.tar.gz 2> /dev/null || true)" + symbols_bundle="$(ls build/*/bundles/jdk-*_bin${{ inputs.debug-suffix }}-symbols.tar.gz 2> /dev/null || true)" + tests_bundle="$(ls build/*/bundles/jdk-*_bin-tests${{ inputs.debug-suffix }}.tar.gz 2> /dev/null || true)" + + mkdir bundles + + if [[ "$jdk_bundle_zip" != "" ]]; then + mv "$jdk_bundle_zip" "bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip" + fi + if [[ "$jdk_bundle_tar_gz" != "" ]]; then + mv "$jdk_bundle_tar_gz" "bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz" + fi + if [[ "$symbols_bundle" != "" ]]; then + mv "$symbols_bundle" "bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz" + fi + if [[ "$tests_bundle" != "" ]]; then + mv "$tests_bundle" "bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz" + fi + + if [[ "$jdk_bundle_zip$jdk_bundle_tar_gz$symbols_bundle$tests_bundle" != "" ]]; then + echo 'bundles-found=true' >> $GITHUB_OUTPUT + else + echo 'bundles-found=false' >> $GITHUB_OUTPUT + fi + shell: bash + + - name: 'Upload bundles artifact' + uses: actions/upload-artifact@v3 + with: + name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} + path: bundles + retention-days: 1 + if: steps.bundles.outputs.bundles-found == 'true' diff --git a/.github/scripts/gen-build-failure-report.sh b/.github/scripts/gen-build-failure-report.sh new file mode 100644 index 00000000000..fd3215fc7fe --- /dev/null +++ b/.github/scripts/gen-build-failure-report.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# 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. 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. +# + +GITHUB_STEP_SUMMARY="$1" +BUILD_DIR="$(ls -d build/*)" + +# Send signal to the do-build action that we failed +touch "$BUILD_DIR/build-failure" + +( + echo '### :boom: Build failure summary' + echo '' + echo 'The build failed. Here follows the failure summary from the build.' + echo '
View build failure summary' + echo '' + echo '```' + if [[ -f "$BUILD_DIR/make-support/failure-summary.log" ]]; then + cat "$BUILD_DIR/make-support/failure-summary.log" + else + echo "Failure summary ($BUILD_DIR/make-support/failure-summary.log) not found" + fi + echo '```' + echo '
' + echo '' + + echo '' + echo ':arrow_right: To see the entire test log, click the job in the list to the left. To download logs, see the `failure-logs` [artifact above](#artifacts).' +) >> $GITHUB_STEP_SUMMARY diff --git a/.github/scripts/gen-test-results.sh b/.github/scripts/gen-test-results.sh new file mode 100644 index 00000000000..73edb8b3d11 --- /dev/null +++ b/.github/scripts/gen-test-results.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# 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. 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. +# + +GITHUB_STEP_SUMMARY="$1" + +test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) +results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text +report_dir=build/run-test-prebuilt/test-support/$test_suite_name + +failures=$(sed -E -e 's/(.*)\.(java|sh)/\1/' -e '/^#/d' $results_dir/newfailures.txt 2> /dev/null || true) +errors=$(sed -E -e 's/(.*)\.(java|sh)/\1/' -e '/^#/d' $results_dir/other_errors.txt 2> /dev/null || true) + +if [[ "$failures" = "" && "$errors" = "" ]]; then + # If we have nothing to report, exit this step now + exit 0 +fi + +echo "### Test output for failed tests" >> $GITHUB_STEP_SUMMARY +for test in $failures $errors; do + anchor="$(echo "$test" | tr [A-Z/] [a-z_])" + base_path="$(echo "$test" | tr '#' '_')" + report_file="$report_dir/$base_path.jtr" + hs_err_files=$(ls $report_dir/$base_path/hs_err*.log 2> /dev/null || true) + echo "#### $test" + + echo '
View test results' + echo '' + echo '```' + if [[ -f "$report_file" ]]; then + cat "$report_file" + else + echo "Error: Result file $report_file not found" + fi + echo '```' + echo '
' + echo '' + + if [[ "$hs_err_files" != "" ]]; then + echo '
View HotSpot error log' + echo '' + for hs_err in $hs_err_files; do + echo '```' + echo "$hs_err:" + echo '' + cat "$hs_err" + echo '```' + done + + echo '
' + echo '' + fi + +done >> $GITHUB_STEP_SUMMARY + +# With many failures, the summary can easily exceed 1024 kB, the limit set by Github +# Trim it down if so. +summary_size=$(wc -c < $GITHUB_STEP_SUMMARY) +if [[ $summary_size -gt 1000000 ]]; then + # Trim to below 1024 kB, and cut off after the last detail group + head -c 1000000 $GITHUB_STEP_SUMMARY | tac | sed -n -e '/<\/details>/,$ p' | tac > $GITHUB_STEP_SUMMARY.tmp + mv $GITHUB_STEP_SUMMARY.tmp $GITHUB_STEP_SUMMARY + ( + echo '' + echo ':x: **WARNING: Summary is too large and has been truncated.**' + echo '' + ) >> $GITHUB_STEP_SUMMARY +fi + +echo ':arrow_right: To see the entire test log, click the job in the list to the left.' >> $GITHUB_STEP_SUMMARY diff --git a/.github/scripts/gen-test-summary.sh b/.github/scripts/gen-test-summary.sh new file mode 100644 index 00000000000..d016cb38649 --- /dev/null +++ b/.github/scripts/gen-test-summary.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# 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. 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. +# + +GITHUB_STEP_SUMMARY="$1" +GITHUB_OUTPUT="$2" + +test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) +results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text + +if [[ ! -f build/run-test-prebuilt/make-support/exit-with-error ]]; then + # There were no failures, exit now + exit +fi + +failures=$(sed -E -e 's/(.*)\.(java|sh)/\1/' -e '/^#/d' $results_dir/newfailures.txt 2> /dev/null || true) +errors=$(sed -E -e 's/(.*)\.(java|sh)/\1/' -e '/^#/d' $results_dir/other_errors.txt 2> /dev/null || true) +failure_count=$(echo $failures | wc -w || true) +error_count=$(echo $errors | wc -w || true) + +if [[ "$failures" = "" && "$errors" = "" ]]; then + # We know something went wrong, but not what + echo 'error-message=Unspecified test suite failure. Please see log for job for details.' >> $GITHUB_OUTPUT + exit 0 +fi + +echo 'failure=true' >> $GITHUB_OUTPUT +echo "error-message=Test run reported $failure_count test failure(s) and $error_count error(s). See summary for details." >> $GITHUB_OUTPUT + +echo '### :boom: Test failures summary' >> $GITHUB_STEP_SUMMARY + +if [[ "$failures" != "" ]]; then + echo '' >> $GITHUB_STEP_SUMMARY + echo 'These tests reported failure:' >> $GITHUB_STEP_SUMMARY + for test in $failures; do + anchor="$(echo "$test" | tr [A-Z/] [a-z_])" + echo "* [$test](#user-content-$anchor)" + done >> $GITHUB_STEP_SUMMARY +fi + +if [[ "$errors" != "" ]]; then + echo '' >> $GITHUB_STEP_SUMMARY + echo 'These tests reported errors:' >> $GITHUB_STEP_SUMMARY + for test in $errors; do + anchor="$(echo "$test" | tr [A-Z/] [a-z_])" + echo "* [$test](#user-content-$anchor)" + done >> $GITHUB_STEP_SUMMARY +fi diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml new file mode 100644 index 00000000000..168c5924d86 --- /dev/null +++ b/.github/workflows/build-cross-compile.yml @@ -0,0 +1,154 @@ +# +# 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. 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. +# + +name: 'Build (cross-compile)' + +on: + workflow_call: + inputs: + gcc-major-version: + required: false + type: string + default: '10' + apt-gcc-version: + required: false + type: string + default: '10.3.0-1ubuntu1~20.04' + apt-gcc-cross-suffix: + required: false + type: string + default: 'cross1' + +jobs: + build-cross-compile: + name: build + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + target-cpu: + - aarch64 + - arm + - s390x + - ppc64le + include: + - target-cpu: aarch64 + debian-arch: arm64 + gnu-arch: aarch64 + - target-cpu: arm + debian-arch: armhf + gnu-arch: arm + gnu-abi: eabihf + - target-cpu: s390x + debian-arch: s390x + gnu-arch: s390x + - target-cpu: ppc64le + debian-arch: ppc64el + gnu-arch: powerpc64le + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + 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: | + # Install dependencies using apt-get + sudo apt-get update + sudo apt-get install --only-upgrade apt + sudo apt-get install \ + gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ + g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ + gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-version }}${{ inputs.apt-gcc-cross-suffix }} \ + g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-version }}${{ inputs.apt-gcc-cross-suffix }} \ + libxrandr-dev libxtst-dev libcups2-dev libasound2-dev + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} + + - name: 'Check cache for sysroot' + id: get-cached-sysroot + uses: actions/cache@v3 + with: + path: sysroot + key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} + + - name: 'Install sysroot dependencies' + run: sudo apt-get install debootstrap qemu-user-static + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Create sysroot' + run: > + sudo qemu-debootstrap + --arch=${{ matrix.debian-arch }} + --verbose + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev + --resolve-deps + buster + sysroot + https://httpredir.debian.org/debian/ + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Prepare sysroot' + run: | + # Prepare sysroot and remove unused files to minimize cache + sudo chroot sysroot symlinks -cr . + sudo chown ${USER} -R sysroot + rm -rf sysroot/{dev,proc,run,sys} + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Configure' + run: > + bash configure + --with-conf-name=linux-${{ matrix.target-cpu }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-zlib=system + --enable-debug + --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-10 + CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-10 + + - name: 'Build' + id: build + uses: ./.github/actions/do-build + with: + make-target: 'hotspot' + platform: linux-${{ matrix.target-cpu }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 00000000000..7f981118e23 --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,127 @@ +# +# 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. 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. +# + +name: 'Build (linux)' + +on: + workflow_call: + inputs: + platform: + required: true + type: string + extra-conf-options: + required: false + type: string + make-target: + required: false + type: string + default: 'product-bundles test-bundles' + debug-levels: + required: false + type: string + default: '[ "debug", "release" ]' + apt-gcc-version: + required: true + type: string + apt-architecture: + required: false + type: string + apt-extra-packages: + required: false + type: string + +jobs: + build-linux: + name: build + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + debug-level: ${{ fromJSON(inputs.debug-levels) }} + include: + - debug-level: debug + flags: --with-debug-level=fastdebug + suffix: -debug + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: linux-x64 + + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Set architecture' + id: arch + run: | + # Set a proper suffix for packages if using a different architecture + if [[ '${{ inputs.apt-architecture }}' != '' ]]; then + echo 'suffix=:${{ inputs.apt-architecture }}' >> $GITHUB_OUTPUT + fi + + # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. + - name: 'Install toolchain and dependencies' + run: | + # Install dependencies using apt-get + if [[ '${{ inputs.apt-architecture }}' != '' ]]; then + sudo dpkg --add-architecture ${{ inputs.apt-architecture }} + fi + sudo apt-get update + sudo apt-get install --only-upgrade apt + sudo apt-get install gcc-${{ inputs.apt-gcc-version }} g++-${{ inputs.apt-gcc-version }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 + + - name: 'Configure' + run: > + bash configure + --with-conf-name=${{ inputs.platform }} + ${{ matrix.flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-jtreg=${{ steps.jtreg.outputs.path }} + --enable-jtreg-failure-handler + --with-zlib=system + ${{ inputs.extra-conf-options }} + + - name: 'Build' + id: build + uses: ./.github/actions/do-build + with: + make-target: '${{ inputs.make-target }}' + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' + + - name: 'Upload bundles' + uses: ./.github/actions/upload-bundles + with: + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 00000000000..b00f7e091dd --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,109 @@ +# +# 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. 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. +# + +name: 'Build (macos)' + +on: + workflow_call: + inputs: + platform: + required: true + type: string + extra-conf-options: + required: false + type: string + make-target: + required: false + type: string + default: 'product-bundles test-bundles' + debug-levels: + required: false + type: string + default: '[ "debug", "release" ]' + xcode-toolset-version: + required: true + type: string + +jobs: + build-macos: + name: build + runs-on: macos-11 + + strategy: + fail-fast: false + matrix: + debug-level: ${{ fromJSON(inputs.debug-levels) }} + include: + - debug-level: debug + flags: --with-debug-level=fastdebug + suffix: -debug + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: macos-x64 + + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Install toolchain and dependencies' + run: | + # Run Homebrew installation and xcode-select + brew install make + sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-toolset-version }}.app/Contents/Developer + # This will make GNU make available as 'make' and not only as 'gmake' + echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH + + - name: 'Configure' + run: > + bash configure + --with-conf-name=${{ inputs.platform }} + ${{ matrix.flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-jtreg=${{ steps.jtreg.outputs.path }} + --enable-jtreg-failure-handler + --with-zlib=system + ${{ inputs.extra-conf-options }} + + - name: 'Build' + id: build + uses: ./.github/actions/do-build + with: + make-target: '${{ inputs.make-target }}' + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' + + - name: 'Upload bundles' + uses: ./.github/actions/upload-bundles + with: + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 00000000000..4983ffd7042 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,126 @@ +# +# 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. 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. +# + +name: 'Build (windows)' + +on: + workflow_call: + inputs: + platform: + required: true + type: string + extra-conf-options: + required: false + type: string + make-target: + required: false + type: string + default: 'product-bundles test-bundles' + debug-levels: + required: false + type: string + default: '[ "debug", "release" ]' + msvc-toolset-version: + required: true + type: string + msvc-toolset-architecture: + required: true + type: string + +env: + # These are needed to make the MSYS2 bash work properly + MSYS2_PATH_TYPE: minimal + CHERE_INVOKING: 1 + +jobs: + build-windows: + name: build + runs-on: windows-2019 + defaults: + run: + shell: bash + + strategy: + fail-fast: false + matrix: + debug-level: ${{ fromJSON(inputs.debug-levels) }} + include: + - debug-level: debug + flags: --with-debug-level=fastdebug + suffix: -debug + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Get MSYS2' + uses: ./.github/actions/get-msys2 + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: windows-x64 + + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Install toolchain and dependencies' + run: | + # Run Visual Studio Installer + '/c/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe' \ + modify --quiet --installPath 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise' \ + --add Microsoft.VisualStudio.Component.VC.${{ inputs.msvc-toolset-version }}.${{ inputs.msvc-toolset-architecture }} + + - name: 'Configure' + run: > + bash configure + --with-conf-name=${{ inputs.platform }} + ${{ matrix.flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-jtreg=${{ steps.jtreg.outputs.path }} + --enable-jtreg-failure-handler + --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }} + ${{ inputs.extra-conf-options }} + env: + # We need a minimal PATH on Windows + # Set PATH to "", so just GITHUB_PATH is included + PATH: '' + + - name: 'Build' + id: build + uses: ./.github/actions/do-build + with: + make-target: '${{ inputs.make-target }}' + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' + + - name: 'Upload bundles' + uses: ./.github/actions/upload-bundles + with: + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..2cc6e0a1f55 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,331 @@ +# +# 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. 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. +# + +name: 'OpenJDK GHA Sanity Checks' + +on: + push: + branches-ignore: + - master + - pr/* + workflow_dispatch: + inputs: + platforms: + description: 'Platform(s) to execute on (comma separated, e.g. "linux-x64, macos, aarch64")' + required: true + default: 'linux-x64, linux-x86, linux-x64-variants, linux-cross-compile, macos-x64, macos-aarch64, windows-x64, windows-aarch64' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + ### + ### Determine platforms to include + ### + + select: + name: 'Select platforms' + runs-on: ubuntu-20.04 + outputs: + linux-x64: ${{ steps.include.outputs.linux-x64 }} + linux-x86: ${{ steps.include.outputs.linux-x86 }} + linux-x64-variants: ${{ steps.include.outputs.linux-x64-variants }} + linux-cross-compile: ${{ steps.include.outputs.linux-cross-compile }} + macos-x64: ${{ steps.include.outputs.macos-x64 }} + macos-aarch64: ${{ steps.include.outputs.macos-aarch64 }} + windows-x64: ${{ steps.include.outputs.windows-x64 }} + windows-aarch64: ${{ steps.include.outputs.windows-aarch64 }} + + steps: + # This function must be inlined in main.yml, or we'd be forced to checkout the repo + - name: 'Check what jobs to run' + id: include + run: | + # Determine which platform jobs to run + + # Returns 'true' if the input platform list matches any of the platform monikers given as argument, + # 'false' otherwise. + # arg $1: platform name or names to look for + function check_platform() { + if [[ '${{ !secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/') }}' == 'false' ]]; then + # If JDK_SUBMIT_FILTER is set, and this is not a "submit/" branch, don't run anything + echo 'false' + return + fi + + if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then + input='${{ github.event.inputs.platforms }}' + elif [[ $GITHUB_EVENT_NAME == push ]]; then + input='${{ secrets.JDK_SUBMIT_PLATFORMS }}' + else + echo 'Internal error in GHA' + exit 1 + fi + + normalized_input="$(echo ,$input, | tr -d ' ')" + if [[ "$normalized_input" == ",," ]]; then + # For an empty input, assume all platforms should run + echo 'true' + return + else + # Check for all acceptable platform names + for part in $* ; do + if echo "$normalized_input" | grep -q -e ",$part," ; then + echo 'true' + return + fi + done + fi + + echo 'false' + } + + echo "linux-x64=$(check_platform linux-x64 linux x64)" >> $GITHUB_OUTPUT + echo "linux-x86=$(check_platform linux-x86 linux x86)" >> $GITHUB_OUTPUT + echo "linux-x64-variants=$(check_platform linux-x64-variants variants)" >> $GITHUB_OUTPUT + echo "linux-cross-compile=$(check_platform linux-cross-compile cross-compile)" >> $GITHUB_OUTPUT + echo "macos-x64=$(check_platform macos-x64 macos x64)" >> $GITHUB_OUTPUT + echo "macos-aarch64=$(check_platform macos-aarch64 macos aarch64)" >> $GITHUB_OUTPUT + echo "windows-x64=$(check_platform windows-x64 windows x64)" >> $GITHUB_OUTPUT + echo "windows-aarch64=$(check_platform windows-aarch64 windows aarch64)" >> $GITHUB_OUTPUT + + ### + ### Build jobs + ### + + build-linux-x64: + name: linux-x64 + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x64 + apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + # 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' + + build-linux-x86: + name: linux-x86 + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x86 + apt-gcc-version: '10-multilib' + apt-architecture: 'i386' + # Some multilib libraries do not have proper inter-dependencies, so we have to + # install their dependencies manually. + apt-extra-packages: 'libfreetype6-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386' + extra-conf-options: '--with-target-bits=32' + if: needs.select.outputs.linux-x86 == 'true' + + build-linux-x64-hs-nopch: + name: linux-x64-hs-nopch + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x64 + make-target: 'hotspot' + debug-levels: '[ "debug" ]' + apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + extra-conf-options: '--disable-precompiled-headers' + if: needs.select.outputs.linux-x64-variants == 'true' + + build-linux-x64-hs-zero: + name: linux-x64-hs-zero + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x64 + make-target: 'hotspot' + debug-levels: '[ "debug" ]' + apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers' + if: needs.select.outputs.linux-x64-variants == 'true' + + build-linux-x64-hs-minimal: + name: linux-x64-hs-minimal + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x64 + make-target: 'hotspot' + debug-levels: '[ "debug" ]' + apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers' + if: needs.select.outputs.linux-x64-variants == 'true' + + build-linux-x64-hs-optimized: + name: linux-x64-hs-optimized + needs: select + uses: ./.github/workflows/build-linux.yml + with: + platform: linux-x64 + make-target: 'hotspot' + # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job + debug-levels: '[ "debug" ]' + apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' + if: needs.select.outputs.linux-x64-variants == 'true' + + build-linux-cross-compile: + name: linux-cross-compile + needs: + - select + - build-linux-x64 + uses: ./.github/workflows/build-cross-compile.yml + if: needs.select.outputs.linux-cross-compile == 'true' + + build-macos-x64: + name: macos-x64 + needs: select + uses: ./.github/workflows/build-macos.yml + with: + platform: macos-x64 + xcode-toolset-version: '11.7' + if: needs.select.outputs.macos-x64 == 'true' + + build-macos-aarch64: + name: macos-aarch64 + needs: select + uses: ./.github/workflows/build-macos.yml + with: + platform: macos-aarch64 + xcode-toolset-version: '12.4' + extra-conf-options: '--openjdk-target=aarch64-apple-darwin' + if: needs.select.outputs.macos-aarch64 == 'true' + + build-windows-x64: + name: windows-x64 + needs: select + uses: ./.github/workflows/build-windows.yml + with: + platform: windows-x64 + msvc-toolset-version: '14.28' + msvc-toolset-architecture: 'x86.x64' + if: needs.select.outputs.windows-x64 == 'true' + + build-windows-aarch64: + name: windows-aarch64 + needs: select + uses: ./.github/workflows/build-windows.yml + with: + platform: windows-aarch64 + msvc-toolset-version: '14.29' + msvc-toolset-architecture: 'arm64' + make-target: 'hotspot' + extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin' + if: needs.select.outputs.windows-aarch64 == 'true' + + ### + ### Test jobs + ### + + test-linux-x64: + name: linux-x64 + needs: + - build-linux-x64 + uses: ./.github/workflows/test.yml + with: + platform: linux-x64 + bootjdk-platform: linux-x64 + runs-on: ubuntu-20.04 + + test-linux-x86: + name: linux-x86 + needs: + - build-linux-x86 + uses: ./.github/workflows/test.yml + with: + platform: linux-x86 + bootjdk-platform: linux-x64 + runs-on: ubuntu-20.04 + + test-macos-x64: + name: macos-x64 + needs: + - build-macos-x64 + uses: ./.github/workflows/test.yml + with: + platform: macos-x64 + bootjdk-platform: macos-x64 + runs-on: macos-11 + + test-windows-x64: + name: windows-x64 + needs: + - build-windows-x64 + uses: ./.github/workflows/test.yml + with: + platform: windows-x64 + bootjdk-platform: windows-x64 + runs-on: windows-2019 + + # Remove bundles so they are not misconstrued as binary distributions from the JDK project + remove-bundles: + name: 'Remove bundle artifacts' + runs-on: ubuntu-20.04 + if: always() + needs: + - build-linux-x64 + - build-linux-x86 + - build-linux-x64-hs-nopch + - build-linux-x64-hs-zero + - build-linux-x64-hs-minimal + - build-linux-x64-hs-optimized + - build-linux-cross-compile + - build-macos-x64 + - build-macos-aarch64 + - build-windows-x64 + - build-windows-aarch64 + - test-linux-x64 + - test-linux-x86 + - test-macos-x64 + - test-windows-x64 + + steps: + # 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 + with: + script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }' + + - name: 'Remove bundle artifacts' + run: | + # Find and remove all bundle artifacts + ALL_ARTIFACT_URLS="$(curl -s \ + -H 'Accept: application/json;api-version=6.0-preview' \ + -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \ + '${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')" + BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')" + for url in $BUNDLE_ARTIFACT_URLS; do + echo "Removing $url" + curl -s \ + -H 'Accept: application/json;api-version=6.0-preview' \ + -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \ + -X DELETE "$url" \ + || echo "Failed to remove bundle" + done diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml deleted file mode 100644 index fd8a4d81920..00000000000 --- a/.github/workflows/submit.yml +++ /dev/null @@ -1,2038 +0,0 @@ -name: Pre-submit tests - -on: - push: - branches-ignore: - - master - - pr/* - workflow_dispatch: - inputs: - platforms: - description: "Platform(s) to execute on" - required: true - default: "Linux additional (hotspot only), Linux x64, Linux x86, Windows aarch64, Windows x64, macOS x64, macOS aarch64" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - prerequisites: - name: Prerequisites - runs-on: "ubuntu-20.04" - outputs: - should_run: ${{ steps.check_submit.outputs.should_run }} - bundle_id: ${{ steps.check_bundle_id.outputs.bundle_id }} - jdk_version: ${{ steps.check_jdk_versions.outputs.jdk_version }} - platform_linux_additional: ${{ steps.check_platforms.outputs.platform_linux_additional }} - platform_linux_x64: ${{ steps.check_platforms.outputs.platform_linux_x64 }} - platform_linux_x86: ${{ steps.check_platforms.outputs.platform_linux_x86 }} - platform_windows_aarch64: ${{ steps.check_platforms.outputs.platform_windows_aarch64 }} - platform_windows_x64: ${{ steps.check_platforms.outputs.platform_windows_x64 }} - platform_macos_x64: ${{ steps.check_platforms.outputs.platform_macos_x64 }} - platform_macos_aarch64: ${{ steps.check_platforms.outputs.platform_macos_aarch64 }} - dependencies: ${{ steps.check_deps.outputs.dependencies }} - - steps: - - name: Check if submit tests should actually run depending on secrets and manual triggering - id: check_submit - run: echo "should_run=${{ github.event.inputs.platforms != '' || (!secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/')) }}" >> $GITHUB_OUTPUT - - - name: Check which platforms should be included - id: check_platforms - run: | - echo "platform_linux_additional=${{ contains(github.event.inputs.platforms, 'linux additional (hotspot only)') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux additional (hotspot only)'))) }}" >> $GITHUB_OUTPUT - echo "platform_linux_x64=${{ contains(github.event.inputs.platforms, 'linux x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux x64'))) }}" >> $GITHUB_OUTPUT - echo "platform_linux_x86=${{ contains(github.event.inputs.platforms, 'linux x86') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux x86'))) }}" >> $GITHUB_OUTPUT - echo "platform_windows_x64=${{ contains(github.event.inputs.platforms, 'windows aarch64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'windows aarch64'))) }}" >> $GITHUB_OUTPUT - echo "platform_windows_x64=${{ contains(github.event.inputs.platforms, 'windows x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'windows x64'))) }}" >> $GITHUB_OUTPUT - echo "platform_macos_x64=${{ contains(github.event.inputs.platforms, 'macos x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'macos x64'))) }}" >> $GITHUB_OUTPUT - echo "platform_macos_aarch64=${{ contains(github.event.inputs.platforms, 'macos aarch64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'macos aarch64'))) }}" >> $GITHUB_OUTPUT - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine unique bundle identifier - id: check_bundle_id - run: echo "bundle_id=${GITHUB_ACTOR}_${GITHUB_SHA:0:8}" >> $GITHUB_OUTPUT - if: steps.check_submit.outputs.should_run != 'false' - - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine versions and locations to be used for dependencies - id: check_deps - run: "echo dependencies=`cat make/autoconf/version-numbers make/conf/test-dependencies | sed -e '1i {' -e 's/#.*//g' -e 's/\"//g' -e 's/\\(.*\\)=\\(.*\\)/\"\\1\": \"\\2\",/g' -e '$s/,\\s\\{0,\\}$/\\}/'` >> $GITHUB_OUTPUT" - working-directory: jdk - if: steps.check_submit.outputs.should_run != 'false' - - - name: Print extracted dependencies to the log - run: "echo '${{ steps.check_deps.outputs.dependencies }}'" - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine full JDK versions - id: check_jdk_versions - shell: bash - run: | - FEATURE=${{ fromJson(steps.check_deps.outputs.dependencies).DEFAULT_VERSION_FEATURE }} - INTERIM=${{ fromJson(steps.check_deps.outputs.dependencies).DEFAULT_VERSION_INTERIM }} - UPDATE=${{ fromJson(steps.check_deps.outputs.dependencies).DEFAULT_VERSION_UPDATE }} - PATCH=${{ fromJson(steps.check_deps.outputs.dependencies).DEFAULT_VERSION_PATCH }} - if [ "x${PATCH}" != "x0" ]; then - V=${FEATURE}.${INTERIM}.${UPDATE}.${PATCH} - elif [ "x${UPDATE}" != "x0" ]; then - V=${FEATURE}.${INTERIM}.${UPDATE} - elif [ "x${INTERIM}" != "x0" ]; then - V={FEATURE}.${INTERIM} - else - V=${FEATURE} - fi - echo "jdk_version=${V}" >> $GITHUB_OUTPUT - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine the jtreg ref to checkout - run: "echo JTREG_REF=jtreg-${{ fromJson(steps.check_deps.outputs.dependencies).JTREG_VERSION }}+${{ fromJson(steps.check_deps.outputs.dependencies).JTREG_BUILD }} >> $GITHUB_ENV" - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine the jtreg version to build - run: echo "BUILD_VERSION=${{ fromJson(steps.check_deps.outputs.dependencies).JTREG_VERSION }}" >> $GITHUB_ENV - if: steps.check_submit.outputs.should_run != 'false' - - - name: Determine the jtreg build number to build - run: echo "BUILD_NUMBER=${{ fromJson(steps.check_deps.outputs.dependencies).JTREG_BUILD }}" >> $GITHUB_ENV - if: steps.check_submit.outputs.should_run != 'false' - - - name: Check if a jtreg image is present in the cache - id: jtreg - uses: actions/cache@v3 - with: - path: ~/jtreg/ - key: jtreg-${{ env.JTREG_REF }}-v1 - if: steps.check_submit.outputs.should_run != 'false' - - - name: Checkout the jtreg source - uses: actions/checkout@v3 - with: - repository: "openjdk/jtreg" - ref: ${{ env.JTREG_REF }} - path: jtreg - if: steps.check_submit.outputs.should_run != 'false' && steps.jtreg.outputs.cache-hit != 'true' - - - name: Build jtreg - run: bash make/build.sh --jdk ${JAVA_HOME_8_X64} - working-directory: jtreg - if: steps.check_submit.outputs.should_run != 'false' && steps.jtreg.outputs.cache-hit != 'true' - - - name: Move jtreg image to destination folder - run: mv build/images/jtreg ~/ - working-directory: jtreg - if: steps.check_submit.outputs.should_run != 'false' && steps.jtreg.outputs.cache-hit != 'true' - - - name: Store jtreg for use by later steps - uses: actions/upload-artifact@v3 - with: - name: transient_jtreg_${{ steps.check_bundle_id.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.check_submit.outputs.should_run != 'false' - - linux_x64_build: - name: Linux x64 - runs-on: "ubuntu-20.04" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && (needs.prerequisites.outputs.platform_linux_x64 != 'false' || needs.prerequisites.outputs.platform_linux_additional == 'true') - - strategy: - fail-fast: false - matrix: - flavor: - - build release - - build debug - include: - - flavor: build debug - flags: --enable-debug - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Fix jtreg permissions - run: chmod -R a+rx ${HOME}/jtreg/ - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install gcc-9=9.4.0-1ubuntu1~20.04.1 g++-9=9.4.0-1ubuntu1~20.04.1 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 - - - name: Configure - run: > - bash configure - --with-conf-name=linux-x64 - ${{ matrix.flags }} - --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} - --with-version-build=0 - --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION} - --with-jtreg=${HOME}/jtreg - --with-default-make-target="product-bundles test-bundles" - --with-zlib=system - --with-jvm-features=shenandoahgc - --enable-jtreg-failure-handler - working-directory: jdk - - - name: Build - run: make CONF_NAME=linux-x64 - working-directory: jdk - - - name: Persist test bundles - uses: actions/upload-artifact@v3 - with: - name: transient_jdk-linux-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: | - jdk/build/linux-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin${{ matrix.artifact }}.tar.gz - jdk/build/linux-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin-tests${{ matrix.artifact }}.tar.gz - - linux_x64_test: - name: Linux x64 - runs-on: "ubuntu-20.04" - needs: - - prerequisites - - linux_x64_build - - strategy: - fail-fast: false - matrix: - test: - - jdk/tier1 part 1 - - jdk/tier1 part 2 - - jdk/tier1 part 3 - - langtools/tier1 - - hs/tier1 common - - hs/tier1 compiler - - hs/tier1 gc - - hs/tier1 runtime - - hs/tier1 serviceability - include: - - test: jdk/tier1 part 1 - suites: test/jdk/:tier1_part1 - - test: jdk/tier1 part 2 - suites: test/jdk/:tier1_part2 - - test: jdk/tier1 part 3 - suites: test/jdk/:tier1_part3 - - test: langtools/tier1 - suites: test/langtools/:tier1 - - test: hs/tier1 common - suites: test/hotspot/jtreg/:tier1_common - artifact: -debug - - test: hs/tier1 compiler - suites: test/hotspot/jtreg/:tier1_compiler - artifact: -debug - - test: hs/tier1 gc - suites: test/hotspot/jtreg/:tier1_gc - artifact: -debug - - test: hs/tier1 runtime - suites: test/hotspot/jtreg/:tier1_runtime - artifact: -debug - - test: hs/tier1 serviceability - suites: test/hotspot/jtreg/:tier1_serviceability - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Restore build artifacts - id: build_restore - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x64${{ matrix.artifact }} - continue-on-error: true - - - name: Restore build artifacts (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x64${{ matrix.artifact }} - if: steps.build_restore.outcome == 'failure' - - - name: Unpack jdk - run: | - mkdir -p "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin${{ matrix.artifact }}" - - - name: Unpack tests - run: | - mkdir -p "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin-tests${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin-tests${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin-tests${{ matrix.artifact }}" - - - name: Find root of jdk image dir - run: | - imageroot=`find ${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin${{ matrix.artifact }} -name release -type f` - echo "imageroot=`dirname ${imageroot}`" >> $GITHUB_ENV - - - name: Run tests - id: run_tests - run: > - JDK_IMAGE_DIR=${{ env.imageroot }} - TEST_IMAGE_DIR=${HOME}/jdk-linux-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin-tests${{ matrix.artifact }} - BOOT_JDK=${HOME}/bootjdk/${BOOT_JDK_VERSION} - JT_HOME=${HOME}/jtreg - make run-test-prebuilt - CONF_NAME=run-test-prebuilt - LOG_CMDLINES=true - JTREG_VERBOSE=fail,error,time - TEST="${{ matrix.suites }}" - TEST_OPTS_JAVA_OPTIONS= - JTREG_KEYWORDS="!headful" - JTREG="JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash" - - - name: Generate test failure summary - run: | - # - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - failure_count=$(echo $failures | wc -w || true) - error_count=$(echo $errors | wc -w || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "::error:: Test run reported $failure_count test failure(s) and $error_count error(s). See summary for details." - - echo "### :boom: Test failures summary" >> $GITHUB_STEP_SUMMARY - - if [[ "$failures" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported failure:" >> $GITHUB_STEP_SUMMARY - for test in $failures; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - if [[ "$errors" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported errors:" >> $GITHUB_STEP_SUMMARY - for test in $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - - name: Collect failed test output - run: | - # - # This is a separate step, since if the markdown from a step gets bigger than - # 1024 kB it is skipped, but then the summary above is still generated - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - report_dir=build/run-test-prebuilt/test-support/$test_suite_name - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "### Test output for failed tests" >> $GITHUB_STEP_SUMMARY - for test in $failures $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - base_path="$(echo "$test" | tr '#' '_')" - report_file="$report_dir/$base_path.jtr" - hs_err_files="$report_dir/$base_path/hs_err*.log" - echo "####
$test" - - echo "
View test results" - echo "" - echo '```' - if [[ -f "$report_file" ]]; then - cat "$report_file" - else - echo "Error: Result file $report_file not found" - fi - echo '```' - echo "
" - echo "" - - if [[ "$hs_err_files" != "" ]]; then - echo "
View HotSpot error log" - echo "" - for hs_err in $hs_err_files; do - echo '```' - echo "$hs_err:" - echo "" - cat "$hs_err" - echo '```' - done - - echo "
" - echo "" - fi - - done >> $GITHUB_STEP_SUMMARY - - echo ":arrow_right: To see the entire test log, click the job in the list to the left" >> $GITHUB_STEP_SUMMARY - - # This will abort the entire job in GHA, which is what we want - exit 1 - - - name: Create suitable test log artifact name - if: always() - run: echo "logsuffix=`echo ${{ matrix.test }} | sed -e 's!/!_!'g -e 's! !_!'g`" >> $GITHUB_ENV - - - name: Package test results - if: always() - working-directory: build/run-test-prebuilt/test-results/ - run: > - zip -r9 - "$HOME/linux-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip" - . - continue-on-error: true - - - name: Package test support - if: always() - working-directory: build/run-test-prebuilt/test-support/ - run: > - zip -r9 - "$HOME/linux-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip" - . - -i *.jtr - -i */hs_err*.log - -i */replay*.log - continue-on-error: true - - - name: Persist test results - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/linux-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip - continue-on-error: true - - - name: Persist test outputs - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/linux-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip - continue-on-error: true - - linux_additional_build: - name: Linux additional - runs-on: "ubuntu-20.04" - needs: - - prerequisites - - linux_x64_build - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_linux_additional != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - hs x64 build only - - hs x64 zero build only - - hs x64 minimal build only - - hs x64 optimized build only - - hs aarch64 build only - - hs arm build only - - hs s390x build only - - hs ppc64le build only - include: - - flavor: hs x64 build only - flags: --enable-debug --disable-precompiled-headers - - flavor: hs x64 shenandoah build only - flags: --enable-debug --disable-precompiled-headers --with-jvm-features=shenandoahgc - - flavor: hs x64 zero build only - flags: --enable-debug --disable-precompiled-headers --with-jvm-variants=zero - - flavor: hs x64 minimal build only - flags: --enable-debug --disable-precompiled-headers --with-jvm-variants=minimal - - flavor: hs x64 optimized build only - flags: --with-debug-level=optimized --disable-precompiled-headers - - flavor: hs aarch64 build only - flags: --enable-debug --disable-precompiled-headers - debian-arch: arm64 - gnu-arch: aarch64 - - flavor: hs aarch64 shenandoah build only - flags: --enable-debug --disable-precompiled-headers --with-jvm-features=shenandoahgc - debian-arch: arm64 - gnu-arch: aarch64 - - flavor: hs arm build only - flags: --enable-debug --disable-precompiled-headers - debian-arch: armhf - gnu-arch: arm - gnu-flavor: eabihf - - flavor: hs s390x build only - flags: --enable-debug --disable-precompiled-headers - debian-arch: s390x - gnu-arch: s390x - - flavor: hs ppc64le build only - flags: --enable-debug --disable-precompiled-headers - debian-arch: ppc64el - gnu-arch: powerpc64le - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore build JDK - id: build_restore - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x64_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x64 - continue-on-error: true - - - name: Restore build JDK (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x64_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x64 - if: steps.build_restore.outcome == 'failure' - - - name: Unpack build JDK - run: | - mkdir -p "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin" - tar -xf "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin.tar.gz" -C "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin" - - - name: Find root of build JDK image dir - run: | - build_jdk_root=`find ${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin -name release -type f` - echo "build_jdk_root=`dirname ${build_jdk_root}`" >> $GITHUB_ENV - - - name: Update apt - run: sudo apt-get update - - - name: Install native host dependencies - run: | - sudo apt-get install gcc-9=9.4.0-1ubuntu1~20.04.1 g++-9=9.4.0-1ubuntu1~20.04.1 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 - if: matrix.debian-arch == '' - - - name: Install cross-compilation host dependencies - run: sudo apt-get install gcc-9-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=9.4.0-1ubuntu1~20.04.1cross2 g++-9-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=9.4.0-1ubuntu1~20.04.1cross2 - if: matrix.debian-arch != '' - - - name: Cache sysroot - id: cache-sysroot - uses: actions/cache@v3 - with: - path: ~/sysroot-${{ matrix.debian-arch }}/ - key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('jdk/.github/workflows/submit.yml') }} - if: matrix.debian-arch != '' - - - name: Install sysroot host dependencies - run: sudo apt-get install debootstrap qemu-user-static - if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' - - - name: Create sysroot - run: > - sudo qemu-debootstrap - --arch=${{ matrix.debian-arch }} - --verbose - --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev - --resolve-deps - buster - ~/sysroot-${{ matrix.debian-arch }} - http://httpredir.debian.org/debian/ - if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' - - - name: Prepare sysroot for caching - run: | - sudo chroot ~/sysroot-${{ matrix.debian-arch }} symlinks -cr . - sudo chown ${USER} -R ~/sysroot-${{ matrix.debian-arch }} - rm -rf ~/sysroot-${{ matrix.debian-arch }}/{dev,proc,run,sys} - if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' - - - name: Configure cross compiler - run: | - echo "CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}-gcc-9" >> $GITHUB_ENV - echo "CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}-g++-9" >> $GITHUB_ENV - if: matrix.debian-arch != '' - - - name: Configure cross specific flags - run: > - echo "cross_flags= - --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}} - --with-sysroot=${HOME}/sysroot-${{ matrix.debian-arch }}/ - " >> $GITHUB_ENV - if: matrix.debian-arch != '' - - - name: Configure - run: > - bash configure - --with-conf-name=linux-${{ matrix.gnu-arch }}-hotspot - ${{ matrix.flags }} - ${{ env.cross_flags }} - --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} - --with-version-build=0 - --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION} - --with-build-jdk=${{ env.build_jdk_root }} - --with-default-make-target="hotspot" - --with-zlib=system - working-directory: jdk - - - name: Build - run: make CONF_NAME=linux-${{ matrix.gnu-arch }}-hotspot - working-directory: jdk - - linux_x86_build: - name: Linux x86 - runs-on: "ubuntu-20.04" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_linux_x86 != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - build release - - build debug - include: - - flavor: build debug - flags: --enable-debug - artifact: -debug - - # Reduced 32-bit build uses the same boot JDK as 64-bit build - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Fix jtreg permissions - run: chmod -R a+rx ${HOME}/jtreg/ - - # Roll in the multilib environment and its dependencies. - # Some multilib libraries do not have proper inter-dependencies, so we have to - # install their dependencies manually. Additionally, upgrading apt solves - # the libc6 installation bugs until base image catches up, see JDK-8260460. - - name: Install dependencies - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install --only-upgrade apt - sudo apt-get install gcc-9-multilib g++-9-multilib libfreetype6-dev:i386 libxrandr-dev:i386 libxtst-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386 libcups2-dev:i386 libasound2-dev:i386 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 - - - name: Configure - run: > - bash configure - --with-conf-name=linux-x86 - --with-target-bits=32 - ${{ matrix.flags }} - --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} - --with-version-build=0 - --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION} - --with-jtreg=${HOME}/jtreg - --with-default-make-target="product-bundles test-bundles" - --with-zlib=system - --with-jvm-features=shenandoahgc - --enable-jtreg-failure-handler - working-directory: jdk - - - name: Build - run: make CONF_NAME=linux-x86 - working-directory: jdk - - - name: Persist test bundles - uses: actions/upload-artifact@v3 - with: - name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: | - jdk/build/linux-x86/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}.tar.gz - jdk/build/linux-x86/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}.tar.gz - - linux_x86_test: - name: Linux x86 - runs-on: "ubuntu-20.04" - needs: - - prerequisites - - linux_x86_build - - strategy: - fail-fast: false - matrix: - test: - - jdk/tier1 part 1 - - jdk/tier1 part 2 - - jdk/tier1 part 3 - - langtools/tier1 - - hs/tier1 common - - hs/tier1 compiler - - hs/tier1 gc - - hs/tier1 runtime - - hs/tier1 serviceability - include: - - test: jdk/tier1 part 1 - suites: test/jdk/:tier1_part1 - - test: jdk/tier1 part 2 - suites: test/jdk/:tier1_part2 - - test: jdk/tier1 part 3 - suites: test/jdk/:tier1_part3 - - test: langtools/tier1 - suites: test/langtools/:tier1 - - test: hs/tier1 common - suites: test/hotspot/jtreg/:tier1_common - artifact: -debug - - test: hs/tier1 compiler - suites: test/hotspot/jtreg/:tier1_compiler - artifact: -debug - - test: hs/tier1 gc - suites: test/hotspot/jtreg/:tier1_gc - artifact: -debug - - test: hs/tier1 runtime - suites: test/hotspot/jtreg/:tier1_runtime - artifact: -debug - - test: hs/tier1 serviceability - suites: test/hotspot/jtreg/:tier1_serviceability - artifact: -debug - - # Reduced 32-bit build uses the same boot JDK as 64-bit build - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Restore build artifacts - id: build_restore - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x86${{ matrix.artifact }} - continue-on-error: true - - - name: Restore build artifacts (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-linux-x86${{ matrix.artifact }} - if: steps.build_restore.outcome == 'failure' - - - name: Unpack jdk - run: | - mkdir -p "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}" - - - name: Unpack tests - run: | - mkdir -p "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}" - - - name: Find root of jdk image dir - run: | - imageroot=`find ${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }} -name release -type f` - echo "imageroot=`dirname ${imageroot}`" >> $GITHUB_ENV - - - name: Run tests - id: run_tests - run: > - JDK_IMAGE_DIR=${{ env.imageroot }} - TEST_IMAGE_DIR=${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }} - BOOT_JDK=${HOME}/bootjdk/${BOOT_JDK_VERSION} - JT_HOME=${HOME}/jtreg - make run-test-prebuilt - CONF_NAME=run-test-prebuilt - LOG_CMDLINES=true - JTREG_VERBOSE=fail,error,time - TEST="${{ matrix.suites }}" - TEST_OPTS_JAVA_OPTIONS= - JTREG_KEYWORDS="!headful" - JTREG="JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash" - - - name: Generate test failure summary - run: | - # - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - failure_count=$(echo $failures | wc -w || true) - error_count=$(echo $errors | wc -w || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "::error:: Test run reported $failure_count test failure(s) and $error_count error(s). See summary for details." - - echo "### :boom: Test failures summary" >> $GITHUB_STEP_SUMMARY - - if [[ "$failures" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported failure:" >> $GITHUB_STEP_SUMMARY - for test in $failures; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - if [[ "$errors" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported errors:" >> $GITHUB_STEP_SUMMARY - for test in $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - - name: Collect failed test output - run: | - # - # This is a separate step, since if the markdown from a step gets bigger than - # 1024 kB it is skipped, but then the summary above is still generated - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - report_dir=build/run-test-prebuilt/test-support/$test_suite_name - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "### Test output for failed tests" >> $GITHUB_STEP_SUMMARY - for test in $failures $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - base_path="$(echo "$test" | tr '#' '_')" - report_file="$report_dir/$base_path.jtr" - hs_err_files="$report_dir/$base_path/hs_err*.log" - echo "####
$test" - - echo "
View test results" - echo "" - echo '```' - if [[ -f "$report_file" ]]; then - cat "$report_file" - else - echo "Error: Result file $report_file not found" - fi - echo '```' - echo "
" - echo "" - - if [[ "$hs_err_files" != "" ]]; then - echo "
View HotSpot error log" - echo "" - for hs_err in $hs_err_files; do - echo '```' - echo "$hs_err:" - echo "" - cat "$hs_err" - echo '```' - done - - echo "
" - echo "" - fi - - done >> $GITHUB_STEP_SUMMARY - - echo ":arrow_right: To see the entire test log, click the job in the list to the left" >> $GITHUB_STEP_SUMMARY - - # This will abort the entire job in GHA, which is what we want - exit 1 - - - name: Create suitable test log artifact name - if: always() - run: echo "logsuffix=`echo ${{ matrix.test }} | sed -e 's!/!_!'g -e 's! !_!'g`" >> $GITHUB_ENV - - - name: Package test results - if: always() - working-directory: build/run-test-prebuilt/test-results/ - run: > - zip -r9 - "$HOME/linux-x86${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip" - . - continue-on-error: true - - - name: Package test support - if: always() - working-directory: build/run-test-prebuilt/test-support/ - run: > - zip -r9 - "$HOME/linux-x86${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip" - . - -i *.jtr - -i */hs_err*.log - -i */replay*.log - continue-on-error: true - - - name: Persist test results - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/linux-x86${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip - continue-on-error: true - - - name: Persist test outputs - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/linux-x86${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip - continue-on-error: true - - windows_aarch64_build: - name: Windows aarch64 - runs-on: "windows-2019" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_windows_aarch64 != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - build debug - include: - - flavor: build debug - flags: --enable-debug - artifact: -debug - - env: - JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).DEFAULT_VERSION_FEATURE }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Restore cygwin installer from cache - id: cygwin-installer - uses: actions/cache@v3 - with: - path: ~/cygwin/setup-x86_64.exe - key: cygwin-installer - - - name: Download cygwin installer - run: | - New-Item -Force -ItemType directory -Path "$HOME\cygwin" - & curl -L "https://www.cygwin.com/setup-x86_64.exe" -o "$HOME/cygwin/setup-x86_64.exe" - if: steps.cygwin-installer.outputs.cache-hit != 'true' - - - name: Restore cygwin packages from cache - id: cygwin - uses: actions/cache@v3 - with: - path: ~/cygwin/packages - key: cygwin-packages-${{ runner.os }}-v1 - - - name: Install cygwin - run: | - Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow - - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - & curl -L "$env:BOOT_JDK_URL" -o "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash = Get-FileHash -Algorithm SHA256 "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash.Hash -eq $env:BOOT_JDK_SHA256 - & tar -xf "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" -C "$HOME/bootjdk/$env:BOOT_JDK_VERSION" - Get-ChildItem "$HOME\bootjdk\$env:BOOT_JDK_VERSION\*\*" | Move-Item -Destination "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Ensure a specific version of MSVC is installed - run: > - Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe' -Wait -NoNewWindow -ArgumentList - 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet - --add Microsoft.VisualStudio.Component.VC.14.29.arm64' - - - name: Configure - run: > - $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; - $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; - $env:BOOT_JDK = cygpath "$HOME/bootjdk/$env:BOOT_JDK_VERSION" ; - & bash configure - --with-conf-name=windows-aarch64 - --with-msvc-toolset-version=14.29 - --openjdk-target=aarch64-unknown-cygwin - ${{ matrix.flags }} - --with-version-opt="$env:GITHUB_ACTOR-$env:GITHUB_SHA" - --with-version-build=0 - --with-boot-jdk="$env:BOOT_JDK" - --with-default-make-target="hotspot" - --with-jvm-features=shenandoahgc - working-directory: jdk - - - name: Build - run: | - $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; - $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; - & make CONF_NAME=windows-aarch64 - working-directory: jdk - - windows_x64_build: - name: Windows x64 - runs-on: "windows-2019" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_windows_x64 != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - build release - - build debug - include: - - flavor: build debug - flags: --enable-debug - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Restore cygwin installer from cache - id: cygwin-installer - uses: actions/cache@v3 - with: - path: ~/cygwin/setup-x86_64.exe - key: cygwin-installer - - - name: Download cygwin installer - run: | - New-Item -Force -ItemType directory -Path "$HOME\cygwin" - & curl -L "https://www.cygwin.com/setup-x86_64.exe" -o "$HOME/cygwin/setup-x86_64.exe" - if: steps.cygwin-installer.outputs.cache-hit != 'true' - - - name: Restore cygwin packages from cache - id: cygwin - uses: actions/cache@v3 - with: - path: ~/cygwin/packages - key: cygwin-packages-${{ runner.os }}-v1 - - - name: Install cygwin - run: | - Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow - - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - & curl -L "$env:BOOT_JDK_URL" -o "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash = Get-FileHash -Algorithm SHA256 "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash.Hash -eq $env:BOOT_JDK_SHA256 - & tar -xf "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" -C "$HOME/bootjdk/$env:BOOT_JDK_VERSION" - Get-ChildItem "$HOME\bootjdk\$env:BOOT_JDK_VERSION\*\*" | Move-Item -Destination "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Ensure a specific version of MSVC is installed - run: > - Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe' -Wait -NoNewWindow -ArgumentList - 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet - --add Microsoft.VisualStudio.Component.VC.14.28.x86.x64' - - - name: Configure - run: > - $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; - $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; - $env:BOOT_JDK = cygpath "$HOME/bootjdk/$env:BOOT_JDK_VERSION" ; - $env:JT_HOME = cygpath "$HOME/jtreg" ; - & bash configure - --with-conf-name=windows-x64 - --with-msvc-toolset-version=14.28 - ${{ matrix.flags }} - --with-version-opt="$env:GITHUB_ACTOR-$env:GITHUB_SHA" - --with-version-build=0 - --with-boot-jdk="$env:BOOT_JDK" - --with-jtreg="$env:JT_HOME" - --with-default-make-target="product-bundles test-bundles" - --with-jvm-features=shenandoahgc - --enable-jtreg-failure-handler - working-directory: jdk - - - name: Build - run: | - $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; - $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; - & make CONF_NAME=windows-x64 - working-directory: jdk - - - name: Persist test bundles - uses: actions/upload-artifact@v3 - with: - name: transient_jdk-windows-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: | - jdk/build/windows-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}.zip - jdk/build/windows-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin-tests${{ matrix.artifact }}.tar.gz - jdk/build/windows-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}-symbols.tar.gz - - windows_x64_test: - name: Windows x64 - runs-on: "windows-2019" - needs: - - prerequisites - - windows_x64_build - - strategy: - fail-fast: false - matrix: - test: - - jdk/tier1 part 1 - - jdk/tier1 part 2 - - jdk/tier1 part 3 - - langtools/tier1 - - hs/tier1 common - - hs/tier1 compiler - - hs/tier1 gc - - hs/tier1 runtime - - hs/tier1 serviceability - include: - - test: jdk/tier1 part 1 - suites: test/jdk/:tier1_part1 - - test: jdk/tier1 part 2 - suites: test/jdk/:tier1_part2 - - test: jdk/tier1 part 3 - suites: test/jdk/:tier1_part3 - - test: langtools/tier1 - suites: test/langtools/:tier1 - - test: hs/tier1 common - suites: test/hotspot/jtreg/:tier1_common - artifact: -debug - - test: hs/tier1 compiler - suites: test/hotspot/jtreg/:tier1_compiler - artifact: -debug - - test: hs/tier1 gc - suites: test/hotspot/jtreg/:tier1_gc - artifact: -debug - - test: hs/tier1 runtime - suites: test/hotspot/jtreg/:tier1_runtime - artifact: -debug - - test: hs/tier1 serviceability - suites: test/hotspot/jtreg/:tier1_serviceability - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - & curl -L "$env:BOOT_JDK_URL" -o "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash = Get-FileHash -Algorithm SHA256 "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" - $FileHash.Hash -eq $env:BOOT_JDK_SHA256 - & tar -xf "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" -C "$HOME/bootjdk/$env:BOOT_JDK_VERSION" - Get-ChildItem "$HOME\bootjdk\$env:BOOT_JDK_VERSION\*\*" | Move-Item -Destination "$HOME\bootjdk\$env:BOOT_JDK_VERSION" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore cygwin installer from cache - id: cygwin-installer - uses: actions/cache@v3 - with: - path: ~/cygwin/setup-x86_64.exe - key: cygwin-installer - - - name: Download cygwin installer - run: | - New-Item -Force -ItemType directory -Path "$HOME\cygwin" - & curl -L "https://www.cygwin.com/setup-x86_64.exe" -o "$HOME/cygwin/setup-x86_64.exe" - if: steps.cygwin-installer.outputs.cache-hit != 'true' - - - name: Restore cygwin packages from cache - id: cygwin - uses: actions/cache@v3 - with: - path: ~/cygwin/packages - key: cygwin-packages-${{ runner.os }}-v1 - - - name: Install cygwin - run: | - Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Restore build artifacts - id: build_restore - uses: actions/download-artifact@v3 - with: - name: transient_jdk-windows-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-windows-x64${{ matrix.artifact }} - continue-on-error: true - - - name: Restore build artifacts (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jdk-windows-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-windows-x64${{ matrix.artifact }} - if: steps.build_restore.outcome == 'failure' - - - name: Unpack jdk - run: | - mkdir -p "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}.zip" -C "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}" - - - name: Unpack symbols - run: | - mkdir -p "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}-symbols" - tar -xf "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}-symbols.tar.gz" -C "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }}-symbols" - - - name: Unpack tests - run: | - mkdir -p "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin-tests${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin-tests${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin-tests${{ matrix.artifact }}" - - - name: Find root of jdk image dir - run: echo ("imageroot=" + (Get-ChildItem -Path $HOME/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin${{ matrix.artifact }} -Filter release -Recurse -ErrorAction SilentlyContinue -Force).DirectoryName) | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 - - - name: Run tests - id: run_tests - run: > - $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; - $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; - $env:JDK_IMAGE_DIR = cygpath "${{ env.imageroot }}" ; - $env:SYMBOLS_IMAGE_DIR = cygpath "${{ env.imageroot }}" ; - $env:TEST_IMAGE_DIR = cygpath "$HOME/jdk-windows-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_windows-x64_bin-tests${{ matrix.artifact }}" ; - $env:BOOT_JDK = cygpath "$HOME/bootjdk/$env:BOOT_JDK_VERSION" ; - $env:JT_HOME = cygpath "$HOME/jtreg" ; - & make run-test-prebuilt - CONF_NAME=run-test-prebuilt - LOG_CMDLINES=true - JTREG_VERBOSE=fail,error,time - TEST=${{ matrix.suites }} - TEST_OPTS_JAVA_OPTIONS= - JTREG_KEYWORDS="!headful" - JTREG="JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash" - - - name: Check that all tests executed successfully - if: steps.run_tests.outcome != 'skipped' - run: > - if ((Get-ChildItem -Path build\*\test-results\test-summary.txt -Recurse | Select-String -Pattern "TEST SUCCESS" ).Count -eq 0) { - Get-Content -Path build\*\test-results\*\*\newfailures.txt ; - Get-Content -Path build\*\test-results\*\*\other_errors.txt ; - exit 1 - } - - - name: Create suitable test log artifact name - if: always() - run: echo ("logsuffix=" + ("${{ matrix.test }}" -replace "/", "_" -replace " ", "_")) | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 - - - name: Package test results - if: always() - working-directory: build/run-test-prebuilt/test-results/ - run: > - $env:Path = "$HOME\cygwin\cygwin64\bin;$env:Path" ; - zip -r9 - "$HOME/windows-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip" - . - continue-on-error: true - - - name: Package test support - if: always() - working-directory: build/run-test-prebuilt/test-support/ - run: > - $env:Path = "$HOME\cygwin\cygwin64\bin;$env:Path" ; - zip -r9 - "$HOME/windows-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip" - . - -i *.jtr - -i */hs_err*.log - -i */replay*.log - continue-on-error: true - - - name: Persist test results - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/windows-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip - continue-on-error: true - - - name: Persist test outputs - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/windows-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip - continue-on-error: true - - macos_x64_build: - name: macOS x64 - runs-on: "macos-11" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_macos_x64 != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - build release - - build debug - include: - - flavor: build release - - flavor: build debug - flags: --enable-debug - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p ${HOME}/bootjdk/${BOOT_JDK_VERSION} || true - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | shasum -a 256 -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Fix jtreg permissions - run: chmod -R a+rx ${HOME}/jtreg/ - - - name: Install dependencies - run: brew install make - - - name: Select Xcode version - run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer - - - name: Configure - run: > - bash configure - --with-conf-name=macos-x64 - ${{ matrix.flags }} - --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} - --with-version-build=0 - --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION}/Contents/Home - --with-jtreg=${HOME}/jtreg - --with-default-make-target="product-bundles test-bundles" - --with-zlib=system - --with-jvm-features=shenandoahgc - --enable-jtreg-failure-handler - working-directory: jdk - - - name: Build - run: make CONF_NAME=macos-x64 - working-directory: jdk - - - name: Persist test bundles - uses: actions/upload-artifact@v3 - with: - name: transient_jdk-macos-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: | - jdk/build/macos-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin${{ matrix.artifact }}.tar.gz - jdk/build/macos-x64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin-tests${{ matrix.artifact }}.tar.gz - - macos_aarch64_build: - name: macOS aarch64 - runs-on: "macos-11" - needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_macos_aarch64 != 'false' - - strategy: - fail-fast: false - matrix: - flavor: - - build release - - build debug - include: - - flavor: build release - - flavor: build debug - flags: --enable-debug - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - with: - path: jdk - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p ${HOME}/bootjdk/${BOOT_JDK_VERSION} || true - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | shasum -a 256 -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Fix jtreg permissions - run: chmod -R a+rx ${HOME}/jtreg/ - - - name: Install dependencies - run: brew install make - - - name: Select Xcode version - run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer - - - name: Configure - run: > - bash configure - --with-conf-name=macos-aarch64 - --openjdk-target=aarch64-apple-darwin - ${{ matrix.flags }} - --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} - --with-version-build=0 - --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION}/Contents/Home - --with-jtreg=${HOME}/jtreg - --with-default-make-target="product-bundles test-bundles" - --with-zlib=system - --with-jvm-features=shenandoahgc - --enable-jtreg-failure-handler - working-directory: jdk - - - name: Build - run: make CONF_NAME=macos-aarch64 - working-directory: jdk - - - name: Persist test bundles - uses: actions/upload-artifact@v3 - with: - name: transient_jdk-macos-aarch64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: | - jdk/build/macos-aarch64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_macos-aarch64_bin${{ matrix.artifact }}.tar.gz - jdk/build/macos-aarch64/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_macos-aarch64_bin-tests${{ matrix.artifact }}.tar.gz - - - macos_x64_test: - name: macOS x64 - runs-on: "macos-11" - needs: - - prerequisites - - macos_x64_build - - strategy: - fail-fast: false - matrix: - test: - - jdk/tier1 part 1 - - jdk/tier1 part 2 - - jdk/tier1 part 3 - - langtools/tier1 - - hs/tier1 common - - hs/tier1 compiler - - hs/tier1 gc - - hs/tier1 runtime - - hs/tier1 serviceability - include: - - test: jdk/tier1 part 1 - suites: test/jdk/:tier1_part1 - - test: jdk/tier1 part 2 - suites: test/jdk/:tier1_part2 - - test: jdk/tier1 part 3 - suites: test/jdk/:tier1_part3 - - test: langtools/tier1 - suites: test/langtools/:tier1 - - test: hs/tier1 common - suites: test/hotspot/jtreg/:tier1_common - artifact: -debug - - test: hs/tier1 compiler - suites: test/hotspot/jtreg/:tier1_compiler - artifact: -debug - - test: hs/tier1 gc - suites: test/hotspot/jtreg/:tier1_gc - artifact: -debug - - test: hs/tier1 runtime - suites: test/hotspot/jtreg/:tier1_runtime - artifact: -debug - - test: hs/tier1 serviceability - suites: test/hotspot/jtreg/:tier1_serviceability - artifact: -debug - - env: - JDK_VERSION: "${{ needs.prerequisites.outputs.jdk_version }}" - BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" - BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_FILENAME }}" - BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_URL }}" - BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).MACOS_X64_BOOT_JDK_SHA256 }}" - - steps: - - name: Checkout the source - uses: actions/checkout@v3 - - - name: Restore boot JDK from cache - id: bootjdk - uses: actions/cache@v3 - with: - path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} - key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 - - - name: Download boot JDK - run: | - mkdir -p ${HOME}/bootjdk/${BOOT_JDK_VERSION} || true - wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" - echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | shasum -a 256 -c >/dev/null - - tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" - mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" - if: steps.bootjdk.outputs.cache-hit != 'true' - - - name: Restore jtreg artifact - id: jtreg_restore - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - continue-on-error: true - - - name: Restore jtreg artifact (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jtreg/ - if: steps.jtreg_restore.outcome == 'failure' - - - name: Restore build artifacts - id: build_restore - uses: actions/download-artifact@v3 - with: - name: transient_jdk-macos-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-macos-x64${{ matrix.artifact }} - continue-on-error: true - - - name: Restore build artifacts (retry) - uses: actions/download-artifact@v3 - with: - name: transient_jdk-macos-x64${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} - path: ~/jdk-macos-x64${{ matrix.artifact }} - if: steps.build_restore.outcome == 'failure' - - - name: Unpack jdk - run: | - mkdir -p "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin${{ matrix.artifact }}" - - - name: Unpack tests - run: | - mkdir -p "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin-tests${{ matrix.artifact }}" - tar -xf "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin-tests${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin-tests${{ matrix.artifact }}" - - - name: Install dependencies - run: brew install make - - - name: Select Xcode version - run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer - - - name: Find root of jdk image dir - run: | - imageroot=`find ${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin${{ matrix.artifact }} -name release -type f` - echo "imageroot=`dirname ${imageroot}`" >> $GITHUB_ENV - - - name: Run tests - id: run_tests - run: > - JDK_IMAGE_DIR=${{ env.imageroot }} - TEST_IMAGE_DIR=${HOME}/jdk-macos-x64${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_macos-x64_bin-tests${{ matrix.artifact }} - BOOT_JDK=${HOME}/bootjdk/${BOOT_JDK_VERSION}/Contents/Home - JT_HOME=${HOME}/jtreg - gmake run-test-prebuilt - CONF_NAME=run-test-prebuilt - LOG_CMDLINES=true - JTREG_VERBOSE=fail,error,time - TEST=${{ matrix.suites }} - TEST_OPTS_JAVA_OPTIONS= - JTREG_KEYWORDS="!headful" - JTREG="JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash" - - - name: Generate test failure summary - run: | - # - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - failure_count=$(echo $failures | wc -w || true) - error_count=$(echo $errors | wc -w || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "::error:: Test run reported $failure_count test failure(s) and $error_count error(s). See summary for details." - - echo "### :boom: Test failures summary" >> $GITHUB_STEP_SUMMARY - - if [[ "$failures" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported failure:" >> $GITHUB_STEP_SUMMARY - for test in $failures; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - if [[ "$errors" != "" ]]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "These tests reported errors:" >> $GITHUB_STEP_SUMMARY - for test in $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - echo "* [$test](#user-content-$anchor)" - done >> $GITHUB_STEP_SUMMARY - fi - - - name: Collect failed test output - run: | - # - # This is a separate step, since if the markdown from a step gets bigger than - # 1024 kB it is skipped, but then the summary above is still generated - test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) - results_dir=build/run-test-prebuilt/test-results/$test_suite_name/text - report_dir=build/run-test-prebuilt/test-support/$test_suite_name - - failures=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/newfailures.txt || true) - errors=$(sed -e 's!\(.*\)\.java!\1!' -e '/^#/d' $results_dir/other_errors.txt || true) - - if [[ "$failures" = "" && "$errors" = "" ]]; then - # If we have nothing to report, exit this step now - exit 0 - fi - - echo "### Test output for failed tests" >> $GITHUB_STEP_SUMMARY - for test in $failures $errors; do - anchor="$(echo "$test" | tr [A-Z/] [a-z_])" - base_path="$(echo "$test" | tr '#' '_')" - report_file="$report_dir/$base_path.jtr" - hs_err_files="$report_dir/$base_path/hs_err*.log" - echo "####
$test" - - echo "
View test results" - echo "" - echo '```' - if [[ -f "$report_file" ]]; then - cat "$report_file" - else - echo "Error: Result file $report_file not found" - fi - echo '```' - echo "
" - echo "" - - if [[ "$hs_err_files" != "" ]]; then - echo "
View HotSpot error log" - echo "" - for hs_err in $hs_err_files; do - echo '```' - echo "$hs_err:" - echo "" - cat "$hs_err" - echo '```' - done - - echo "
" - echo "" - fi - - done >> $GITHUB_STEP_SUMMARY - - echo ":arrow_right: To see the entire test log, click the job in the list to the left" >> $GITHUB_STEP_SUMMARY - - # This will abort the entire job in GHA, which is what we want - exit 1 - - - name: Create suitable test log artifact name - if: always() - run: echo "logsuffix=`echo ${{ matrix.test }} | sed -e 's!/!_!'g -e 's! !_!'g`" >> $GITHUB_ENV - - - name: Package test results - if: always() - working-directory: build/run-test-prebuilt/test-results/ - run: > - zip -r9 - "$HOME/macos-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip" - . - continue-on-error: true - - - name: Package test support - if: always() - working-directory: build/run-test-prebuilt/test-support/ - run: > - zip -r9 - "$HOME/macos-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip" - . - -i *.jtr - -i */hs_err*.log - -i */replay*.log - continue-on-error: true - - - name: Persist test results - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/macos-x64${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip - continue-on-error: true - - - name: Persist test outputs - if: always() - uses: actions/upload-artifact@v3 - with: - path: ~/macos-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip - continue-on-error: true - - artifacts: - name: Post-process artifacts - runs-on: "ubuntu-20.04" - if: always() - continue-on-error: true - needs: - - prerequisites - - linux_additional_build - - windows_aarch64_build - - linux_x64_test - - linux_x86_test - - windows_x64_test - - macos_x64_test - - macos_aarch64_build - - steps: - - name: Determine current artifacts endpoint - id: actions_runtime - uses: actions/github-script@v6 - with: - script: "return { url: process.env['ACTIONS_RUNTIME_URL'], token: process.env['ACTIONS_RUNTIME_TOKEN'] }" - - - name: Display current artifacts - run: > - curl -s -H 'Accept: application/json;api-version=6.0-preview' - -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}' - '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' - - - name: Delete transient artifacts - run: > - for url in ` - curl -s -H 'Accept: application/json;api-version=6.0-preview' - -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}' - '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' | - jq -r -c '.value | map(select(.name|startswith("transient_"))) | .[].url'`; do - curl -s -H 'Accept: application/json;api-version=6.0-preview' - -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}' - -X DELETE "${url}"; - done - - - name: Fetch remaining artifacts (test results) - uses: actions/download-artifact@v3 - with: - path: test-results - - - name: Delete remaining artifacts - run: > - for url in ` - curl -s -H 'Accept: application/json;api-version=6.0-preview' - -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}' - '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' | - jq -r -c '.value | .[].url'`; do - curl -s -H 'Accept: application/json;api-version=6.0-preview' - -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}' - -X DELETE "${url}"; - done - - - name: Upload a combined test results artifact - uses: actions/upload-artifact@v3 - with: - name: test-results_${{ needs.prerequisites.outputs.bundle_id }} - path: test-results diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..7ac6708f9e0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,205 @@ +# +# 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. 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. +# + +name: 'Run tests' + +on: + workflow_call: + inputs: + platform: + required: true + type: string + bootjdk-platform: + required: true + type: string + runs-on: + required: true + type: string + +env: + # These are needed to make the MSYS2 bash work properly + MSYS2_PATH_TYPE: minimal + CHERE_INVOKING: 1 + +jobs: + test: + name: test + runs-on: ${{ inputs.runs-on }} + defaults: + run: + shell: bash + + strategy: + fail-fast: false + matrix: + test-name: + - 'jdk/tier1 part 1' + - 'jdk/tier1 part 2' + - 'jdk/tier1 part 3' + - 'langtools/tier1' + - 'hs/tier1 common' + - 'hs/tier1 compiler' + - 'hs/tier1 gc' + - 'hs/tier1 runtime' + - 'hs/tier1 serviceability' + + include: + - test-name: 'jdk/tier1 part 1' + test-suite: 'test/jdk/:tier1_part1' + + - test-name: 'jdk/tier1 part 2' + test-suite: 'test/jdk/:tier1_part2' + + - test-name: 'jdk/tier1 part 3' + test-suite: 'test/jdk/:tier1_part3' + + - test-name: 'langtools/tier1' + test-suite: 'test/langtools/:tier1' + + - test-name: 'hs/tier1 common' + test-suite: 'test/hotspot/jtreg/:tier1_common' + debug-suffix: -debug + + - test-name: 'hs/tier1 compiler' + test-suite: 'test/hotspot/jtreg/:tier1_compiler' + debug-suffix: -debug + + - test-name: 'hs/tier1 gc' + test-suite: 'test/hotspot/jtreg/:tier1_gc' + debug-suffix: -debug + + - test-name: 'hs/tier1 runtime' + test-suite: 'test/hotspot/jtreg/:tier1_runtime' + debug-suffix: -debug + + - test-name: 'hs/tier1 serviceability' + test-suite: 'test/hotspot/jtreg/:tier1_serviceability' + debug-suffix: -debug + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Get MSYS2' + uses: ./.github/actions/get-msys2 + if: runner.os == 'Windows' + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: ${{ inputs.bootjdk-platform }} + + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Get bundles' + id: bundles + uses: ./.github/actions/get-bundles + with: + platform: ${{ inputs.platform }} + debug-suffix: ${{ matrix.debug-suffix }} + + - name: 'Install dependencies' + run: | + # On macOS we need to install some dependencies for testing + brew install make + sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer + # This will make GNU make available as 'make' and not only as 'gmake' + echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH + if: runner.os == 'macOS' + + - name: 'Set PATH' + id: path + run: | + # We need a minimal PATH on Windows + # Set PATH to "", so just GITHUB_PATH is included + if [[ '${{ runner.os }}' == 'Windows' ]]; then + echo "value=" >> $GITHUB_OUTPUT + else + echo "value=$PATH" >> $GITHUB_OUTPUT + fi + + - name: 'Run tests' + id: run-tests + run: > + make run-test-prebuilt + TEST='${{ matrix.test-suite }}' + BOOT_JDK=${{ steps.bootjdk.outputs.path }} + JT_HOME=${{ steps.jtreg.outputs.path }} + JDK_IMAGE_DIR=${{ steps.bundles.outputs.jdk-path }} + SYMBOLS_IMAGE_DIR=${{ steps.bundles.outputs.symbols-path }} + TEST_IMAGE_DIR=${{ steps.bundles.outputs.tests-path }} + JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful' + && bash ./.github/scripts/gen-test-summary.sh "$GITHUB_STEP_SUMMARY" "$GITHUB_OUTPUT" + env: + PATH: ${{ steps.path.outputs.value }} + + # This is a separate step, since if the markdown from a step gets bigger than + # 1024 kB it is skipped, but then the short summary above is still generated + - name: 'Generate test report' + run: bash ./.github/scripts/gen-test-results.sh "$GITHUB_STEP_SUMMARY" + if: always() + + - name: 'Package test results' + id: package + run: | + # Package test-results and relevant parts of test-support + mkdir results + + if [[ -d build/run-test-prebuilt/test-results ]]; then + cd build/run-test-prebuilt/test-results/ + zip -r -9 "$GITHUB_WORKSPACE/results/test-results.zip" . + cd $GITHUB_WORKSPACE + else + echo '::warning ::Missing test-results directory' + fi + + if [[ -d build/run-test-prebuilt/test-support ]]; then + cd build/run-test-prebuilt/test-support/ + zip -r -9 "$GITHUB_WORKSPACE/results/test-support.zip" . -i *.jtr -i */hs_err*.log -i */replay*.log + cd $GITHUB_WORKSPACE + else + echo '::warning ::Missing test-support directory' + fi + + artifact_name="results-${{ inputs.platform }}-$(echo ${{ matrix.test-name }} | tr '/ ' '__')" + echo "artifact-name=$artifact_name" >> $GITHUB_OUTPUT + if: always() + + - name: 'Upload test results' + uses: actions/upload-artifact@v3 + with: + path: results + name: ${{ steps.package.outputs.artifact-name }} + if: always() + + # 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 + with: + script: core.setFailed('${{ steps.run-tests.outputs.error-message }}') + if: steps.run-tests.outputs.failure == 'true' diff --git a/make/conf/test-dependencies b/make/conf/github-actions.conf similarity index 85% rename from make/conf/test-dependencies rename to make/conf/github-actions.conf index 0b6c9130dc6..04d6e54ddc5 100644 --- a/make/conf/test-dependencies +++ b/make/conf/github-actions.conf @@ -23,21 +23,19 @@ # questions. # -# Versions and download locations for dependencies used by pre-submit testing. +# Versions and download locations for dependencies used by GitHub Actions (GHA) -BOOT_JDK_VERSION=11 -JTREG_VERSION=6 -JTREG_BUILD=1 GTEST_VERSION=1.8.1 +JTREG_VERSION=6.1+2 -LINUX_X64_BOOT_JDK_FILENAME=openjdk-11.0.14.1_linux-x64_bin.tar.gz +LINUX_X64_BOOT_JDK_EXT=tar.gz LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz LINUX_X64_BOOT_JDK_SHA256=43fb84f8063ad9bf6b6d694a67b8f64c8827552b920ec5ce794dfe5602edffe7 -WINDOWS_X64_BOOT_JDK_FILENAME=openjdk-11.0.14.1_windows-x64_bin.zip +WINDOWS_X64_BOOT_JDK_EXT=zip WINDOWS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_windows_hotspot_11.0.14.1_1.zip WINDOWS_X64_BOOT_JDK_SHA256=3e7da701aa92e441418299714f0ed6db10c3bb1e2db625c35a2c2cd9cc619731 -MACOS_X64_BOOT_JDK_FILENAME=openjdk-11.0.14.1_osx-x64_bin.tar.gz +MACOS_X64_BOOT_JDK_EXT=tar.gz MACOS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.14.1_1.tar.gz MACOS_X64_BOOT_JDK_SHA256=8c69808f5d9d209b195575e979de0e43cdf5d0f1acec1853a569601fe2c1f743 From 3990eb250749d136f9dbe598fb38b5e9754d9c11 Mon Sep 17 00:00:00 2001 From: Autumn Capasso Date: Mon, 19 Dec 2022 21:50:51 +0000 Subject: [PATCH 013/205] 8256110: Create implementation for NSAccessibilityStepper protocol Backport-of: 5dc5d9401e7a176da53a14293fb59e97b644b31a --- .../awt/a11y/ButtonAccessibility.m | 16 +----- .../awt/a11y/CommonComponentAccessibility.h | 1 + .../awt/a11y/CommonComponentAccessibility.m | 21 ++++++- .../awt/a11y/SpinboxAccessibility.h | 39 +++++++++++++ .../awt/a11y/SpinboxAccessibility.m | 56 +++++++++++++++++++ 5 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ButtonAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ButtonAccessibility.m index 9b0e703f03c..3c4a896b7a8 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ButtonAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ButtonAccessibility.m @@ -24,10 +24,6 @@ */ #import "ButtonAccessibility.h" -#import "JNIUtilities.h" -#import "ThreadUtilities.h" - -static jclass sjc_CAccessibility = NULL; /* * Implementation of the accessibility peer for the pushbutton role @@ -40,17 +36,7 @@ - (nullable NSString *)accessibilityLabel - (BOOL)accessibilityPerformPress { - AWT_ASSERT_APPKIT_THREAD; - JNIEnv* env = [ThreadUtilities getJNIEnv]; - - GET_CACCESSIBILITY_CLASS_RETURN(FALSE); - DECLARE_STATIC_METHOD_RETURN(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction", - "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V", FALSE); - (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction, - [self axContextWithEnv:(env)], 0, fComponent); - CHECK_EXCEPTION(); - - return TRUE; + return [self performAccessibleAction:0]; } @end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h index d4cb2751ae0..adce4f5e38a 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h @@ -36,6 +36,7 @@ + (JavaComponentAccessibility * _Nullable) getComponentAccessibility:(NSString * _Nonnull)role; - (NSRect)accessibilityFrame; - (nullable id)accessibilityParent; +- (BOOL)performAccessibleAction:(int)index; @end #endif diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 9fa49731e62..e867aea0a72 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -46,11 +46,13 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:3]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:4]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"]; + [rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"]; + } /* @@ -60,7 +62,6 @@ + (void) initializeRolesMap { + (JavaComponentAccessibility *) getComponentAccessibility:(NSString *)role { AWT_ASSERT_APPKIT_THREAD; - if (rolesMap == nil) { [self initializeRolesMap]; } @@ -97,4 +98,20 @@ - (nullable id)accessibilityParent return [self accessibilityParentAttribute]; } +// AccessibleAction support +- (BOOL)performAccessibleAction:(int)index +{ + AWT_ASSERT_APPKIT_THREAD; + JNIEnv* env = [ThreadUtilities getJNIEnv]; + + GET_CACCESSIBILITY_CLASS_RETURN(FALSE); + DECLARE_STATIC_METHOD_RETURN(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction", + "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V", FALSE); + (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction, + [self axContextWithEnv:(env)], index, fComponent); + CHECK_EXCEPTION(); + + return TRUE; +} + @end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.h new file mode 100644 index 00000000000..9476a7ed83a --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "JavaComponentAccessibility.h" +#import "CommonComponentAccessibility.h" + +#import + +@interface SpinboxAccessibility : CommonComponentAccessibility { + +}; + +- (nullable NSString *)accessibilityLabel; +- (nullable id)accessibilityValue; +- (BOOL)accessibilityPerformDecrement; +- (BOOL)accessibilityPerformIncrement; +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.m new file mode 100644 index 00000000000..49e9e8cde30 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/SpinboxAccessibility.m @@ -0,0 +1,56 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "SpinboxAccessibility.h" + +#define INCREMENT 0 +#define DECREMENT 1 + +/* + * Implementation of the accessibility peer for the spinner role + */ +@implementation SpinboxAccessibility +- (nullable NSString *)accessibilityLabel +{ + return [self accessibilityTitleAttribute]; +} + +- (nullable id)accessibilityValue +{ + return [self accessibilityValueAttribute]; +} + +- (BOOL)accessibilityPerformIncrement +{ + return [self performAccessibleAction:INCREMENT]; +} + + +- (BOOL)accessibilityPerformDecrement +{ + return [self performAccessibleAction:DECREMENT]; +} + +@end From 1acc508f2ec2c575be683557ce08c19699d73830 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 20 Dec 2022 01:07:05 +0000 Subject: [PATCH 014/205] 8274939: Incorrect size of the pixel storage is used by the robot on macOS Reviewed-by: clanger Backport-of: eff5dafba9f72bd0612357712ffa472ce1c9166a --- .../macosx/classes/sun/lwawt/macosx/CRobot.java | 8 ++++---- src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m | 7 ++++++- .../awt/Robot/CheckCommonColors/CheckCommonColors.java | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java index ae28ebf4aca..4c39d2bed56 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -169,9 +169,9 @@ public void keyRelease(final int keycode) { */ @Override public int getRGBPixel(int x, int y) { - int c[] = new int[1]; - double scale = fDevice.getScaleFactor(); - getScreenPixels(new Rectangle(x, y, (int) scale, (int) scale), c); + int scale = fDevice.getScaleFactor(); + int[] c = new int[scale * scale]; + getScreenPixels(new Rectangle(x, y, scale, scale), c); return c[0]; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m index 9d90086677d..55df129960f 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -321,6 +321,11 @@ static inline void autoDelay(BOOL isMove) { jint picY = y; jint picWidth = width; jint picHeight = height; + jsize size = (*env)->GetArrayLength(env, pixels); + if (size < (long) picWidth * picHeight || picWidth < 0 || picHeight < 0) { + JNU_ThrowInternalError(env, "Invalid arguments to get screen pixels"); + return; + } CGRect screenRect = CGRectMake(picX / scale, picY / scale, picWidth / scale, picHeight / scale); diff --git a/test/jdk/java/awt/Robot/CheckCommonColors/CheckCommonColors.java b/test/jdk/java/awt/Robot/CheckCommonColors/CheckCommonColors.java index 57419b0ac5a..55d9b4358af 100644 --- a/test/jdk/java/awt/Robot/CheckCommonColors/CheckCommonColors.java +++ b/test/jdk/java/awt/Robot/CheckCommonColors/CheckCommonColors.java @@ -42,6 +42,8 @@ * @key headful * @bug 8215105 8211999 * @summary tests that Robot can capture the common colors without artifacts + * @run main/othervm CheckCommonColors + * @run main/othervm -Xcheck:jni CheckCommonColors */ public final class CheckCommonColors { From dba30227215ba29e0d469bd1938f186993f9d64e Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 20 Dec 2022 08:53:38 +0000 Subject: [PATCH 015/205] 8238936: The crash in XRobotPeer when the custom GraphicsDevice is used Backport-of: 9d0a4875d75421e416747271e3f229d068cf0dd0 --- .../classes/sun/lwawt/macosx/CRobot.java | 3 +- .../classes/sun/lwawt/macosx/LWCToolkit.java | 11 +- .../share/classes/java/awt/Robot.java | 2 +- .../classes/sun/awt/ComponentFactory.java | 70 ++++++++- .../unix/classes/sun/awt/X11/XRobotPeer.java | 18 +-- .../unix/classes/sun/awt/X11/XToolkit.java | 11 +- .../classes/sun/awt/windows/WRobotPeer.java | 6 +- .../classes/sun/awt/windows/WToolkit.java | 136 +++++++++++++----- .../CreateRobotCustomGC.java | 66 +++++++++ 9 files changed, 251 insertions(+), 72 deletions(-) create mode 100644 test/jdk/java/awt/Robot/CreateRobotCustomGC/CreateRobotCustomGC.java diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java index 4c39d2bed56..c764ae2162b 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java @@ -27,7 +27,6 @@ import java.awt.Point; import java.awt.Rectangle; -import java.awt.Robot; import java.awt.peer.RobotPeer; import sun.awt.CGraphicsDevice; @@ -49,7 +48,7 @@ final class CRobot implements RobotPeer { * Uses the given GraphicsDevice as the coordinate system for subsequent * coordinate calls. */ - public CRobot(Robot r, CGraphicsDevice d) { + CRobot(CGraphicsDevice d) { fDevice = d; initRobot(); } diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index c0af4562616..3446f0db2b4 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -26,6 +26,7 @@ package sun.lwawt.macosx; import java.awt.AWTError; +import java.awt.AWTException; import java.awt.CheckboxMenuItem; import java.awt.Color; import java.awt.Component; @@ -49,7 +50,6 @@ import java.awt.Point; import java.awt.PopupMenu; import java.awt.RenderingHints; -import java.awt.Robot; import java.awt.SystemTray; import java.awt.Taskbar; import java.awt.Toolkit; @@ -499,8 +499,11 @@ public void sync() { } @Override - public RobotPeer createRobot(Robot target, GraphicsDevice screen) { - return new CRobot(target, (CGraphicsDevice)screen); + public RobotPeer createRobot(GraphicsDevice screen) throws AWTException { + if (screen instanceof CGraphicsDevice) { + return new CRobot((CGraphicsDevice) screen); + } + return super.createRobot(screen); } private native boolean isCapsLockOn(); diff --git a/src/java.desktop/share/classes/java/awt/Robot.java b/src/java.desktop/share/classes/java/awt/Robot.java index 7f4b8608a5c..e801639358c 100644 --- a/src/java.desktop/share/classes/java/awt/Robot.java +++ b/src/java.desktop/share/classes/java/awt/Robot.java @@ -136,7 +136,7 @@ private void init(GraphicsDevice screen) throws AWTException { checkRobotAllowed(); Toolkit toolkit = Toolkit.getDefaultToolkit(); if (toolkit instanceof ComponentFactory) { - peer = ((ComponentFactory)toolkit).createRobot(this, screen); + peer = ((ComponentFactory)toolkit).createRobot(screen); } initLegalButtonMask(); } diff --git a/src/java.desktop/share/classes/sun/awt/ComponentFactory.java b/src/java.desktop/share/classes/sun/awt/ComponentFactory.java index b2e8af875ec..12664d88f97 100644 --- a/src/java.desktop/share/classes/sun/awt/ComponentFactory.java +++ b/src/java.desktop/share/classes/sun/awt/ComponentFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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,12 +25,60 @@ package sun.awt; -import java.awt.peer.TaskbarPeer; -import java.awt.*; +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.Component; +import java.awt.Desktop; +import java.awt.Dialog; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.HeadlessException; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.Taskbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Window; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.peer.*; +import java.awt.peer.ButtonPeer; +import java.awt.peer.CanvasPeer; +import java.awt.peer.CheckboxMenuItemPeer; +import java.awt.peer.CheckboxPeer; +import java.awt.peer.ChoicePeer; +import java.awt.peer.DesktopPeer; +import java.awt.peer.DialogPeer; +import java.awt.peer.FileDialogPeer; +import java.awt.peer.FontPeer; +import java.awt.peer.FramePeer; +import java.awt.peer.LabelPeer; +import java.awt.peer.LightweightPeer; +import java.awt.peer.ListPeer; +import java.awt.peer.MenuBarPeer; +import java.awt.peer.MenuItemPeer; +import java.awt.peer.MenuPeer; +import java.awt.peer.MouseInfoPeer; +import java.awt.peer.PanelPeer; +import java.awt.peer.PopupMenuPeer; +import java.awt.peer.RobotPeer; +import java.awt.peer.ScrollPanePeer; +import java.awt.peer.ScrollbarPeer; +import java.awt.peer.TaskbarPeer; +import java.awt.peer.TextAreaPeer; +import java.awt.peer.TextFieldPeer; +import java.awt.peer.WindowPeer; import sun.awt.datatransfer.DataTransferer; @@ -437,9 +485,17 @@ default FontPeer getFontPeer(String name, int style) { return null; } - default RobotPeer createRobot(Robot target, GraphicsDevice screen) - throws AWTException { - throw new HeadlessException(); + /** + * Creates the peer for a Robot. + * + * @param screen the GraphicsDevice indicating the coordinate system the + * Robot will operate in + * @return the peer created + * @throws AWTException if the platform configuration does not allow + * low-level input control + */ + default RobotPeer createRobot(GraphicsDevice screen) throws AWTException { + throw new AWTException(String.format("Unsupported device: %s", screen)); } default DataTransferer getDataTransferer() { diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java index ef9589aa0b4..4834fb3bc43 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java +++ b/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,7 +25,6 @@ package sun.awt.X11; -import java.awt.GraphicsConfiguration; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.peer.RobotPeer; @@ -35,11 +34,12 @@ import sun.awt.SunToolkit; import sun.awt.UNIXToolkit; import sun.awt.X11GraphicsConfig; +import sun.awt.X11GraphicsDevice; import sun.security.action.GetPropertyAction; final class XRobotPeer implements RobotPeer { - static final boolean tryGtk; + private static final boolean tryGtk; static { loadNativeLibraries(); tryGtk = Boolean.parseBoolean( @@ -48,16 +48,10 @@ final class XRobotPeer implements RobotPeer { )); } private static volatile boolean useGtk; - private X11GraphicsConfig xgc = null; + private final X11GraphicsConfig xgc; - /* - * native implementation uses some static shared data (pipes, processes) - * so use a class lock to synchronize native method calls - */ - static Object robotLock = new Object(); - - XRobotPeer(GraphicsConfiguration gc) { - this.xgc = (X11GraphicsConfig)gc; + XRobotPeer(X11GraphicsDevice gd) { + xgc = (X11GraphicsConfig) gd.getDefaultConfiguration(); SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks()); diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java index eafabd47130..330827c939d 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java +++ b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -58,7 +58,6 @@ import java.awt.PopupMenu; import java.awt.PrintJob; import java.awt.Rectangle; -import java.awt.Robot; import java.awt.ScrollPane; import java.awt.Scrollbar; import java.awt.SystemColor; @@ -1069,11 +1068,13 @@ protected static void targetDisposedPeer(Object target, Object peer) { } @Override - public RobotPeer createRobot(Robot target, GraphicsDevice screen) { - return new XRobotPeer(screen.getDefaultConfiguration()); + public RobotPeer createRobot(GraphicsDevice screen) throws AWTException { + if (screen instanceof X11GraphicsDevice) { + return new XRobotPeer((X11GraphicsDevice) screen); + } + return super.createRobot(screen); } - /* * On X, support for dynamic layout on resizing is governed by the * window manager. If the window manager supports it, it happens diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WRobotPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WRobotPeer.java index 1f4cedf6775..c30b4ee3a08 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WRobotPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WRobotPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, 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 @@ -25,7 +25,6 @@ package sun.awt.windows; -import java.awt.GraphicsDevice; import java.awt.Point; import java.awt.Rectangle; import java.awt.peer.RobotPeer; @@ -34,9 +33,6 @@ final class WRobotPeer implements RobotPeer { - WRobotPeer(GraphicsDevice screen) { - } - public native void mouseMoveImpl(int x, int y); @Override public void mouseMove(int x, int y) { diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java index e4686f0b577..f1de1f00186 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -25,60 +25,124 @@ package sun.awt.windows; -import java.awt.peer.TaskbarPeer; -import java.awt.*; -import java.awt.im.InputMethodHighlight; -import java.awt.im.spi.InputMethodDescriptor; -import java.awt.image.*; -import java.awt.peer.*; +import java.awt.AWTEvent; +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FileDialog; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.Insets; +import java.awt.JobAttributes; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.PrintJob; +import java.awt.RenderingHints; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.SystemTray; +import java.awt.Taskbar; +import java.awt.TextArea; +import java.awt.TextComponent; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.TrayIcon; +import java.awt.Window; +import java.awt.datatransfer.Clipboard; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.MouseDragGestureRecognizer; +import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; -import java.awt.datatransfer.Clipboard; -import java.awt.TextComponent; -import java.awt.TrayIcon; +import java.awt.im.InputMethodHighlight; +import java.awt.im.spi.InputMethodDescriptor; +import java.awt.image.ColorModel; +import java.awt.peer.ButtonPeer; +import java.awt.peer.CanvasPeer; +import java.awt.peer.CheckboxMenuItemPeer; +import java.awt.peer.CheckboxPeer; +import java.awt.peer.ChoicePeer; +import java.awt.peer.DesktopPeer; +import java.awt.peer.DialogPeer; +import java.awt.peer.FileDialogPeer; +import java.awt.peer.FontPeer; +import java.awt.peer.FramePeer; +import java.awt.peer.KeyboardFocusManagerPeer; +import java.awt.peer.LabelPeer; +import java.awt.peer.ListPeer; +import java.awt.peer.MenuBarPeer; +import java.awt.peer.MenuItemPeer; +import java.awt.peer.MenuPeer; +import java.awt.peer.MouseInfoPeer; +import java.awt.peer.PanelPeer; +import java.awt.peer.PopupMenuPeer; +import java.awt.peer.RobotPeer; +import java.awt.peer.ScrollPanePeer; +import java.awt.peer.ScrollbarPeer; +import java.awt.peer.SystemTrayPeer; +import java.awt.peer.TaskbarPeer; +import java.awt.peer.TextAreaPeer; +import java.awt.peer.TextFieldPeer; +import java.awt.peer.TrayIconPeer; +import java.awt.peer.WindowPeer; import java.beans.PropertyChangeListener; import java.lang.ref.WeakReference; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + import javax.swing.text.JTextComponent; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.AWTAutoShutdown; import sun.awt.AWTPermissions; import sun.awt.AppContext; import sun.awt.DisplayChangedListener; import sun.awt.LightweightFrame; import sun.awt.SunToolkit; -import sun.awt.util.ThreadGroupUtils; import sun.awt.Win32GraphicsDevice; import sun.awt.Win32GraphicsEnvironment; import sun.awt.datatransfer.DataTransferer; -import sun.java2d.d3d.D3DRenderQueue; -import sun.java2d.opengl.OGLRenderQueue; - -import sun.print.PrintJob2D; - -import java.awt.dnd.DragSource; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureRecognizer; -import java.awt.dnd.MouseDragGestureRecognizer; -import java.awt.dnd.InvalidDnDOperationException; -import java.awt.dnd.peer.DragSourceContextPeer; - -import java.util.Hashtable; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - import sun.awt.util.PerformanceLogger; +import sun.awt.util.ThreadGroupUtils; import sun.font.FontManager; import sun.font.FontManagerFactory; import sun.font.SunFontManager; +import sun.java2d.d3d.D3DRenderQueue; +import sun.java2d.opengl.OGLRenderQueue; +import sun.print.PrintJob2D; import sun.util.logging.PlatformLogger; public final class WToolkit extends SunToolkit implements Runnable { @@ -496,11 +560,11 @@ public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) { } @Override - public RobotPeer createRobot(Robot target, GraphicsDevice screen) { - // (target is unused for now) - // Robot's don't need to go in the peer map since - // they're not Component's - return new WRobotPeer(screen); + public RobotPeer createRobot(GraphicsDevice screen) throws AWTException { + if (screen instanceof Win32GraphicsDevice) { + return new WRobotPeer(); + } + return super.createRobot(screen); } public WEmbeddedFramePeer createEmbeddedFrame(WEmbeddedFrame target) { diff --git a/test/jdk/java/awt/Robot/CreateRobotCustomGC/CreateRobotCustomGC.java b/test/jdk/java/awt/Robot/CreateRobotCustomGC/CreateRobotCustomGC.java new file mode 100644 index 00000000000..47a4e4946a5 --- /dev/null +++ b/test/jdk/java/awt/Robot/CreateRobotCustomGC/CreateRobotCustomGC.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +import java.awt.AWTException; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Robot; + +/** + * @test + * @key headful + * @bug 8238936 + * @summary Check that Robot(GraphicsDevice) constructor throw AWTException if + * device is unsupported + */ +public final class CreateRobotCustomGC { + + public static void main(String[] args) { + try { + new Robot(new GraphicsDevice() { + @Override + public int getType() { + return TYPE_RASTER_SCREEN; + } + + @Override + public String getIDstring() { + return "Custom screen device"; + } + + @Override + public GraphicsConfiguration[] getConfigurations() { + return new GraphicsConfiguration[0]; + } + + @Override + public GraphicsConfiguration getDefaultConfiguration() { + return null; + } + }); + throw new RuntimeException("Expected AWTException did not occur"); + } catch (AWTException ignored) { + // expected AWTException + } + } +} \ No newline at end of file From 2a5ae36da24ff39c1e531951e83072bb9f4aafb8 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Tue, 20 Dec 2022 10:23:37 +0000 Subject: [PATCH 016/205] 8289695: [TESTBUG] TestMemoryAwareness.java fails on cgroups v2 and crun Backport-of: ac6be165196457a26d837760b5f5030fe010d633 --- test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java index 24f23ba780d..9e7d062e860 100644 --- a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java +++ b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java @@ -152,9 +152,8 @@ private static void testMemorySoftLimit(String valueToSet, String expectedTraceV private static void testOOM(String dockerMemLimit, int sizeToAllocInMb) throws Exception { Common.logNewTestCase("OOM"); - // add "--memory-swappiness 0" so as to disable anonymous page swapping. DockerRunOptions opts = Common.newOpts(imageName, "AttemptOOM") - .addDockerOpts("--memory", dockerMemLimit, "--memory-swappiness", "0", "--memory-swap", dockerMemLimit); + .addDockerOpts("--memory", dockerMemLimit, "--memory-swap", dockerMemLimit); opts.classParams.add("" + sizeToAllocInMb); // make sure we avoid inherited Xmx settings from the jtreg vmoptions From 31b51844bca9904d34f4d8eb7540a9014f657cdb Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Tue, 20 Dec 2022 10:41:41 +0000 Subject: [PATCH 017/205] 8065422: Trailing dot in hostname causes TLS handshake to fail with SNI disabled Backport-of: a95ee5ada230a0177517efd3a417f319066169dd --- .../classes/sun/security/ssl/Utilities.java | 11 +- .../security/ssl/X509TrustManagerImpl.java | 6 + .../net/ssl/ServerName/EndingDotHostname.java | 251 +++++++++++++ .../net/ssl/templates/SSLExampleCert.java | 351 ++++++++++++++++++ 4 files changed, 616 insertions(+), 3 deletions(-) create mode 100644 test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java create mode 100644 test/jdk/javax/net/ssl/templates/SSLExampleCert.java diff --git a/src/java.base/share/classes/sun/security/ssl/Utilities.java b/src/java.base/share/classes/sun/security/ssl/Utilities.java index 95005b466dc..d56c0bf29bd 100644 --- a/src/java.base/share/classes/sun/security/ssl/Utilities.java +++ b/src/java.base/share/classes/sun/security/ssl/Utilities.java @@ -100,14 +100,19 @@ static List addToSNIServerNameList( * not look like a FQDN */ private static SNIHostName rawToSNIHostName(String hostname) { - SNIHostName sniHostName = null; + // Is it a Fully-Qualified Domain Names (FQDN) ending with a dot? + if (hostname != null && hostname.endsWith(".")) { + // Remove the ending dot, which is not allowed in SNIHostName. + hostname = hostname.substring(0, hostname.length() - 1); + } + if (hostname != null && hostname.indexOf('.') > 0 && !hostname.endsWith(".") && !IPAddressUtil.isIPv4LiteralAddress(hostname) && !IPAddressUtil.isIPv6LiteralAddress(hostname)) { try { - sniHostName = new SNIHostName(hostname); + return new SNIHostName(hostname); } catch (IllegalArgumentException iae) { // don't bother to handle illegal host_name if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { @@ -117,7 +122,7 @@ private static SNIHostName rawToSNIHostName(String hostname) { } } - return sniHostName; + return null; } /** diff --git a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java index db72e7f294c..999fb09f312 100644 --- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java @@ -407,6 +407,12 @@ static void checkIdentity(SSLSession session, boolean identifiable = false; String peerHost = session.getPeerHost(); + // Is it a Fully-Qualified Domain Names (FQDN) ending with a dot? + if (peerHost != null && peerHost.endsWith(".")) { + // Remove the ending dot, which is not allowed in SNIHostName. + peerHost = peerHost.substring(0, peerHost.length() - 1); + } + if (!checkClientTrusted) { List sniNames = getRequestedServerNames(session); String sniHostName = getHostNameInSNI(sniNames); diff --git a/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java new file mode 100644 index 00000000000..20ebc144088 --- /dev/null +++ b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * 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 8806542 + * @summary Trailing dot in hostname causes TLS handshake to fail + * @library /javax/net/ssl/templates + * @run main/othervm -Djdk.net.hosts.file=hostsForExample EndingDotHostname + */ + +import javax.net.ssl.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class EndingDotHostname { + public static void main(String[] args) throws Exception { + System.setProperty("jdk.net.hosts.file", "hostsForExample"); + (new EndingDotHostname()).run(); + } + + public void run() throws Exception { + bootUp(); + } + + // ================================================= + // Stuffs to boot up the client-server mode testing. + private Thread serverThread = null; + private volatile Exception serverException = null; + private volatile Exception clientException = null; + + // Is the server ready to serve? + protected final CountDownLatch serverCondition = new CountDownLatch(1); + + // Is the client ready to handshake? + protected final CountDownLatch clientCondition = new CountDownLatch(1); + + // What's the server port? Use any free port by default + protected volatile int serverPort = 0; + + // Boot up the testing, used to drive remainder of the test. + private void bootUp() throws Exception { + Exception startException = null; + try { + startServer(); + startClient(); + } catch (Exception e) { + startException = e; + } + + // Wait for other side to close down. + if (serverThread != null) { + serverThread.join(); + } + + // The test is pretty much over. Which side threw an exception? + Exception local = clientException; + Exception remote = serverException; + + Exception exception = null; + + // Check various exception conditions. + if ((local != null) && (remote != null)) { + // If both failed, return the curthread's exception. + local.initCause(remote); + exception = local; + } else if (local != null) { + exception = local; + } else if (remote != null) { + exception = remote; + } else if (startException != null) { + exception = startException; + } + + // If there was an exception *AND* a startException, output it. + if (exception != null) { + if (exception != startException && startException != null) { + exception.addSuppressed(startException); + } + throw exception; + } + + // Fall-through: no exception to throw! + } + + private void startServer() { + serverThread = new Thread(() -> { + try { + doServerSide(); + } catch (Exception e) { + // Our server thread just died. Release the client, + // if not active already... + serverException = e; + } + }); + + serverThread.start(); + } + + private void startClient() { + try { + doClientSide(); + } catch (Exception e) { + clientException = e; + } + } + + protected void doServerSide() throws Exception { + // kick off the server side service + SSLContext context = SSLExampleCert.createServerSSLContext(); + SSLServerSocketFactory sslssf = context.getServerSocketFactory(); + + SSLServerSocket sslServerSocket = + (SSLServerSocket)sslssf.createServerSocket(); + sslServerSocket.bind(new InetSocketAddress( + InetAddress.getLoopbackAddress(), 0)); + serverPort = sslServerSocket.getLocalPort(); + + // Signal the client, the server is ready to accept connection. + serverCondition.countDown(); + + // Try to accept a connection in 30 seconds. + SSLSocket sslSocket; + try { + sslServerSocket.setSoTimeout(30000); + sslSocket = (SSLSocket)sslServerSocket.accept(); + } catch (SocketTimeoutException ste) { + // Ignore the test case if no connection within 30 seconds. + System.out.println( + "No incoming client connection in 30 seconds. " + + "Ignore in server side."); + return; + } finally { + sslServerSocket.close(); + } + + // handle the connection + try { + // Is it the expected client connection? + // + // Naughty test cases or third party routines may try to + // connection to this server port unintentionally. In + // order to mitigate the impact of unexpected client + // connections and avoid intermittent failure, it should + // be checked that the accepted connection is really linked + // to the expected client. + boolean clientIsReady = + clientCondition.await(30L, TimeUnit.SECONDS); + + if (clientIsReady) { + // Run the application in server side. + runServerApplication(sslSocket); + } else { // Otherwise, ignore + // We don't actually care about plain socket connections + // for TLS communication testing generally. Just ignore + // the test if the accepted connection is not linked to + // the expected client or the client connection timeout + // in 30 seconds. + System.out.println( + "The client is not the expected one or timeout. " + + "Ignore in server side."); + } + } finally { + sslSocket.close(); + } + } + + // Define the server side application of the test for the specified socket. + protected void runServerApplication(SSLSocket socket) throws Exception { + // here comes the test logic + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + sslOS.write(85); + sslOS.flush(); + } + + protected void doClientSide() throws Exception { + // Wait for server to get started. + // + // The server side takes care of the issue if the server cannot + // get started in 90 seconds. The client side would just ignore + // the test case if the serer is not ready. + boolean serverIsReady = + serverCondition.await(90L, TimeUnit.SECONDS); + if (!serverIsReady) { + System.out.println( + "The server is not ready yet in 90 seconds. " + + "Ignore in client side."); + return; + } + + SSLContext context = SSLExampleCert.createClientSSLContext(); + SSLSocketFactory sslsf = context.getSocketFactory(); + + try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket( + "www.example.com.", serverPort)) { + // OK, here the client and server get connected. + SSLParameters sslParameters = sslSocket.getSSLParameters(); + sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); + sslSocket.setSSLParameters(sslParameters); + + // Signal the server, the client is ready to communicate. + clientCondition.countDown(); + + // There is still a chance in theory that the server thread may + // wait client-ready timeout and then quit. The chance should + // be really rare so we don't consider it until it becomes a + // real problem. + + // Run the application in client side. + runClientApplication(sslSocket); + } + } + + // Define the client side application of the test for the specified socket. + protected void runClientApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(280); + sslOS.flush(); + sslIS.read(); + } +} + diff --git a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java new file mode 100644 index 00000000000..bc8a1fdb2e9 --- /dev/null +++ b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * 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.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; +import java.io.*; +import java.net.InetAddress; +import java.security.KeyFactory; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; + +// A template to use "www.example.com" as the server name. The caller should +// set a virtual hosts file with System Property, "jdk.net.hosts.file". This +// class will map the loopback address to "www.example.com", and write to +// the specified hosts file. +public enum SSLExampleCert { + // Version: 3 (0x2) + // Serial Number: 15223159159760931473 (0xd34386999cc8ca91) + // Signature Algorithm: sha256WithRSAEncryption + // Issuer: C=US, ST=California, O=Example, OU=Test + // Validity + // Not Before: Jan 26 04:50:29 2022 GMT + // Not After : Feb 25 04:50:29 2022 GMT + // Subject: C=US, ST=California, O=Example, OU=Test + // Public Key Algorithm: rsaEncryption + CA_RSA("RSA", + """ + -----BEGIN CERTIFICATE----- + MIIDXDCCAkSgAwIBAgIJANNDhpmcyMqRMA0GCSqGSIb3DQEBCwUAMEMxCzAJBgNV + BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w + CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowQzEL + MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w + bGUxDTALBgNVBAsMBFRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB + AQDnOL2hB/GYyYziXo/ppxi7V1LfMMLeHt0lZbYlrmNxUlln4naI4B4Lkg75eb1Y + DgC7MZQd5nKijK9Dkq52Z2zLxaqBYnLxKJ36qKPqbtTL3I8mfUvVEeNIDN/8YTAt + suIEQi54dNtQVrB4YReMdnUq+xCKLAfEio4QLEQr7KtyCBXHZpM7RYRT0giQFvDU + 2kls9lFLeqKXgocnA7VpoL0V12hpxDeJoRm1szf0M5YXGJumQLaE5qM/+P2OOhw/ + T+xkupy2GF02s6FBXkH7NrFIjtuBSaVhSvCG/N7njWSn339thr3kiPEaCS4KSH5E + E6FEazxZQrTCbkQQ+v3y1pS1AgMBAAGjUzBRMA8GA1UdEwEB/wQFMAMBAf8wHQYD + VR0OBBYEFMFw2FWUvwZx3FJjm1G9TujCjAJSMB8GA1UdIwQYMBaAFMFw2FWUvwZx + 3FJjm1G9TujCjAJSMA0GCSqGSIb3DQEBCwUAA4IBAQCJsJjeYcT/GtKp64C+9KCi + Vgw/WnBZwbosSFZmqyID8aAnAxaGMkZ2B2pUZHTtCkBf6d9c0tuWb5yF8npV77sE + bZqeNg2GU7EvH3WPgPbQVT7+Qb+WbY3EEPgJHLytch61Rm/TRQ3OqD0B+Gs7YjAU + fEspmk1JJ6DWuXX13SHoGWgVnO7rXBnCJaGnGpONtggG4oO5hrwnMzQZKh5eZDhC + 7tkNPqVDoLv+QqnFk8q6k8hhxnVf+aw56IdsebN+9Bi+Lv6OQ+stKUo/u/RTW2z1 + odCOwc8DPF3jbacJsOmLhl3ciuWGOckx9KCvaBeTTgkPdLQH1gpNha2tnqgxUXmC + -----END CERTIFICATE-----""", + + """ + MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDnOL2hB/GYyYzi + Xo/ppxi7V1LfMMLeHt0lZbYlrmNxUlln4naI4B4Lkg75eb1YDgC7MZQd5nKijK9D + kq52Z2zLxaqBYnLxKJ36qKPqbtTL3I8mfUvVEeNIDN/8YTAtsuIEQi54dNtQVrB4 + YReMdnUq+xCKLAfEio4QLEQr7KtyCBXHZpM7RYRT0giQFvDU2kls9lFLeqKXgocn + A7VpoL0V12hpxDeJoRm1szf0M5YXGJumQLaE5qM/+P2OOhw/T+xkupy2GF02s6FB + XkH7NrFIjtuBSaVhSvCG/N7njWSn339thr3kiPEaCS4KSH5EE6FEazxZQrTCbkQQ + +v3y1pS1AgMBAAECggEBAJQAKLkTWZx/njMjbiCT+Wuo6H2+O21r+ge/BAk4h6R4 + nou1VEQmmHS1h+o992mOhP9NK867vDK5tFGfaRaW+vevzYTF3GbqpbxVB56+VG0s + /2AWoVx/96gdvZ1RJEKMFsm9BvvJaLwS0SAsnaMmC7d4Ps0Cg/JU8bv+aaBn/BGf + TWiofYWeUk6llco4kO9H2APxUVzlaUUU/cPAJqX7XktnhDCI9/esuVg7nVR0XxOF + GDrV/jdqSYmSbp4aTRXgI9nwxOmlKiGgevTrCUXl3/KaJxZekllVjushY1VVzgbY + K5R4bcN5MXMmFdgF9DTEW72RqEfg9iXqyhYbZp3Q/UECgYEA/yiaJd0w2HS22HSg + o4dJ072WbyR3qUqQmPbSUn9hBQTJAz1eX3cci8u4oawo/S+jN38b/DfpSg3eIMLB + vnXW3wZtodpJnFaweKd3yUaSF2r9vZRHJgfPfe67VbruEOF6BsCjTq/deGeNnGeH + /IDVn9WtSeRX/bv/s5YHvGaHGGUCgYEA5/vugmilOBq979EqksCG/7EQHSOoEukO + J/aunDyEwz+BMEHOEW7tDMUefdiSfnGXSW+ZTmpmvc+aLk37Xuo34jpugK5ayUFY + iYVgiqdnygGiBevBM2o0O/parQkAGEB8GPButrYItUzubUgXnuw+EdMiXGnpjJaK + S3dPYJEHvhECgYEAjqIIwV/LPUTJLWjMn30yBN43KLvu9ECNYiSfX6R6/I43O8tj + ZOQ1nePsutt9MkMd7xjr8OrkSxRDdnbITQqcaaGzSUW33mALV/btnCMJ6XNSklZA + C39UOuZn7D2JdQBF8V5gK81ddUAVxjeNqdXvFOEidGrj0R/1iVM10dhSbo0CgYBk + P8GtR02Gtj+4P/qW2m48VqbxALSkH2SHrpl8WMbCnVHVqcpETFxSNWjc11dPHwVS + rdBhS6fEhM9LDVYAiVTHBZs1LqN67ys0mpfCs18ts5Dx4BRohI+4D5NZzVbmJA+8 + s0IU4QtYVbt/LDVQ7yRPjZ7+sqJDp9ZxkEiUIXhoEQKBgQCPG2f8BhsCYNAOV60F + hJVjhDdf59Mia3B2J9SSnrg6Tl2rWB7GPP19TiSPFS6Sn95mWrMjZ2ZuOXtCYV4H + +hmu87AV2CXFhW5c588cajXMT92GFVMSXdE1OHRzDjhpH+/ll8SnmQa7sXmEV36+ + sawd7mwcB9IEi562wglADxBUCA== + """), + + // Version: 3 (0x2) + // Serial Number: 14845986384898254166 (0xce0789f5ac256556) + // Signature Algorithm: sha1WithRSAEncryption + // Issuer: C=US, ST=California, O=Example, OU=Test + // Validity + // Not Before: Jan 26 04:50:29 2022 GMT + // Not After : Feb 25 04:50:29 2022 GMT + // Subject: C=US, ST=California, O=Example, OU=Test, CN=www.example.com + // Public Key Algorithm: rsaEncryption + SERVER_EXAMPLE_RSA("RSA", + """ + -----BEGIN CERTIFICATE----- + MIIDjDCCAnSgAwIBAgIJAM4HifWsJWVWMA0GCSqGSIb3DQEBBQUAMEMxCzAJBgNV + BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w + CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowXTEL + MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w + bGUxDTALBgNVBAsMBFRlc3QxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTCCASIw + DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK/i4bVSAF6/aFHyzrFAON8Uwn2a + Q9jFoAMowUkH6+PCexlt4wCOEMVH9IQPa1yzeVlkYRqHggz3i6aVYvd27Q+c6vOF + FuRegWdJusyEuoXd5nwxSGiZZMLmFQswODSPmucroCG+Tq9RKY5oEKiRP8tUDqyn + eE52PaeSR2Q6mng7BM5Llj7amVgimO3jlH2AWLLpHNTkc3j/M1QrLFV2PqN4dpxT + OeFuVWzpfTWJSH+9Kq4u/zBMbYl8ON7DSgJAzc2BOw8VPIYIK6JIw6IDbLn4dIQf + GikdgHKB2K6EDOc9LuX6UqQQODDFU88muAyPgpGfUQjxKZeUoTqoAFyisI0CAwEA + AaNpMGcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUQqf/4nqluVMZ8huD3I5FNqLXTqAw + HwYDVR0jBBgwFoAUwXDYVZS/BnHcUmObUb1O6MKMAlIwGgYDVR0RBBMwEYIPd3d3 + LmV4YW1wbGUuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQBl8FJD98fJh/0KY+3LtZDW + CQZDeBSfnpq4milrvHH+gcOCaKYlB9702tAQ6rL1c1dLz/Lpw1x7EYvO8XIwXMRc + DZghf8EJ6wMpZbLVLAQLCTggiB65XPwmhUoMvgVRVLYoXT3ozmNPt7P+ZURisqem + 0/xVVfxqmHw9Hb4DNlc7oZDgOK7IrqriaBK6Amsu3m2eThsvkwTdJfeFG3ZdV6x5 + mbaGZDMt/wgWIqyq5CZNpXPaFRH7KM4zhcoqXvFAoq9jxWOuBkJUUx5EHaxGhhPw + SMgE1yl4O+N7GJmF/WMR5zp2LGKMqJ3vwLPv6QNkUmLwB5ZLYJ8E2dpj6DjQWa7X + -----END CERTIFICATE-----""", + + """ + MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCv4uG1UgBev2hR + 8s6xQDjfFMJ9mkPYxaADKMFJB+vjwnsZbeMAjhDFR/SED2tcs3lZZGEah4IM94um + lWL3du0PnOrzhRbkXoFnSbrMhLqF3eZ8MUhomWTC5hULMDg0j5rnK6Ahvk6vUSmO + aBCokT/LVA6sp3hOdj2nkkdkOpp4OwTOS5Y+2plYIpjt45R9gFiy6RzU5HN4/zNU + KyxVdj6jeHacUznhblVs6X01iUh/vSquLv8wTG2JfDjew0oCQM3NgTsPFTyGCCui + SMOiA2y5+HSEHxopHYBygdiuhAznPS7l+lKkEDgwxVPPJrgMj4KRn1EI8SmXlKE6 + qABcorCNAgMBAAECggEBAJb2SvfP7BVmf+lmV9V249lE/jHECFu0M8TCZDOEowiX + 0gRfdqjxRp+tRMdcXK/yM0Nwjo+wowTyK2DNc2YnIw11h4uAPcfA/ZxjgfssKNPh + Q4Rw4E826W8HACTcPEGQyEmF/ik4KFz9coeR9kpYcMLZ4MZ77xyZDA4Z1UDHs/Fg + egrd4k35fxIFOavsjNuekMIjZlyQ2xU1a11QDBrZAu/pjITXXulg4jCxLbeNOOPs + hH+Sx+jnsVV7qIBNwulzxEdpb3+NkWIMmOQK4HOSeHgjRVvSXXBPgYadMaP/Bzvx + AwJ9WeLZg7KWHE03aOc7CSMoyHfmhXx3gD8icGpSq8ECgYEA3TWGBSgny/wket+V + 65ldWjp4NOKHbLPtBdL9ygIO+1bGfLl5srCxUWHBYdcWCXKuB5ALCBu0hMY+TlwF + s/BzZmvVW7RLAEZZ3Q5HpawDlr9j8Kenm4X2Mqh0MSkmwIDRDHF8jRXAvWIzcBiS + +rPZm2CMZpznUSE4X+GrvTSCBbkCgYEAy4yJ58wNUavj/tR8KySn5ygPABFZ1Uoy + pIyabm18Oe3gCl5UulBskoN0WreTKnA4r9jGlnrgeuu5WfMK53AZKbC+YduZixW4 + QFuJBSMbFCBDt4nkhkMMR7VcV4jIqaOK7qNrs7ubGTZhsG8wj6/WWdCp3Avnx1rS + WCCoYNhAK3UCgYADaLnCBpZmbGJbimqTEPABXflQR1Vy9WrnthK3NETq1rGEZo9b + k6GH8Yu7aEcsqhnIgA3LeDHWAgAf0Qc9eK0unObS3Ppy7KKh54BvKzF690QhB1Rr + 7yqWKUZxI4M3YETYfj8/JWCtCoBkb9yEBJWL8Xb4dd6Sv4JQ5/dvmQmP8QKBgBX+ + 5+Aeksnik060U36uBV7bW1OcjGKaFALoFsAcILJ53B4Ct5Eyo6jpf6dV8xdA7T9D + Y6JbQOrHkk4AD4uW94Ej0k7s1hjLjg+WVKYzdvejzO2GfyVrFWaiWIo1A8ohHCBR + lI/llAsTb1cLjOnaDIXEILbgqnlGfTh8vvVIKRcJAoGALF6Q1Ca2GIx4kJZ2/Az5 + qx89q95wQoWVHcJCA91g/GKg/bD0ZJMWEhhVH3QcnDOU7afRGKOPGdSSBdPQnspQ + 1OPpPjA3U5Mffy5PJ2bHTpPBeeHOzDO4Jt073zK3N81QovJzS8COoOwuGdcocURH + mFMnEtK7d+EK1C1NTWDyNzU= + """), + + + // Version: 3 (0x2) + // Serial Number: 14845986384898254167 (0xce0789f5ac256557) + // Signature Algorithm: sha1WithRSAEncryption + // Issuer: C=US, ST=California, O=Example, OU=Test + // Validity + // Not Before: Jan 26 04:50:29 2022 GMT + // Not After : Feb 25 04:50:29 2022 GMT + // Subject: C=US, ST=California, O=Example, OU=Test, CN=Do-Not-Reply + // Public Key Algorithm: rsaEncryption + CLIENT_EXAMPLE_RSA("RSA", + """ + -----BEGIN CERTIFICATE----- + MIIDkjCCAnqgAwIBAgIJAM4HifWsJWVXMA0GCSqGSIb3DQEBBQUAMEMxCzAJBgNV + BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w + CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowWjEL + MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w + bGUxDTALBgNVBAsMBFRlc3QxFTATBgNVBAMMDERvLU5vdC1SZXBseTCCASIwDQYJ + KoZIhvcNAQEBBQADggEPADCCAQoCggEBAODbsCteHcAg3dktUO5fiPTytIahKZMg + U2h6h0+BT803tYcdN6WDHnLNlU/3iFnBMpyTwzWhYIftC9c/TIkXBAGfWl4HHQgc + x08NHPms0E+GF6CDthvHERSvRCBrIyVna0KIZPemBzUfeBeNdiqwsLvg+C5dqWu5 + YcILvL6GzTMvdMwJeEX+c2ZYHibqd8aZydWsT+IPVZnueDX6KTOnYvexLFIoid2a + 62FavnMWiPKnICertDDg+gHlN2XceW3tlYQwO+HMig4DH3u2x0SApOoM3y8k29Ew + Fn6wquSRomcbDiI8SEOeaBFenu6W0g24iaxIZfqEM52kPbQFdzqg+O0CAwEAAaNy + MHAwCQYDVR0TBAIwADAdBgNVHQ4EFgQU0t+I5iAfPq6C/I2CSvTKHGK6+2kwHwYD + VR0jBBgwFoAUwXDYVZS/BnHcUmObUb1O6MKMAlIwIwYDVR0RBBwwGoEYZG8tbm90 + LXJlcGx5QGV4YW1wbGUuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQBqWk35XXpb3L+N + 7kPlNmSlhfamenVOVYxPBq/tSFpl728CV0OrGAy79awEFDvzhpbBg9Mz7HS/a7ax + f+lBbsAt1maWlsVSsaaJrmy3znl9CZiIg+ykZ5ZzLS5FkIbQ6LkzvxYZJ1JYCzXm + P/5+rbQyIvQaDGL23PmE7AB2Q0q+imt4b9HKs+SnI4XERyj8OF/kseRtILtP2ltV + r+3XgcBxwyU17CLwsHrjnQ8/1eGovBKzGAfUXeHBdzOuD3ZemjnqwlzQTf2TAkBP + OuMc8gr2Umc5tMtdiRUFPODO7DG7vB7LKEsJGKWLUtGbR+3S55lIcCF5NFZ//TNZ + 4x2GPOJ+ + -----END CERTIFICATE-----""", + + """ + MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDg27ArXh3AIN3Z + LVDuX4j08rSGoSmTIFNoeodPgU/NN7WHHTelgx5yzZVP94hZwTKck8M1oWCH7QvX + P0yJFwQBn1peBx0IHMdPDRz5rNBPhhegg7YbxxEUr0QgayMlZ2tCiGT3pgc1H3gX + jXYqsLC74PguXalruWHCC7y+hs0zL3TMCXhF/nNmWB4m6nfGmcnVrE/iD1WZ7ng1 + +ikzp2L3sSxSKIndmuthWr5zFojypyAnq7Qw4PoB5Tdl3Hlt7ZWEMDvhzIoOAx97 + tsdEgKTqDN8vJNvRMBZ+sKrkkaJnGw4iPEhDnmgRXp7ultINuImsSGX6hDOdpD20 + BXc6oPjtAgMBAAECggEAKjqX900RoUeK4oKUNHBUtEvwg2g4+pyTjYeVaeULK6tO + uDVQghEB4uWhKQd/3/tcmfNWMfhAvMZT9vS4Vvavle5rdkU3upJNDBeWXX2LEaRJ + Q6f4x3a3Sn8v+DamvxuRFUmwTKItsFhcoW+7xYCxcFdrxKlqbATAy0SRCecfGoFw + 9pAsFIgIqLGQtV9V9fZWKdXIfLkH3venNImHt0n5pYadl4kZu0gNCmOGRO1MqB51 + bdAck3dBg22TE5+sZBIZmCjBAEbrc2RUQu5mAoDs8eeenxBlFYszWZxqM8BkJL5e + SqQkbc18E8Gzdx52xEx6BCLTq0MITKliKX4B2tsQsQKBgQD1DIvt13yg9LlyoiAb + Fc1zzKZQBPRgDUJCGzCPeC6AqbPUjoxvFAHxGNgmJXqAXwsqcs88qlSGAjk6ANAx + fHWUQ3UmkZjGvV0ru3rIPcXvS7isjzm/cbq1YZua6+ohFl4+hojc/iyUrOaCd9uY + V2zwrr+A0JJrlev72niEuAtEmwKBgQDq6CaLP79dHqAOIV43+SyX7KdwNkMMWIR7 + El6E/74V0IWOYWFXLmV4sX6BKi0ZBTFZ3wKwMTDqQBYD2/a7gq43HjzuWu+2dFhA + pCQumMOKNqcNS9NldqoxAiGLxC+JMhGGyf3RO0Ey9gdPnQuje3133Wce8WWaHHv2 + lD5BcmzdFwKBgQCCeca7wiPy07s2ZUqxAT/eq5XWP30a85RW/IEzsusXyMQepjPy + JPYPuInGbeg3F+QrGuxrQco1fFOaJbq0zq8QXYawHY/6KfPFCFMM8Y9FpczT3IME + A3tFfo5Kw9hq+6z8n8eZ26BDHXiy+Tysdchksrb20JdVv4LiG+ZVzGT7hwKBgG+b + Bp0IF4JFh6PPBLWxRBeWT2MH1Mkr0R2r945W91fj72BbMeU63Oj/42u4vx5xEiZx + xxQw+t2AvzTsMAicqOr1CdvxBoz4L+neUnZ1DApBtxKhIPnG7EtGiOuftToIuL0C + gP4EmhB9RbH0mk/83vqxDUptRGl4+QiJHB76H3DXAoGASGT6tfs1/92rGqe0COm3 + aHpelvW7Wwr9AuBumE7/ur/JWAAiM4pm6w7m5H5duYZtG3eWz1s+jvjy8jIPBIkN + RA2DoneC2J/tsRRNFBqZrOWon5Jv4dc9R79qR13B/Oqu8H6FYSB2oDyh67Csud3q + PRrz4o7UKM+HQ/obr1rUYqM= + """); + + final String keyAlgo; + final String certStr; + final String privateKeyStr; + + // Trusted certificate + private final static SSLExampleCert[] TRUSTED_CERTS = { + SSLExampleCert.CA_RSA + }; + + // Server certificate. + private final static SSLExampleCert[] SERVER_CERTS = { + SSLExampleCert.SERVER_EXAMPLE_RSA + }; + + // Client certificate. + private final static SSLExampleCert[] CLIENT_CERTS = { + SSLExampleCert.CLIENT_EXAMPLE_RSA + }; + + // Set "www.example.com" to loopback address. + static { + String hostsFileName = System.getProperty("jdk.net.hosts.file"); + String loopbackHostname = + InetAddress.getLoopbackAddress().getHostAddress() + + " " + "www.example.com www.example.com.\n"; + try (FileWriter writer= new FileWriter(hostsFileName, false)) { + writer.write(loopbackHostname); + } catch (IOException ioe) { + // ignore + } + } + + SSLExampleCert(String keyAlgo, String certStr, String privateKeyStr) { + this.keyAlgo = keyAlgo; + this.certStr = certStr; + this.privateKeyStr = privateKeyStr; + } + + public static SSLContext createClientSSLContext() throws Exception { + return createSSLContext(TRUSTED_CERTS, CLIENT_CERTS); + } + + public static SSLContext createServerSSLContext() throws Exception { + return createSSLContext(TRUSTED_CERTS, SERVER_CERTS); + } + + private static SSLContext createSSLContext( + SSLExampleCert[] trustedCerts, + SSLExampleCert[] endEntityCerts) throws Exception { + char[] passphrase = "passphrase".toCharArray(); + + // Generate certificate from cert string. + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + + // Import the trusted certs. + KeyStore ts = null; // trust store + if (trustedCerts != null && trustedCerts.length != 0) { + ts = KeyStore.getInstance("PKCS12"); + ts.load(null, null); + + Certificate[] trustedCert = new Certificate[trustedCerts.length]; + for (int i = 0; i < trustedCerts.length; i++) { + try (ByteArrayInputStream is = new ByteArrayInputStream( + trustedCerts[i].certStr.getBytes())) { + trustedCert[i] = cf.generateCertificate(is); + } + + ts.setCertificateEntry("trusted-cert-" + + trustedCerts[i].name(), trustedCert[i]); + } + } + + // Import the key materials. + KeyStore ks = null; // trust store + if (endEntityCerts != null && endEntityCerts.length != 0) { + ks = KeyStore.getInstance("PKCS12"); + ks.load(null, null); + + for (SSLExampleCert endEntityCert : endEntityCerts) { + // generate the private key. + PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( + Base64.getMimeDecoder() + .decode(endEntityCert.privateKeyStr)); + KeyFactory kf = + KeyFactory.getInstance( + endEntityCert.keyAlgo); + PrivateKey priKey = kf.generatePrivate(priKeySpec); + + // generate certificate chain + Certificate keyCert; + try (ByteArrayInputStream is = new ByteArrayInputStream( + endEntityCert.certStr.getBytes())) { + keyCert = cf.generateCertificate(is); + } + + Certificate[] chain = new Certificate[]{keyCert}; + + // import the key entry. + ks.setKeyEntry("end-entity-cert-" + + endEntityCert.name(), + priKey, passphrase, chain); + } + } + + // Create an SSLContext object. + TrustManagerFactory tmf = + TrustManagerFactory.getInstance("PKIX"); + tmf.init(ts); + + SSLContext context = SSLContext.getInstance("TLS"); + if (endEntityCerts != null && endEntityCerts.length != 0) { + KeyManagerFactory kmf = + KeyManagerFactory.getInstance("NewSunX509"); + kmf.init(ks, passphrase); + + context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + } else { + context.init(null, tmf.getTrustManagers(), null); + } + + return context; + } +} From 6a4603f829bbb293575b1fbab126231fec9a6f67 Mon Sep 17 00:00:00 2001 From: Denghui Dong Date: Wed, 21 Dec 2022 06:31:51 +0000 Subject: [PATCH 018/205] 8283870: jdeprscan --help causes an exception when the locale is ja, zh_CN or de Reviewed-by: clanger Backport-of: ef25e189c7f987b6c7b049ce481ee832cc7f70aa --- .../com/sun/tools/jdeprscan/resources/jdeprscan_ja.properties | 2 +- .../sun/tools/jdeprscan/resources/jdeprscan_zh_CN.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_ja.properties b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_ja.properties index 3fe4425ff7a..bd8afce55e9 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_ja.properties +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_ja.properties @@ -1,4 +1,4 @@ -main.usage=\u4F7F\u7528\u65B9\u6CD5: jdeprscan [options] ''{dir|jar|class}'' ...\n\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n --class-path PATH\n --for-removal\n --full-version\n -? -h --help\n -l --list\n --release {0}\n -v --verbose\n --version +main.usage=\u4F7F\u7528\u65B9\u6CD5: jdeprscan [options] '{dir|jar|class}' ...\n\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n --class-path PATH\n --for-removal\n --full-version\n -? -h --help\n -l --list\n --release {0}\n -v --verbose\n --version main.help=\u975E\u63A8\u5968API\u306E\u4F7F\u7528\u306B\u3064\u3044\u3066\u5404\u5F15\u6570\u3092\u30B9\u30AD\u30E3\u30F3\u3057\u307E\u3059\u3002\u5F15\u6570\u306B\u306F\u3001\n\u30D1\u30C3\u30B1\u30FC\u30B8\u968E\u5C64\u306E\u30EB\u30FC\u30C8\u3092\u6307\u5B9A\u3059\u308B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001JAR\u30D5\u30A1\u30A4\u30EB\u3001\n\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30AF\u30E9\u30B9\u540D\u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002\u30AF\u30E9\u30B9\u540D\u306F\u3001\n\u5B8C\u5168\u4FEE\u98FE\u30AF\u30E9\u30B9\u540D\u3092\u4F7F\u7528\u3057\u3066\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u30CD\u30B9\u30C8\u3055\u308C\u305F\n\u30AF\u30E9\u30B9\u306F$\u3067\u533A\u5207\u308A\u307E\u3059\u3002\u4F8B:\n\n java.lang.Thread$State\n\n--class-path\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u4F9D\u5B58\u3059\u308B\u30AF\u30E9\u30B9\u306E\u89E3\u6C7A\u306E\u305F\u3081\u306E\n\u691C\u7D22\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002\n\n--for-removal\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30B9\u30AD\u30E3\u30F3\u3068\u30EA\u30B9\u30C8\u5316\u3092\u524A\u9664\u4E88\u5B9A\u3067\u975E\u63A8\u5968\u306EAPI\u306B\n\u9650\u5B9A\u3057\u307E\u3059\u3002\u30EA\u30EA\u30FC\u30B9\u5024\u304C6\u30017\u307E\u305F\u306F8\u306E\u5834\u5408\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002\n\n--full-version\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u30C4\u30FC\u30EB\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306E\u5168\u4F53\u3092\u51FA\u529B\u3057\u307E\u3059\u3002\n\n--help (-? -h)\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u5168\u4F53\u3092\u51FA\u529B\u3057\u307E\u3059\u3002\n\n--list (-l)\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u975E\u63A8\u5968API\u30BB\u30C3\u30C8\u3092\u51FA\u529B\u3057\u307E\u3059\u3002\u30B9\u30AD\u30E3\u30F3\u306F\u884C\u308F\u308C\u306A\u3044\u305F\u3081\u3001\n\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001JAR\u307E\u305F\u306F\u30AF\u30E9\u30B9\u5F15\u6570\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\u3002\n\n--release\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30B9\u30AD\u30E3\u30F3\u3059\u308B\u975E\u63A8\u5968API\u306E\u30BB\u30C3\u30C8\u3092\u63D0\u4F9B\u3059\u308BJava SE\n\u30EA\u30EA\u30FC\u30B9\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002\n\n--verbose (-v)\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3059\u308B\u3068\u3001\u51E6\u7406\u4E2D\u306B\u8FFD\u52A0\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3067\u304D\u307E\u3059\u3002\n\n--version\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u7C21\u7565\u5316\u3055\u308C\u305F\u30C4\u30FC\u30EB\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u3092\u51FA\u529B\u3057\u307E\u3059\u3002 diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_zh_CN.properties b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_zh_CN.properties index 5b2fa2439d9..4fe6782e0d9 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_zh_CN.properties +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan_zh_CN.properties @@ -1,4 +1,4 @@ -main.usage=\u7528\u6CD5\uFF1Ajdeprscan [options] ''{dir|jar|class}'' ...\n\n\u9009\u9879\uFF1A\n --class-path PATH\n --for-removal\n --full-version\n -? -h --help\n -l --list\n --release {0}\n -v --verbose\n --version +main.usage=\u7528\u6CD5\uFF1Ajdeprscan [options] '{dir|jar|class}' ...\n\n\u9009\u9879\uFF1A\n --class-path PATH\n --for-removal\n --full-version\n -? -h --help\n -l --list\n --release {0}\n -v --verbose\n --version main.help=\u626B\u63CF\u6BCF\u4E2A\u53C2\u6570\u4EE5\u4E86\u89E3\u662F\u5426\u4F7F\u7528\u4E86\u8FC7\u65F6\u7684 API\u3002\n\u53C2\u6570\u53EF\u4EE5\u662F\u6307\u5B9A\u7A0B\u5E8F\u5305\u5206\u5C42\u7ED3\u6784\u3001JAR \u6587\u4EF6\u3001\n\u7C7B\u6587\u4EF6\u6216\u7C7B\u540D\u7684\u6839\u7684\u76EE\u5F55\u3002\u7C7B\u540D\u5FC5\u987B\n\u4F7F\u7528\u5168\u9650\u5B9A\u7C7B\u540D\u6307\u5B9A\uFF0C\u5E76\u4F7F\u7528 $ \u5206\u9694\u7B26\n\u6307\u5B9A\u5D4C\u5957\u7C7B\uFF0C\u4F8B\u5982\uFF0C\n\n java.lang.Thread$State\n\n--class-path \u9009\u9879\u63D0\u4F9B\u4E86\u7528\u4E8E\u89E3\u6790\u4ECE\u5C5E\u7C7B\u7684\n\u641C\u7D22\u8DEF\u5F84\u3002\n\n--for-removal \u9009\u9879\u9650\u5236\u626B\u63CF\u6216\u5217\u51FA\u5DF2\u8FC7\u65F6\u5E76\u5F85\u5220\u9664\n\u7684 API\u3002\u4E0D\u80FD\u4E0E\u53D1\u884C\u7248\u503C 6\u30017 \u6216 8 \u4E00\u8D77\u4F7F\u7528\u3002\n\n--full-version \u9009\u9879\u8F93\u51FA\u5DE5\u5177\u7684\u5B8C\u6574\u7248\u672C\u5B57\u7B26\u4E32\u3002\n\n--help (-? -h) \u9009\u9879\u8F93\u51FA\u5B8C\u6574\u7684\u5E2E\u52A9\u6D88\u606F\u3002\n\n--list (-l) \u9009\u9879\u8F93\u51FA\u4E00\u7EC4\u5DF2\u8FC7\u65F6\u7684 API\u3002\u4E0D\u6267\u884C\u626B\u63CF\uFF0C\n\u56E0\u6B64\u4E0D\u5E94\u63D0\u4F9B\u4EFB\u4F55\u76EE\u5F55\u3001jar \u6216\u7C7B\u53C2\u6570\u3002\n\n--release \u9009\u9879\u6307\u5B9A\u63D0\u4F9B\u8981\u626B\u63CF\u7684\u5DF2\u8FC7\u65F6 API \u96C6\n\u7684 Java SE \u53D1\u884C\u7248\u3002\n\n--verbose (-v) \u9009\u9879\u5728\u5904\u7406\u671F\u95F4\u542F\u7528\u9644\u52A0\u6D88\u606F\u8F93\u51FA\u3002\n\n--version \u9009\u9879\u8F93\u51FA\u5DE5\u5177\u7684\u7F29\u5199\u7248\u672C\u5B57\u7B26\u4E32\u3002 From a3d052291069ab18e63f41ba2884d7fb416c3f53 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Wed, 21 Dec 2022 10:57:43 +0000 Subject: [PATCH 019/205] 8282398: EndingDotHostname.java test fails because SSL cert expired Backport-of: afd4bcbc1d1b2a8a1c29005878c8e06c662a1f6e --- .../net/ssl/ServerName/EndingDotHostname.java | 3 +- .../net/ssl/templates/SSLExampleCert.java | 369 ++++++++++-------- 2 files changed, 200 insertions(+), 172 deletions(-) diff --git a/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java index 20ebc144088..cac5147250f 100644 --- a/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java +++ b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java @@ -23,14 +23,13 @@ /** * @test - * @bug 8806542 + * @bug 8065422 * @summary Trailing dot in hostname causes TLS handshake to fail * @library /javax/net/ssl/templates * @run main/othervm -Djdk.net.hosts.file=hostsForExample EndingDotHostname */ import javax.net.ssl.*; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.*; diff --git a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java index bc8a1fdb2e9..657106a3d2d 100644 --- a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java +++ b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java @@ -34,197 +34,226 @@ import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; -// A template to use "www.example.com" as the server name. The caller should -// set a virtual hosts file with System Property, "jdk.net.hosts.file". This -// class will map the loopback address to "www.example.com", and write to -// the specified hosts file. +/* A template to use "www.example.com" as the server name. The caller should + set a virtual hosts file with System Property, "jdk.net.hosts.file". This + class will map the loopback address to "www.example.com", and write to + the specified hosts file. + + Commands used: + # Root CA + > openssl req -new -config openssl.cnf -out root-ca.csr -keyout private/root-ca.key -days 7300 -newkey rsa:2048 + > openssl ca -selfsign -config openssl.cnf -in root-ca.csr -out certs/root-ca.crt -extensions v3_ca + -keyfile private/root-ca.key -days 7300 + + # www.example.com + > openssl req -new -keyout private/example.key -out example.csr -days 7299 -newkey rsa:2048 + > openssl ca -config openssl.cnf -in example.csr -out certs/example.crt -extensions usr_cert + -keyfile private/root-ca.key -days 7299 + + # Client + > openssl req -new -keyout private/client.key -out client.csr -days 7299 -newkey rsa:2048 + > openssl ca -config openssl.cnf -in client.csr -out certs/client.crt -extensions usr_cert + -keyfile private/root-ca.key -days 7299 + + The key files should be in PKCS8 format: + > openssl pkcs8 -topk8 -inform PEM -outform pem -in private/example.key -out private/example-pkcs.key -nocrypt + */ public enum SSLExampleCert { // Version: 3 (0x2) - // Serial Number: 15223159159760931473 (0xd34386999cc8ca91) + // Serial Number: 4097 (0x1001) // Signature Algorithm: sha256WithRSAEncryption - // Issuer: C=US, ST=California, O=Example, OU=Test + // Issuer: C = US, ST = California, O = Example, OU = Test // Validity - // Not Before: Jan 26 04:50:29 2022 GMT - // Not After : Feb 25 04:50:29 2022 GMT - // Subject: C=US, ST=California, O=Example, OU=Test - // Public Key Algorithm: rsaEncryption + // Not Before: Feb 25 20:12:04 2022 GMT + // Not After : Feb 20 20:12:04 2042 GMT + // Subject: C = US, ST = California, O = Example, OU = Test + // Subject Public Key Info: + // Public Key Algorithm: rsaEncryption + // RSA Public-Key: (2048 bit) CA_RSA("RSA", """ - -----BEGIN CERTIFICATE----- - MIIDXDCCAkSgAwIBAgIJANNDhpmcyMqRMA0GCSqGSIb3DQEBCwUAMEMxCzAJBgNV - BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w - CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowQzEL - MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w - bGUxDTALBgNVBAsMBFRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB - AQDnOL2hB/GYyYziXo/ppxi7V1LfMMLeHt0lZbYlrmNxUlln4naI4B4Lkg75eb1Y - DgC7MZQd5nKijK9Dkq52Z2zLxaqBYnLxKJ36qKPqbtTL3I8mfUvVEeNIDN/8YTAt - suIEQi54dNtQVrB4YReMdnUq+xCKLAfEio4QLEQr7KtyCBXHZpM7RYRT0giQFvDU - 2kls9lFLeqKXgocnA7VpoL0V12hpxDeJoRm1szf0M5YXGJumQLaE5qM/+P2OOhw/ - T+xkupy2GF02s6FBXkH7NrFIjtuBSaVhSvCG/N7njWSn339thr3kiPEaCS4KSH5E - E6FEazxZQrTCbkQQ+v3y1pS1AgMBAAGjUzBRMA8GA1UdEwEB/wQFMAMBAf8wHQYD - VR0OBBYEFMFw2FWUvwZx3FJjm1G9TujCjAJSMB8GA1UdIwQYMBaAFMFw2FWUvwZx - 3FJjm1G9TujCjAJSMA0GCSqGSIb3DQEBCwUAA4IBAQCJsJjeYcT/GtKp64C+9KCi - Vgw/WnBZwbosSFZmqyID8aAnAxaGMkZ2B2pUZHTtCkBf6d9c0tuWb5yF8npV77sE - bZqeNg2GU7EvH3WPgPbQVT7+Qb+WbY3EEPgJHLytch61Rm/TRQ3OqD0B+Gs7YjAU - fEspmk1JJ6DWuXX13SHoGWgVnO7rXBnCJaGnGpONtggG4oO5hrwnMzQZKh5eZDhC - 7tkNPqVDoLv+QqnFk8q6k8hhxnVf+aw56IdsebN+9Bi+Lv6OQ+stKUo/u/RTW2z1 - odCOwc8DPF3jbacJsOmLhl3ciuWGOckx9KCvaBeTTgkPdLQH1gpNha2tnqgxUXmC - -----END CERTIFICATE-----""", + -----BEGIN CERTIFICATE----- + MIIDtDCCApygAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAxMjA0WhcNNDIwMjIwMjAxMjA0WjBDMQswCQYDVQQG + EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEQMA4GA1UEChMHRXhhbXBsZTENMAsG + A1UECxMEVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOGhEDj + lZ5R6o20kJdgrIRcY1he4qKLWQ4vU0thqAg4mEcKCZZn4/NL05UgJCFLwYaxMZZe + etb/WaTRvQpDDFh7AhsMR24m6zKKJVk9E/e/8ur7sGDIVq8hZOBTq85ZdxPj/zKW + wB1BR/RcY4DsGno1USlkV7TVeZc1qpJHTPImesevzH7zX8nhnFlf4TTQbpQt6RxU + cr+udWpMOyP9xMerIyp7jpPy79tIaGP2x7ryt2BB9FU4RwPk4DcdfOkmdS86md1c + GI9H5qM5rUzyqey0J8wMRLj+E0Vx0F1XELZeTtyulbIbhrBhu/KOXZG2zNIeK+2F + XxDlx9tD+bbcJfUCAwEAAaOBsTCBrjAdBgNVHQ4EFgQULjM9fwJnC3Tp1QYM8HNL + y60btl0wbAYDVR0jBGUwY4AULjM9fwJnC3Tp1QYM8HNLy60btl2hR6RFMEMxCzAJ + BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRAwDgYDVQQKEwdFeGFtcGxl + MQ0wCwYDVQQLEwRUZXN0ggIQATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE + AwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAR0Mk+2X/rr4kYYfHsQUIsROwDZSQhQr3 + QOeLc7fyTjkM96OHXN2dKVoOcpzgKi1goHW7lh8vVmKRQk2wfFqRZV9/kQBFK/gz + QtN5gp+pA8Wk912Uj5gD0loiPcRf5bDElvLnr2iwt4VdKkvGIYa9Eu9CYbkf1x3t + ahVLmrZLBkqvKxo4MG4KGYXkqtII3M6clM4ScFa/0rR1nGZOgZyqG7AMMHc01csA + oLlEZx2hUcpJbz+sfCGUWYaF2uKJvuWMNFbGSDhfs8pOMGgelMOHaKVtgOEfEASN + TSqzqn0vzjJ78Mi6mN7/6L/onDKzROxClw0hc6L+PIhIHftD1ckvVQ== + -----END CERTIFICATE-----""", """ - MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDnOL2hB/GYyYzi - Xo/ppxi7V1LfMMLeHt0lZbYlrmNxUlln4naI4B4Lkg75eb1YDgC7MZQd5nKijK9D - kq52Z2zLxaqBYnLxKJ36qKPqbtTL3I8mfUvVEeNIDN/8YTAtsuIEQi54dNtQVrB4 - YReMdnUq+xCKLAfEio4QLEQr7KtyCBXHZpM7RYRT0giQFvDU2kls9lFLeqKXgocn - A7VpoL0V12hpxDeJoRm1szf0M5YXGJumQLaE5qM/+P2OOhw/T+xkupy2GF02s6FB - XkH7NrFIjtuBSaVhSvCG/N7njWSn339thr3kiPEaCS4KSH5EE6FEazxZQrTCbkQQ - +v3y1pS1AgMBAAECggEBAJQAKLkTWZx/njMjbiCT+Wuo6H2+O21r+ge/BAk4h6R4 - nou1VEQmmHS1h+o992mOhP9NK867vDK5tFGfaRaW+vevzYTF3GbqpbxVB56+VG0s - /2AWoVx/96gdvZ1RJEKMFsm9BvvJaLwS0SAsnaMmC7d4Ps0Cg/JU8bv+aaBn/BGf - TWiofYWeUk6llco4kO9H2APxUVzlaUUU/cPAJqX7XktnhDCI9/esuVg7nVR0XxOF - GDrV/jdqSYmSbp4aTRXgI9nwxOmlKiGgevTrCUXl3/KaJxZekllVjushY1VVzgbY - K5R4bcN5MXMmFdgF9DTEW72RqEfg9iXqyhYbZp3Q/UECgYEA/yiaJd0w2HS22HSg - o4dJ072WbyR3qUqQmPbSUn9hBQTJAz1eX3cci8u4oawo/S+jN38b/DfpSg3eIMLB - vnXW3wZtodpJnFaweKd3yUaSF2r9vZRHJgfPfe67VbruEOF6BsCjTq/deGeNnGeH - /IDVn9WtSeRX/bv/s5YHvGaHGGUCgYEA5/vugmilOBq979EqksCG/7EQHSOoEukO - J/aunDyEwz+BMEHOEW7tDMUefdiSfnGXSW+ZTmpmvc+aLk37Xuo34jpugK5ayUFY - iYVgiqdnygGiBevBM2o0O/parQkAGEB8GPButrYItUzubUgXnuw+EdMiXGnpjJaK - S3dPYJEHvhECgYEAjqIIwV/LPUTJLWjMn30yBN43KLvu9ECNYiSfX6R6/I43O8tj - ZOQ1nePsutt9MkMd7xjr8OrkSxRDdnbITQqcaaGzSUW33mALV/btnCMJ6XNSklZA - C39UOuZn7D2JdQBF8V5gK81ddUAVxjeNqdXvFOEidGrj0R/1iVM10dhSbo0CgYBk - P8GtR02Gtj+4P/qW2m48VqbxALSkH2SHrpl8WMbCnVHVqcpETFxSNWjc11dPHwVS - rdBhS6fEhM9LDVYAiVTHBZs1LqN67ys0mpfCs18ts5Dx4BRohI+4D5NZzVbmJA+8 - s0IU4QtYVbt/LDVQ7yRPjZ7+sqJDp9ZxkEiUIXhoEQKBgQCPG2f8BhsCYNAOV60F - hJVjhDdf59Mia3B2J9SSnrg6Tl2rWB7GPP19TiSPFS6Sn95mWrMjZ2ZuOXtCYV4H - +hmu87AV2CXFhW5c588cajXMT92GFVMSXdE1OHRzDjhpH+/ll8SnmQa7sXmEV36+ - sawd7mwcB9IEi562wglADxBUCA== - """), + MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIn/uWtEzLDK8CAggA + MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIk7+JC4ErMDBIIEyA3yvNhMm/Oj + ZdkN0HSzPyLv9bOfUyyx4NA121kizZIq/FkUjn8pGxzU63rzMk2vU1hmp2/O3ymr + vmV7gzXRp4ULZCjFwn4cLxi9ieKgBOr9MmgTlRc1oZ9P/Y8eWhmjGxA2CU3fy7Kv + DyzftqAetV8YzTelk8xqxLrGevB16O3zDbFj4dcmG7a0i75kqlI8QyQklJ9uyE10 + SELWFlV6w+3GD82YrbR/8v4fE5KP/nAPbtN4h4C7MY3kJQL+apHr5B3Jst+6N62t + JzmxGS5z3ZVT3Bn3mxi8awo8/XS8s+ZOSnH6nHvz83NBUQwSkVbtujlg+yMD2jg4 + Nt3LWfLnF8Q6n4oAQ1ZP9KJyVIh8+PN12txIRoWq1pF74hJmbfVfiCSR/tMrw6lr + XqlkG1Mi7RmpTCz9ScTUBWY/dyScYFITenv/WE+UnfQ+DXBC+78lkmL36M0Rx/ip + S4O1Tgy/z/MIv1s+ZpAFsRRczlpo9lbVEMuSGEWWTIQJCRPFV8Y1NKHmWUgeZpl3 + 2YUjpHNyQt/a1s1h1g5w9+UNuABt/3cUUnlA7psueb6l4x6M92QFBOpe1xUDL51D + RpaipVl1luFWvE84hqgCIv8Kh9EbkAlclmK8CIOkMQAabk0GmhCfEdm+PCW61Cao + rfCMwZ9Bx6zAcXGRrvl0sK35z8C3r8wLftaS/5xF6RTJBy6XY2iiFW6D44qZDFbh + 0rWV8zDtCf2+OZtEvPkeUn3sjevDW78TM6F7HBjXAeIFrNyJGVe2CTlEJLoZi5pX + W1blhMJ93N1mLiDYisILANmJRBfGMt0tYE/pGcJRlkuqG0qylnqRojjL83CTQvFy + 46q/obR36enRDvCZPvQrX2dB7Vkgpkz/drZ6+avmKdQcTjY/ycCd3DclwexhgUoX + QDntZuJQLp7C4tFfHRy2uh4DOEjzMP6a/NQ3q7p6vc6BTNTFZRUAdyNwcEDIzSLM + nZSPFBiz+gukhtNSCO28kLc8OX1hYsSAMgzbImcMtAiQHG3bFAJ0cs0jF4U9VrJt + 4/97kiDBuCgGb2b5t0+uDqipE6G4B6494IGm5KoIPAPbXMJQstmuzjTJt95UTF+p + e60AnWIXcvEOouIIMzC7gH2g23St5Bo6NixfxcmVfkFa92TDlCTxEz5Z5mnma06k + Pao4Km1eJkYS/QaCDnCZs/yCAMhINUTTDd0/7Y9YE3Dmd5B1s2wOa+ovESSL3Mdv + dZoxh91QR+6hQuz3iYztC/BszMtATH8MznAoco0QFAhKi56Wppe+p1ATLWFMqk4W + elX9vtw5XLucKy5cMkQYh144SnrerlPJTAOGy0XXKunj8ceZfEN6zcS9Us9IN5aF + iENMFHjPsscrrKFhKypaMIn67PuIhVhw4PnGrWejr6TM1gUx+zOcRCwT+5ka2L7U + aqmgS8cDg5ZfAHcbig7No9kku/OSk+5QzkVKca2TZQHm++60oQTzRl3/NWiELO+e + Sl6r8i7dS0Kv3bB/AbLfIHtDgebxUh78qXMel/OUWd58ezxBS74rZ4AQTpYcdTbR + jKHploWi8h5yXYn/YdEZG1vW/zYseFNb7QKT5Cznucl8O/+lNZIOVw63Pq368dTD + tG1GZkIlwM+jlJjRew05YQ== + """), // Version: 3 (0x2) - // Serial Number: 14845986384898254166 (0xce0789f5ac256556) - // Signature Algorithm: sha1WithRSAEncryption - // Issuer: C=US, ST=California, O=Example, OU=Test + // Serial Number: 4098 (0x1002) + // Signature Algorithm: sha256WithRSAEncryption + // Issuer: C = US, ST = California, O = Example, OU = Test // Validity - // Not Before: Jan 26 04:50:29 2022 GMT - // Not After : Feb 25 04:50:29 2022 GMT - // Subject: C=US, ST=California, O=Example, OU=Test, CN=www.example.com - // Public Key Algorithm: rsaEncryption + // Not Before: Feb 25 20:31:29 2022 GMT + // Not After : Feb 19 20:31:29 2042 GMT + // Subject: C = US, ST = California, O = Example, OU = Test, CN = www.example.com + // Subject Public Key Info: + // Public Key Algorithm: rsaEncryption + // RSA Public-Key: (2048 bit) SERVER_EXAMPLE_RSA("RSA", """ - -----BEGIN CERTIFICATE----- - MIIDjDCCAnSgAwIBAgIJAM4HifWsJWVWMA0GCSqGSIb3DQEBBQUAMEMxCzAJBgNV - BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w - CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowXTEL - MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w - bGUxDTALBgNVBAsMBFRlc3QxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTCCASIw - DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK/i4bVSAF6/aFHyzrFAON8Uwn2a - Q9jFoAMowUkH6+PCexlt4wCOEMVH9IQPa1yzeVlkYRqHggz3i6aVYvd27Q+c6vOF - FuRegWdJusyEuoXd5nwxSGiZZMLmFQswODSPmucroCG+Tq9RKY5oEKiRP8tUDqyn - eE52PaeSR2Q6mng7BM5Llj7amVgimO3jlH2AWLLpHNTkc3j/M1QrLFV2PqN4dpxT - OeFuVWzpfTWJSH+9Kq4u/zBMbYl8ON7DSgJAzc2BOw8VPIYIK6JIw6IDbLn4dIQf - GikdgHKB2K6EDOc9LuX6UqQQODDFU88muAyPgpGfUQjxKZeUoTqoAFyisI0CAwEA - AaNpMGcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUQqf/4nqluVMZ8huD3I5FNqLXTqAw - HwYDVR0jBBgwFoAUwXDYVZS/BnHcUmObUb1O6MKMAlIwGgYDVR0RBBMwEYIPd3d3 - LmV4YW1wbGUuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQBl8FJD98fJh/0KY+3LtZDW - CQZDeBSfnpq4milrvHH+gcOCaKYlB9702tAQ6rL1c1dLz/Lpw1x7EYvO8XIwXMRc - DZghf8EJ6wMpZbLVLAQLCTggiB65XPwmhUoMvgVRVLYoXT3ozmNPt7P+ZURisqem - 0/xVVfxqmHw9Hb4DNlc7oZDgOK7IrqriaBK6Amsu3m2eThsvkwTdJfeFG3ZdV6x5 - mbaGZDMt/wgWIqyq5CZNpXPaFRH7KM4zhcoqXvFAoq9jxWOuBkJUUx5EHaxGhhPw - SMgE1yl4O+N7GJmF/WMR5zp2LGKMqJ3vwLPv6QNkUmLwB5ZLYJ8E2dpj6DjQWa7X - -----END CERTIFICATE-----""", + -----BEGIN CERTIFICATE----- + MIIDaTCCAlGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAzMTI5WhcNNDIwMjE5MjAzMTI5WjBdMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG + A1UECwwEVGVzdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMIIBIjANBgkqhkiG + 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3crcRzecIV08Muh6kA0CuVKnPkU2bLC+6bpV + 7/iBZ4D3qMwO8Q02+gP71pPNoAQ1nsifxR4k9mBVYOjar35RVpuFmLRRVMargrxg + 4WWDfVgLMhOeCy8+Tl4Mp/yRL3nkr0MJd57RCOPcPE84J/1Crq1Luy2+hsXSj25L + VJKx2o6LE0tfwPWnufdNUHzHRuNoBR83OpqIT0uXH15THZS+0ZcQwrJMcKYe4JWl + 6oXWcsWbtTG+r7QLIRKck2IG7jjHFpE83Q6Iv2HkhctgGZofwSTZyMmJ8eClovva + WFLDaLL2WuI3NwZM//knjMyfsEWtWsILXayCn5NTT74ClQjWQQIDAQABo00wSzAJ + BgNVHRMEAjAAMB0GA1UdDgQWBBQ9nPjenO4PMLtMTBddNiIDsPywjzAfBgNVHSME + GDAWgBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEAVOvM + fMDOxOCkWB244cx7J+f2qZU6/1qGlJUiL0WRLRj1XEmB8AYSZEb6Os1suF8sotka + nA9Aw1SFA/wNyrSKazXNlOKo0In1mu/OjHU7n6XYVAyDmFGziYY8zTqG1h8ZPrI7 + oAkNgnNDwmwy7uCAvMj+Q4QQ0Q4YxTHV/i3X1HuEwThRgz9cJGdDRIAsimRHDSDO + 5hsIJo6VASz0ISrYMxNZQ1og+XktdNssPK616bPf+APwXXnsWSuGkIdGDU059DII + cTSsLTbWkTWDXAAQo+sfDZUrvqopCK000eoywEmPQrTf7O8oAQdRvTsyxwMvOONd + EWQ9pDW9+RC8l5DtRA== + -----END CERTIFICATE-----""", - """ - MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCv4uG1UgBev2hR - 8s6xQDjfFMJ9mkPYxaADKMFJB+vjwnsZbeMAjhDFR/SED2tcs3lZZGEah4IM94um - lWL3du0PnOrzhRbkXoFnSbrMhLqF3eZ8MUhomWTC5hULMDg0j5rnK6Ahvk6vUSmO - aBCokT/LVA6sp3hOdj2nkkdkOpp4OwTOS5Y+2plYIpjt45R9gFiy6RzU5HN4/zNU - KyxVdj6jeHacUznhblVs6X01iUh/vSquLv8wTG2JfDjew0oCQM3NgTsPFTyGCCui - SMOiA2y5+HSEHxopHYBygdiuhAznPS7l+lKkEDgwxVPPJrgMj4KRn1EI8SmXlKE6 - qABcorCNAgMBAAECggEBAJb2SvfP7BVmf+lmV9V249lE/jHECFu0M8TCZDOEowiX - 0gRfdqjxRp+tRMdcXK/yM0Nwjo+wowTyK2DNc2YnIw11h4uAPcfA/ZxjgfssKNPh - Q4Rw4E826W8HACTcPEGQyEmF/ik4KFz9coeR9kpYcMLZ4MZ77xyZDA4Z1UDHs/Fg - egrd4k35fxIFOavsjNuekMIjZlyQ2xU1a11QDBrZAu/pjITXXulg4jCxLbeNOOPs - hH+Sx+jnsVV7qIBNwulzxEdpb3+NkWIMmOQK4HOSeHgjRVvSXXBPgYadMaP/Bzvx - AwJ9WeLZg7KWHE03aOc7CSMoyHfmhXx3gD8icGpSq8ECgYEA3TWGBSgny/wket+V - 65ldWjp4NOKHbLPtBdL9ygIO+1bGfLl5srCxUWHBYdcWCXKuB5ALCBu0hMY+TlwF - s/BzZmvVW7RLAEZZ3Q5HpawDlr9j8Kenm4X2Mqh0MSkmwIDRDHF8jRXAvWIzcBiS - +rPZm2CMZpznUSE4X+GrvTSCBbkCgYEAy4yJ58wNUavj/tR8KySn5ygPABFZ1Uoy - pIyabm18Oe3gCl5UulBskoN0WreTKnA4r9jGlnrgeuu5WfMK53AZKbC+YduZixW4 - QFuJBSMbFCBDt4nkhkMMR7VcV4jIqaOK7qNrs7ubGTZhsG8wj6/WWdCp3Avnx1rS - WCCoYNhAK3UCgYADaLnCBpZmbGJbimqTEPABXflQR1Vy9WrnthK3NETq1rGEZo9b - k6GH8Yu7aEcsqhnIgA3LeDHWAgAf0Qc9eK0unObS3Ppy7KKh54BvKzF690QhB1Rr - 7yqWKUZxI4M3YETYfj8/JWCtCoBkb9yEBJWL8Xb4dd6Sv4JQ5/dvmQmP8QKBgBX+ - 5+Aeksnik060U36uBV7bW1OcjGKaFALoFsAcILJ53B4Ct5Eyo6jpf6dV8xdA7T9D - Y6JbQOrHkk4AD4uW94Ej0k7s1hjLjg+WVKYzdvejzO2GfyVrFWaiWIo1A8ohHCBR - lI/llAsTb1cLjOnaDIXEILbgqnlGfTh8vvVIKRcJAoGALF6Q1Ca2GIx4kJZ2/Az5 - qx89q95wQoWVHcJCA91g/GKg/bD0ZJMWEhhVH3QcnDOU7afRGKOPGdSSBdPQnspQ - 1OPpPjA3U5Mffy5PJ2bHTpPBeeHOzDO4Jt073zK3N81QovJzS8COoOwuGdcocURH - mFMnEtK7d+EK1C1NTWDyNzU= - """), + """ + MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDdytxHN5whXTwy + 6HqQDQK5Uqc+RTZssL7pulXv+IFngPeozA7xDTb6A/vWk82gBDWeyJ/FHiT2YFVg + 6NqvflFWm4WYtFFUxquCvGDhZYN9WAsyE54LLz5OXgyn/JEveeSvQwl3ntEI49w8 + Tzgn/UKurUu7Lb6GxdKPbktUkrHajosTS1/A9ae5901QfMdG42gFHzc6mohPS5cf + XlMdlL7RlxDCskxwph7glaXqhdZyxZu1Mb6vtAshEpyTYgbuOMcWkTzdDoi/YeSF + y2AZmh/BJNnIyYnx4KWi+9pYUsNosvZa4jc3Bkz/+SeMzJ+wRa1awgtdrIKfk1NP + vgKVCNZBAgMBAAECggEBAMUMAtJe7J6Tx/TuqF0swfvGHAHt2eGM0cCzpMATh1xe + rylPSgMNG4faXDcSj4AX3U+ZrKCjHHGruo7jsc5yqm8IsxOtOAjajOwU0vnNh5mn + zCKMXUBQk8lqM1JXyOFmKS8wnsug1NRSJIuMUjbtAf5QxlSg2oHAZUa61cBoqAyk + KXbw9uBYnM4n8WGXdax/LLPuonjnz2Sc35CC1LhRAF/K7oyjg7KvScnphIFRaLiU + X4tFH0nLpcao5de0fP5eUEkbUZ3hE6MEZvOsxn5CFkjH2VdtZ9D5dc3ArV3UMe26 + +3swdenriYZ73HNJDiLAdeIVh9IrGVxhH9UowF9psIUCgYEA/Ldlx4vTTlM7URFn + luqK7D8WH9x4JiCLEGxU80nJxxIgF8eqhOFzsQemytTrf4o1xAkyyPIweHzwApCA + lBdwC4Mc44DjoLFVdTET9hEq7E/UK81znc0mD4v8Hz2JI6h3f2sQrcEAPBvjBwtc + TpS9WlSBKSO3NOb3Hlucq7COVKcCgYEA4KyZ+dOyKVLyGjd0g22v4YW7VC016Hql + uQ7SN1vuI3zQMa2rZfEv5z2L7olJKrDFcmqk8W1tfElrMaSsuohm8khhx0lPtHMw + 4Su/tci/3rEUl+DPrQExdjrrDXCqpUunOAlMP9qElsNBGdkrQ6QlMnSVVi2v8Vf1 + f86Mey2UEtcCgYEAqcOlmqPigfZFnZLcjLPoOQW0HhkjmTE5WgH8GybRZmpVpsPZ + V8R/zEeAkzbvMFEvBw7Kz9RqHTaIoKBjz5fjC8i7ClVWFGesKbqbVyx3MiH6PKaa + aUIbtEvsRSw4SPztsWnB3YcOWlK9csj97Efc36Zu0a0NcHtLPFh8aZWEN3cCgYEA + oQFv8oWPlmeXkcwN1iWjtfT1EtS3XhuOaXjCkuNxW8MVG5S+UHawAoGrpsyBP3Og + e2cLPuxRWpDunYvKMH6Rb60JTRwvXzxxWdvVLbtoLHkwLcrwaKWDQZvlWCNWVtBJ + TDH1j4jUHYpdO93SUE3wTiEX58Mj48tJ5kYpjBhUlc8CgYEA7PG3ORGqZtfCiNmj + CxvPtQiFC+ogf+v8cMQtrKVTgpnI2pxzG+cSXYvL4cnyY2JnwqarWorUic8JU2e2 + EhW53PWUg7VpITlLsqOpATIDiviFAN4qOOxgDt5v0C1PyB3aXe2B5VA3IgczssyR + OLy7p/DhOpu2bqnpKyIkAuzZgFc= + """), // Version: 3 (0x2) - // Serial Number: 14845986384898254167 (0xce0789f5ac256557) - // Signature Algorithm: sha1WithRSAEncryption - // Issuer: C=US, ST=California, O=Example, OU=Test + // Serial Number: 4099 (0x1003) + // Signature Algorithm: sha256WithRSAEncryption + // Issuer: C = US, ST = California, O = Example, OU = Test // Validity - // Not Before: Jan 26 04:50:29 2022 GMT - // Not After : Feb 25 04:50:29 2022 GMT - // Subject: C=US, ST=California, O=Example, OU=Test, CN=Do-Not-Reply - // Public Key Algorithm: rsaEncryption + // Not Before: Feb 25 20:33:59 2022 GMT + // Not After : Feb 19 20:33:59 2042 GMT + // Subject: C = US, ST = California, O = Example, OU = Test, CN = Do-Not-Reply + // Subject Public Key Info: + // Public Key Algorithm: rsaEncryption + // RSA Public-Key: (2048 bit) CLIENT_EXAMPLE_RSA("RSA", """ - -----BEGIN CERTIFICATE----- - MIIDkjCCAnqgAwIBAgIJAM4HifWsJWVXMA0GCSqGSIb3DQEBBQUAMEMxCzAJBgNV - BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRAwDgYDVQQKDAdFeGFtcGxlMQ0w - CwYDVQQLDARUZXN0MB4XDTIyMDEyNjA0NTAyOVoXDTIyMDIyNTA0NTAyOVowWjEL - MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEDAOBgNVBAoMB0V4YW1w - bGUxDTALBgNVBAsMBFRlc3QxFTATBgNVBAMMDERvLU5vdC1SZXBseTCCASIwDQYJ - KoZIhvcNAQEBBQADggEPADCCAQoCggEBAODbsCteHcAg3dktUO5fiPTytIahKZMg - U2h6h0+BT803tYcdN6WDHnLNlU/3iFnBMpyTwzWhYIftC9c/TIkXBAGfWl4HHQgc - x08NHPms0E+GF6CDthvHERSvRCBrIyVna0KIZPemBzUfeBeNdiqwsLvg+C5dqWu5 - YcILvL6GzTMvdMwJeEX+c2ZYHibqd8aZydWsT+IPVZnueDX6KTOnYvexLFIoid2a - 62FavnMWiPKnICertDDg+gHlN2XceW3tlYQwO+HMig4DH3u2x0SApOoM3y8k29Ew - Fn6wquSRomcbDiI8SEOeaBFenu6W0g24iaxIZfqEM52kPbQFdzqg+O0CAwEAAaNy - MHAwCQYDVR0TBAIwADAdBgNVHQ4EFgQU0t+I5iAfPq6C/I2CSvTKHGK6+2kwHwYD - VR0jBBgwFoAUwXDYVZS/BnHcUmObUb1O6MKMAlIwIwYDVR0RBBwwGoEYZG8tbm90 - LXJlcGx5QGV4YW1wbGUuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQBqWk35XXpb3L+N - 7kPlNmSlhfamenVOVYxPBq/tSFpl728CV0OrGAy79awEFDvzhpbBg9Mz7HS/a7ax - f+lBbsAt1maWlsVSsaaJrmy3znl9CZiIg+ykZ5ZzLS5FkIbQ6LkzvxYZJ1JYCzXm - P/5+rbQyIvQaDGL23PmE7AB2Q0q+imt4b9HKs+SnI4XERyj8OF/kseRtILtP2ltV - r+3XgcBxwyU17CLwsHrjnQ8/1eGovBKzGAfUXeHBdzOuD3ZemjnqwlzQTf2TAkBP - OuMc8gr2Umc5tMtdiRUFPODO7DG7vB7LKEsJGKWLUtGbR+3S55lIcCF5NFZ//TNZ - 4x2GPOJ+ - -----END CERTIFICATE-----""", + -----BEGIN CERTIFICATE----- + MIIDZjCCAk6gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAzMzU5WhcNNDIwMjE5MjAzMzU5WjBaMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG + A1UECwwEVGVzdDEVMBMGA1UEAwwMRG8tTm90LVJlcGx5MIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEA2yJgm3Lthr+97vdEWTb4zaNuLTa/DkCXdmVNIQk9 + kVn2hjZrPc+JghBCaWpohGVTQ+zxplIJXk+QVZ0ePEimE7ahBClz4MlAgMpt1uxy + mYYUAsSZDCaFUI9Cpx1f0BiSWu330196K/AfRIoT+/SOZucnpbepxyrt+Az5SKrH + TJR/OSqeX4XKGPoRI96pKxDOV8pY5/I9h9yKGuxfufbpOdVODngVLcMKgBAkiD+2 + sguEHM+iGLx970+W6yycu1dFY1CAgWLUF3evUxe8avwePgx7lTFXnNueYt96Ny9v + L1o/WzoBe3z1mTl5Qb//3tYbXn8vdiDYm0dT8wImpDbpvwIDAQABo00wSzAJBgNV + HRMEAjAAMB0GA1UdDgQWBBSXqW/B1BVjNgowSwa3MBiHMkzp6zAfBgNVHSMEGDAW + gBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEABIMAjT5T + lZDV/1wmdKCyJQJ7WUjA44N5/yBGtEmpAJ0VM7/COnk8lqiYxrk50wK7lt0tiklX + 4aLqbAgnDc27z9AQGHOqB69dZprGQT9PsTByjK6i7KPGs30ygyND41j0rju/GM2e + 3xprZbusODENRyL196QV4ai0WVe1hEvv0wTMIcnXYmZHMP8ArdVRHWaDQF6zW0Mh + QbFqklt5W0ZIl2ZmC8z7z2Z6jv/BYyDo3U96LfdCWsEKxSKiX/PGHqZu4D3A4VSE + 0+fE7cX61kgRdGvZJgFjtYxtfkXd1HlyJ48Dqilzl+rvgvR5XA68zijjN0khPhml + wZhPIOCIaWMZYw== + -----END CERTIFICATE-----""", - """ - MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDg27ArXh3AIN3Z - LVDuX4j08rSGoSmTIFNoeodPgU/NN7WHHTelgx5yzZVP94hZwTKck8M1oWCH7QvX - P0yJFwQBn1peBx0IHMdPDRz5rNBPhhegg7YbxxEUr0QgayMlZ2tCiGT3pgc1H3gX - jXYqsLC74PguXalruWHCC7y+hs0zL3TMCXhF/nNmWB4m6nfGmcnVrE/iD1WZ7ng1 - +ikzp2L3sSxSKIndmuthWr5zFojypyAnq7Qw4PoB5Tdl3Hlt7ZWEMDvhzIoOAx97 - tsdEgKTqDN8vJNvRMBZ+sKrkkaJnGw4iPEhDnmgRXp7ultINuImsSGX6hDOdpD20 - BXc6oPjtAgMBAAECggEAKjqX900RoUeK4oKUNHBUtEvwg2g4+pyTjYeVaeULK6tO - uDVQghEB4uWhKQd/3/tcmfNWMfhAvMZT9vS4Vvavle5rdkU3upJNDBeWXX2LEaRJ - Q6f4x3a3Sn8v+DamvxuRFUmwTKItsFhcoW+7xYCxcFdrxKlqbATAy0SRCecfGoFw - 9pAsFIgIqLGQtV9V9fZWKdXIfLkH3venNImHt0n5pYadl4kZu0gNCmOGRO1MqB51 - bdAck3dBg22TE5+sZBIZmCjBAEbrc2RUQu5mAoDs8eeenxBlFYszWZxqM8BkJL5e - SqQkbc18E8Gzdx52xEx6BCLTq0MITKliKX4B2tsQsQKBgQD1DIvt13yg9LlyoiAb - Fc1zzKZQBPRgDUJCGzCPeC6AqbPUjoxvFAHxGNgmJXqAXwsqcs88qlSGAjk6ANAx - fHWUQ3UmkZjGvV0ru3rIPcXvS7isjzm/cbq1YZua6+ohFl4+hojc/iyUrOaCd9uY - V2zwrr+A0JJrlev72niEuAtEmwKBgQDq6CaLP79dHqAOIV43+SyX7KdwNkMMWIR7 - El6E/74V0IWOYWFXLmV4sX6BKi0ZBTFZ3wKwMTDqQBYD2/a7gq43HjzuWu+2dFhA - pCQumMOKNqcNS9NldqoxAiGLxC+JMhGGyf3RO0Ey9gdPnQuje3133Wce8WWaHHv2 - lD5BcmzdFwKBgQCCeca7wiPy07s2ZUqxAT/eq5XWP30a85RW/IEzsusXyMQepjPy - JPYPuInGbeg3F+QrGuxrQco1fFOaJbq0zq8QXYawHY/6KfPFCFMM8Y9FpczT3IME - A3tFfo5Kw9hq+6z8n8eZ26BDHXiy+Tysdchksrb20JdVv4LiG+ZVzGT7hwKBgG+b - Bp0IF4JFh6PPBLWxRBeWT2MH1Mkr0R2r945W91fj72BbMeU63Oj/42u4vx5xEiZx - xxQw+t2AvzTsMAicqOr1CdvxBoz4L+neUnZ1DApBtxKhIPnG7EtGiOuftToIuL0C - gP4EmhB9RbH0mk/83vqxDUptRGl4+QiJHB76H3DXAoGASGT6tfs1/92rGqe0COm3 - aHpelvW7Wwr9AuBumE7/ur/JWAAiM4pm6w7m5H5duYZtG3eWz1s+jvjy8jIPBIkN - RA2DoneC2J/tsRRNFBqZrOWon5Jv4dc9R79qR13B/Oqu8H6FYSB2oDyh67Csud3q - PRrz4o7UKM+HQ/obr1rUYqM= - """); + """ + MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbImCbcu2Gv73u + 90RZNvjNo24tNr8OQJd2ZU0hCT2RWfaGNms9z4mCEEJpamiEZVND7PGmUgleT5BV + nR48SKYTtqEEKXPgyUCAym3W7HKZhhQCxJkMJoVQj0KnHV/QGJJa7ffTX3or8B9E + ihP79I5m5yelt6nHKu34DPlIqsdMlH85Kp5fhcoY+hEj3qkrEM5Xyljn8j2H3Ioa + 7F+59uk51U4OeBUtwwqAECSIP7ayC4Qcz6IYvH3vT5brLJy7V0VjUICBYtQXd69T + F7xq/B4+DHuVMVec255i33o3L28vWj9bOgF7fPWZOXlBv//e1htefy92INibR1Pz + AiakNum/AgMBAAECggEAW0WxWW4AMyzwDnWdWU+FSBm3TUvNPkF3FNBS1NzFcSI4 + hWRrPJ6R1sOw9blleSe/C77IVA89abPYGWDM9C0KR5G89T/SzSDmJf6qy2dGwF1R + PmnmmWH+CzTwfSzF+KYTZ55QqBDPkTd9vo2Ij1woaAIFyId8RsHBxpyYxESlqGY4 + C6IzEqxFQ0obHXasNR+dP4iOWS4ONhxeUHixcrDHxbmoqmHt0WuJwXhlOjxHgr+i + lUPTe5y+Y2B1gVNYrN4KlDTJqJ6lu4n6MFQ46jhfddzTk3uiEOTVWK6nE8Cf0NM7 + djTzTcR8xAVpoY5XDlk0aBfEd8Np7TLSjV4vU3J04QKBgQD6scazH/H9Yu9ZbR7w + EeN/k7uDDlgahWg8/93syzdFtSNIRGvdalNMhTfM/zXaM/Cl63gvZilWxC+56Uvg + 6QC+rBUwzZrm7ryb6hT6Zyoo4w72bw3jGOJ3e2/bclSLrAcJnL/1Gq87J3CS16wl + NIHrlOlY8orToEdki+6HaagyEQKBgQDfxZz4Uqsa+jDO/rEm959+nz2RkaXYu1Ld + DhYONxmlw69/BbwzOvzr88qKNbd+b+oIK8kpm7Lvpc2/cuqItTFdehmw+tGhMWYo + XizKCeKeCByFTjXI2/PEPUHMy0D8M68Tx/Hq0NbIYqCyzkaamHhXpuJGftxGfd3/ + U0NB4WGOzwKBgQDgnyN7YfcwY1I0XUqoLk8aA2Oy5MpaUQh6B4RwZBENO2T2np/L + TzZ9zKuX2WAGOB26fMY+KhqGLNjaike7qOpK7eM6zC6sFmMWjGHpj0A+TFwewJi/ + z48zIX2zMbjBQQ05NqLkWdmCdi8u02HiIC78x3thgEiVn/n4BE1gNXJIEQKBgEdr + dfcXw36/vZZDWd07CU/LmUX9u3YaC498MHPnCCuM8lVTSkb7m7/fNpS4IlGbfJGR + EApUpF6yh6GEFvD9C71u/AYtd3zAHH/j1t3BG/AeXKP7W1U5RmsqtfacJKiaAlYI + 6eBtOTAJsop/Ja+v3DD1laC0Wq+w+orEU2ISgiWnAoGBAK9/9m3RCYPNYzS/PQ2B + AgE2FQRuY8FXxHegZo2tBBwIojPeVHO1OoThYVNgiQfW9k27dFkRwXVAtt6Jqgax + fvOby8rWRStXH2qHVyvHicceL7iXs6v2bX20Szsy44eMkoFfAImea6ZdErLdVWvI + fxlYpTIVpBt3Nu2BRJn28ili + """); final String keyAlgo; final String certStr; From 23aeca9be6ee296aa96dddd9dc16b5a761ff91d5 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 21 Dec 2022 12:56:13 +0000 Subject: [PATCH 020/205] 8296611: Problemlist several sun/security tests until JDK-8295343 is resolved Backport-of: d6e2d0d03d2161f934474fa1d4299513d14cb9c5 --- test/jdk/ProblemList.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 835bc07ae25..a1eabaab95d 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -647,6 +647,13 @@ sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 gene sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all +sun/security/tools/keytool/NssTest.java 8295343 linux-all +sun/security/pkcs11/Signature/TestRSAKeyLength.java 8295343 linux-all +sun/security/pkcs11/rsa/TestSignatures.java 8295343 linux-all +sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8295343 linux-all +sun/security/pkcs11/rsa/TestKeyFactory.java 8295343 linux-all +sun/security/pkcs11/KeyStore/Basic.java 8295343 linux-all + ############################################################################ # jdk_sound From 3e65a7c5d35b82e14b549ee8ea4bf3a49cfec2e3 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Thu, 22 Dec 2022 08:01:50 +0000 Subject: [PATCH 021/205] 8282511: Use fixed certificate validation date in SSLExampleCert template Backport-of: 268fa693188b685de6289927ee5a1e99473a50f6 --- .../net/ssl/ServerName/EndingDotHostname.java | 3 +- .../net/ssl/templates/SSLExampleCert.java | 394 ++++++++++-------- 2 files changed, 216 insertions(+), 181 deletions(-) diff --git a/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java index cac5147250f..bac110aa033 100644 --- a/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java +++ b/test/jdk/javax/net/ssl/ServerName/EndingDotHostname.java @@ -26,7 +26,8 @@ * @bug 8065422 * @summary Trailing dot in hostname causes TLS handshake to fail * @library /javax/net/ssl/templates - * @run main/othervm -Djdk.net.hosts.file=hostsForExample EndingDotHostname + * @run main/othervm --add-opens java.base/sun.security.ssl=ALL-UNNAMED + * -Djdk.net.hosts.file=hostsForExample EndingDotHostname */ import javax.net.ssl.*; diff --git a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java index 657106a3d2d..0b82aed3b7b 100644 --- a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java +++ b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java @@ -21,42 +21,53 @@ * questions. */ -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.*; import java.io.*; +import java.lang.reflect.Field; import java.net.InetAddress; import java.security.KeyFactory; import java.security.KeyStore; import java.security.PrivateKey; import java.security.cert.Certificate; import java.security.cert.CertificateFactory; +import java.security.cert.PKIXBuilderParameters; import java.security.spec.PKCS8EncodedKeySpec; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Base64; +import java.util.Date; -/* A template to use "www.example.com" as the server name. The caller should - set a virtual hosts file with System Property, "jdk.net.hosts.file". This - class will map the loopback address to "www.example.com", and write to - the specified hosts file. - - Commands used: - # Root CA - > openssl req -new -config openssl.cnf -out root-ca.csr -keyout private/root-ca.key -days 7300 -newkey rsa:2048 - > openssl ca -selfsign -config openssl.cnf -in root-ca.csr -out certs/root-ca.crt -extensions v3_ca - -keyfile private/root-ca.key -days 7300 - - # www.example.com - > openssl req -new -keyout private/example.key -out example.csr -days 7299 -newkey rsa:2048 - > openssl ca -config openssl.cnf -in example.csr -out certs/example.crt -extensions usr_cert - -keyfile private/root-ca.key -days 7299 - - # Client - > openssl req -new -keyout private/client.key -out client.csr -days 7299 -newkey rsa:2048 - > openssl ca -config openssl.cnf -in client.csr -out certs/client.crt -extensions usr_cert - -keyfile private/root-ca.key -days 7299 - - The key files should be in PKCS8 format: - > openssl pkcs8 -topk8 -inform PEM -outform pem -in private/example.key -out private/example-pkcs.key -nocrypt +/** + * A template to use "www.example.com" as the server name. The caller should + * set a virtual hosts file with System Property, "jdk.net.hosts.file". This + * class will map the loopback address to "www.example.com", and write to + * the specified hosts file. + * + * Commands used: + * # Root CA + * > openssl req -new -config openssl.cnf -out root-ca.csr \ + * -keyout private/root-ca.key -days 7300 -newkey rsa:2048 + * > openssl ca -selfsign -config openssl.cnf -in root-ca.csr \ + * -out certs/root-ca.crt -extensions v3_ca + * -keyfile private/root-ca.key -days 7300 + * + * # www.example.com + * > openssl req -new -keyout private/example.key \ + * -out example.csr -days 7299 -newkey rsa:2048 + * > openssl ca -config openssl.cnf -in example.csr \ + * -out certs/example.crt -extensions usr_cert + * -keyfile private/root-ca.key -days 7299 + * + * # Client + * > openssl req -new -keyout private/client.key \ + * -out client.csr -days 7299 -newkey rsa:2048 + * > openssl ca -config openssl.cnf -in client.csr \ + * -out certs/client.crt -extensions usr_cert + * -keyfile private/root-ca.key -days 7299 + * + * The key files should be in PKCS8 format: + * > openssl pkcs8 -topk8 -inform PEM -outform pem \ + * -in private/example.key -out private/example-pkcs.key -nocrypt */ public enum SSLExampleCert { // Version: 3 (0x2) @@ -71,60 +82,60 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) CA_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDtDCCApygAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAxMjA0WhcNNDIwMjIwMjAxMjA0WjBDMQswCQYDVQQG - EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEQMA4GA1UEChMHRXhhbXBsZTENMAsG - A1UECxMEVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOGhEDj - lZ5R6o20kJdgrIRcY1he4qKLWQ4vU0thqAg4mEcKCZZn4/NL05UgJCFLwYaxMZZe - etb/WaTRvQpDDFh7AhsMR24m6zKKJVk9E/e/8ur7sGDIVq8hZOBTq85ZdxPj/zKW - wB1BR/RcY4DsGno1USlkV7TVeZc1qpJHTPImesevzH7zX8nhnFlf4TTQbpQt6RxU - cr+udWpMOyP9xMerIyp7jpPy79tIaGP2x7ryt2BB9FU4RwPk4DcdfOkmdS86md1c - GI9H5qM5rUzyqey0J8wMRLj+E0Vx0F1XELZeTtyulbIbhrBhu/KOXZG2zNIeK+2F - XxDlx9tD+bbcJfUCAwEAAaOBsTCBrjAdBgNVHQ4EFgQULjM9fwJnC3Tp1QYM8HNL - y60btl0wbAYDVR0jBGUwY4AULjM9fwJnC3Tp1QYM8HNLy60btl2hR6RFMEMxCzAJ - BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRAwDgYDVQQKEwdFeGFtcGxl - MQ0wCwYDVQQLEwRUZXN0ggIQATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE - AwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAR0Mk+2X/rr4kYYfHsQUIsROwDZSQhQr3 - QOeLc7fyTjkM96OHXN2dKVoOcpzgKi1goHW7lh8vVmKRQk2wfFqRZV9/kQBFK/gz - QtN5gp+pA8Wk912Uj5gD0loiPcRf5bDElvLnr2iwt4VdKkvGIYa9Eu9CYbkf1x3t - ahVLmrZLBkqvKxo4MG4KGYXkqtII3M6clM4ScFa/0rR1nGZOgZyqG7AMMHc01csA - oLlEZx2hUcpJbz+sfCGUWYaF2uKJvuWMNFbGSDhfs8pOMGgelMOHaKVtgOEfEASN - TSqzqn0vzjJ78Mi6mN7/6L/onDKzROxClw0hc6L+PIhIHftD1ckvVQ== - -----END CERTIFICATE-----""", - - """ - MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIn/uWtEzLDK8CAggA - MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIk7+JC4ErMDBIIEyA3yvNhMm/Oj - ZdkN0HSzPyLv9bOfUyyx4NA121kizZIq/FkUjn8pGxzU63rzMk2vU1hmp2/O3ymr - vmV7gzXRp4ULZCjFwn4cLxi9ieKgBOr9MmgTlRc1oZ9P/Y8eWhmjGxA2CU3fy7Kv - DyzftqAetV8YzTelk8xqxLrGevB16O3zDbFj4dcmG7a0i75kqlI8QyQklJ9uyE10 - SELWFlV6w+3GD82YrbR/8v4fE5KP/nAPbtN4h4C7MY3kJQL+apHr5B3Jst+6N62t - JzmxGS5z3ZVT3Bn3mxi8awo8/XS8s+ZOSnH6nHvz83NBUQwSkVbtujlg+yMD2jg4 - Nt3LWfLnF8Q6n4oAQ1ZP9KJyVIh8+PN12txIRoWq1pF74hJmbfVfiCSR/tMrw6lr - XqlkG1Mi7RmpTCz9ScTUBWY/dyScYFITenv/WE+UnfQ+DXBC+78lkmL36M0Rx/ip - S4O1Tgy/z/MIv1s+ZpAFsRRczlpo9lbVEMuSGEWWTIQJCRPFV8Y1NKHmWUgeZpl3 - 2YUjpHNyQt/a1s1h1g5w9+UNuABt/3cUUnlA7psueb6l4x6M92QFBOpe1xUDL51D - RpaipVl1luFWvE84hqgCIv8Kh9EbkAlclmK8CIOkMQAabk0GmhCfEdm+PCW61Cao - rfCMwZ9Bx6zAcXGRrvl0sK35z8C3r8wLftaS/5xF6RTJBy6XY2iiFW6D44qZDFbh - 0rWV8zDtCf2+OZtEvPkeUn3sjevDW78TM6F7HBjXAeIFrNyJGVe2CTlEJLoZi5pX - W1blhMJ93N1mLiDYisILANmJRBfGMt0tYE/pGcJRlkuqG0qylnqRojjL83CTQvFy - 46q/obR36enRDvCZPvQrX2dB7Vkgpkz/drZ6+avmKdQcTjY/ycCd3DclwexhgUoX - QDntZuJQLp7C4tFfHRy2uh4DOEjzMP6a/NQ3q7p6vc6BTNTFZRUAdyNwcEDIzSLM - nZSPFBiz+gukhtNSCO28kLc8OX1hYsSAMgzbImcMtAiQHG3bFAJ0cs0jF4U9VrJt - 4/97kiDBuCgGb2b5t0+uDqipE6G4B6494IGm5KoIPAPbXMJQstmuzjTJt95UTF+p - e60AnWIXcvEOouIIMzC7gH2g23St5Bo6NixfxcmVfkFa92TDlCTxEz5Z5mnma06k - Pao4Km1eJkYS/QaCDnCZs/yCAMhINUTTDd0/7Y9YE3Dmd5B1s2wOa+ovESSL3Mdv - dZoxh91QR+6hQuz3iYztC/BszMtATH8MznAoco0QFAhKi56Wppe+p1ATLWFMqk4W - elX9vtw5XLucKy5cMkQYh144SnrerlPJTAOGy0XXKunj8ceZfEN6zcS9Us9IN5aF - iENMFHjPsscrrKFhKypaMIn67PuIhVhw4PnGrWejr6TM1gUx+zOcRCwT+5ka2L7U - aqmgS8cDg5ZfAHcbig7No9kku/OSk+5QzkVKca2TZQHm++60oQTzRl3/NWiELO+e - Sl6r8i7dS0Kv3bB/AbLfIHtDgebxUh78qXMel/OUWd58ezxBS74rZ4AQTpYcdTbR - jKHploWi8h5yXYn/YdEZG1vW/zYseFNb7QKT5Cznucl8O/+lNZIOVw63Pq368dTD - tG1GZkIlwM+jlJjRew05YQ== - """), + """ + -----BEGIN CERTIFICATE----- + MIIDtDCCApygAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAxMjA0WhcNNDIwMjIwMjAxMjA0WjBDMQswCQYDVQQG + EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEQMA4GA1UEChMHRXhhbXBsZTENMAsG + A1UECxMEVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOGhEDj + lZ5R6o20kJdgrIRcY1he4qKLWQ4vU0thqAg4mEcKCZZn4/NL05UgJCFLwYaxMZZe + etb/WaTRvQpDDFh7AhsMR24m6zKKJVk9E/e/8ur7sGDIVq8hZOBTq85ZdxPj/zKW + wB1BR/RcY4DsGno1USlkV7TVeZc1qpJHTPImesevzH7zX8nhnFlf4TTQbpQt6RxU + cr+udWpMOyP9xMerIyp7jpPy79tIaGP2x7ryt2BB9FU4RwPk4DcdfOkmdS86md1c + GI9H5qM5rUzyqey0J8wMRLj+E0Vx0F1XELZeTtyulbIbhrBhu/KOXZG2zNIeK+2F + XxDlx9tD+bbcJfUCAwEAAaOBsTCBrjAdBgNVHQ4EFgQULjM9fwJnC3Tp1QYM8HNL + y60btl0wbAYDVR0jBGUwY4AULjM9fwJnC3Tp1QYM8HNLy60btl2hR6RFMEMxCzAJ + BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRAwDgYDVQQKEwdFeGFtcGxl + MQ0wCwYDVQQLEwRUZXN0ggIQATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE + AwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAR0Mk+2X/rr4kYYfHsQUIsROwDZSQhQr3 + QOeLc7fyTjkM96OHXN2dKVoOcpzgKi1goHW7lh8vVmKRQk2wfFqRZV9/kQBFK/gz + QtN5gp+pA8Wk912Uj5gD0loiPcRf5bDElvLnr2iwt4VdKkvGIYa9Eu9CYbkf1x3t + ahVLmrZLBkqvKxo4MG4KGYXkqtII3M6clM4ScFa/0rR1nGZOgZyqG7AMMHc01csA + oLlEZx2hUcpJbz+sfCGUWYaF2uKJvuWMNFbGSDhfs8pOMGgelMOHaKVtgOEfEASN + TSqzqn0vzjJ78Mi6mN7/6L/onDKzROxClw0hc6L+PIhIHftD1ckvVQ== + -----END CERTIFICATE-----""", + + """ + MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIn/uWtEzLDK8CAggA + MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIk7+JC4ErMDBIIEyA3yvNhMm/Oj + ZdkN0HSzPyLv9bOfUyyx4NA121kizZIq/FkUjn8pGxzU63rzMk2vU1hmp2/O3ymr + vmV7gzXRp4ULZCjFwn4cLxi9ieKgBOr9MmgTlRc1oZ9P/Y8eWhmjGxA2CU3fy7Kv + DyzftqAetV8YzTelk8xqxLrGevB16O3zDbFj4dcmG7a0i75kqlI8QyQklJ9uyE10 + SELWFlV6w+3GD82YrbR/8v4fE5KP/nAPbtN4h4C7MY3kJQL+apHr5B3Jst+6N62t + JzmxGS5z3ZVT3Bn3mxi8awo8/XS8s+ZOSnH6nHvz83NBUQwSkVbtujlg+yMD2jg4 + Nt3LWfLnF8Q6n4oAQ1ZP9KJyVIh8+PN12txIRoWq1pF74hJmbfVfiCSR/tMrw6lr + XqlkG1Mi7RmpTCz9ScTUBWY/dyScYFITenv/WE+UnfQ+DXBC+78lkmL36M0Rx/ip + S4O1Tgy/z/MIv1s+ZpAFsRRczlpo9lbVEMuSGEWWTIQJCRPFV8Y1NKHmWUgeZpl3 + 2YUjpHNyQt/a1s1h1g5w9+UNuABt/3cUUnlA7psueb6l4x6M92QFBOpe1xUDL51D + RpaipVl1luFWvE84hqgCIv8Kh9EbkAlclmK8CIOkMQAabk0GmhCfEdm+PCW61Cao + rfCMwZ9Bx6zAcXGRrvl0sK35z8C3r8wLftaS/5xF6RTJBy6XY2iiFW6D44qZDFbh + 0rWV8zDtCf2+OZtEvPkeUn3sjevDW78TM6F7HBjXAeIFrNyJGVe2CTlEJLoZi5pX + W1blhMJ93N1mLiDYisILANmJRBfGMt0tYE/pGcJRlkuqG0qylnqRojjL83CTQvFy + 46q/obR36enRDvCZPvQrX2dB7Vkgpkz/drZ6+avmKdQcTjY/ycCd3DclwexhgUoX + QDntZuJQLp7C4tFfHRy2uh4DOEjzMP6a/NQ3q7p6vc6BTNTFZRUAdyNwcEDIzSLM + nZSPFBiz+gukhtNSCO28kLc8OX1hYsSAMgzbImcMtAiQHG3bFAJ0cs0jF4U9VrJt + 4/97kiDBuCgGb2b5t0+uDqipE6G4B6494IGm5KoIPAPbXMJQstmuzjTJt95UTF+p + e60AnWIXcvEOouIIMzC7gH2g23St5Bo6NixfxcmVfkFa92TDlCTxEz5Z5mnma06k + Pao4Km1eJkYS/QaCDnCZs/yCAMhINUTTDd0/7Y9YE3Dmd5B1s2wOa+ovESSL3Mdv + dZoxh91QR+6hQuz3iYztC/BszMtATH8MznAoco0QFAhKi56Wppe+p1ATLWFMqk4W + elX9vtw5XLucKy5cMkQYh144SnrerlPJTAOGy0XXKunj8ceZfEN6zcS9Us9IN5aF + iENMFHjPsscrrKFhKypaMIn67PuIhVhw4PnGrWejr6TM1gUx+zOcRCwT+5ka2L7U + aqmgS8cDg5ZfAHcbig7No9kku/OSk+5QzkVKca2TZQHm++60oQTzRl3/NWiELO+e + Sl6r8i7dS0Kv3bB/AbLfIHtDgebxUh78qXMel/OUWd58ezxBS74rZ4AQTpYcdTbR + jKHploWi8h5yXYn/YdEZG1vW/zYseFNb7QKT5Cznucl8O/+lNZIOVw63Pq368dTD + tG1GZkIlwM+jlJjRew05YQ== + """), // Version: 3 (0x2) // Serial Number: 4098 (0x1002) @@ -138,57 +149,57 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) SERVER_EXAMPLE_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDaTCCAlGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAzMTI5WhcNNDIwMjE5MjAzMTI5WjBdMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG - A1UECwwEVGVzdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMIIBIjANBgkqhkiG - 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3crcRzecIV08Muh6kA0CuVKnPkU2bLC+6bpV - 7/iBZ4D3qMwO8Q02+gP71pPNoAQ1nsifxR4k9mBVYOjar35RVpuFmLRRVMargrxg - 4WWDfVgLMhOeCy8+Tl4Mp/yRL3nkr0MJd57RCOPcPE84J/1Crq1Luy2+hsXSj25L - VJKx2o6LE0tfwPWnufdNUHzHRuNoBR83OpqIT0uXH15THZS+0ZcQwrJMcKYe4JWl - 6oXWcsWbtTG+r7QLIRKck2IG7jjHFpE83Q6Iv2HkhctgGZofwSTZyMmJ8eClovva - WFLDaLL2WuI3NwZM//knjMyfsEWtWsILXayCn5NTT74ClQjWQQIDAQABo00wSzAJ - BgNVHRMEAjAAMB0GA1UdDgQWBBQ9nPjenO4PMLtMTBddNiIDsPywjzAfBgNVHSME - GDAWgBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEAVOvM - fMDOxOCkWB244cx7J+f2qZU6/1qGlJUiL0WRLRj1XEmB8AYSZEb6Os1suF8sotka - nA9Aw1SFA/wNyrSKazXNlOKo0In1mu/OjHU7n6XYVAyDmFGziYY8zTqG1h8ZPrI7 - oAkNgnNDwmwy7uCAvMj+Q4QQ0Q4YxTHV/i3X1HuEwThRgz9cJGdDRIAsimRHDSDO - 5hsIJo6VASz0ISrYMxNZQ1og+XktdNssPK616bPf+APwXXnsWSuGkIdGDU059DII - cTSsLTbWkTWDXAAQo+sfDZUrvqopCK000eoywEmPQrTf7O8oAQdRvTsyxwMvOONd - EWQ9pDW9+RC8l5DtRA== - -----END CERTIFICATE-----""", + """ + -----BEGIN CERTIFICATE----- + MIIDaTCCAlGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAzMTI5WhcNNDIwMjE5MjAzMTI5WjBdMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG + A1UECwwEVGVzdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMIIBIjANBgkqhkiG + 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3crcRzecIV08Muh6kA0CuVKnPkU2bLC+6bpV + 7/iBZ4D3qMwO8Q02+gP71pPNoAQ1nsifxR4k9mBVYOjar35RVpuFmLRRVMargrxg + 4WWDfVgLMhOeCy8+Tl4Mp/yRL3nkr0MJd57RCOPcPE84J/1Crq1Luy2+hsXSj25L + VJKx2o6LE0tfwPWnufdNUHzHRuNoBR83OpqIT0uXH15THZS+0ZcQwrJMcKYe4JWl + 6oXWcsWbtTG+r7QLIRKck2IG7jjHFpE83Q6Iv2HkhctgGZofwSTZyMmJ8eClovva + WFLDaLL2WuI3NwZM//knjMyfsEWtWsILXayCn5NTT74ClQjWQQIDAQABo00wSzAJ + BgNVHRMEAjAAMB0GA1UdDgQWBBQ9nPjenO4PMLtMTBddNiIDsPywjzAfBgNVHSME + GDAWgBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEAVOvM + fMDOxOCkWB244cx7J+f2qZU6/1qGlJUiL0WRLRj1XEmB8AYSZEb6Os1suF8sotka + nA9Aw1SFA/wNyrSKazXNlOKo0In1mu/OjHU7n6XYVAyDmFGziYY8zTqG1h8ZPrI7 + oAkNgnNDwmwy7uCAvMj+Q4QQ0Q4YxTHV/i3X1HuEwThRgz9cJGdDRIAsimRHDSDO + 5hsIJo6VASz0ISrYMxNZQ1og+XktdNssPK616bPf+APwXXnsWSuGkIdGDU059DII + cTSsLTbWkTWDXAAQo+sfDZUrvqopCK000eoywEmPQrTf7O8oAQdRvTsyxwMvOONd + EWQ9pDW9+RC8l5DtRA== + -----END CERTIFICATE-----""", """ - MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDdytxHN5whXTwy - 6HqQDQK5Uqc+RTZssL7pulXv+IFngPeozA7xDTb6A/vWk82gBDWeyJ/FHiT2YFVg - 6NqvflFWm4WYtFFUxquCvGDhZYN9WAsyE54LLz5OXgyn/JEveeSvQwl3ntEI49w8 - Tzgn/UKurUu7Lb6GxdKPbktUkrHajosTS1/A9ae5901QfMdG42gFHzc6mohPS5cf - XlMdlL7RlxDCskxwph7glaXqhdZyxZu1Mb6vtAshEpyTYgbuOMcWkTzdDoi/YeSF - y2AZmh/BJNnIyYnx4KWi+9pYUsNosvZa4jc3Bkz/+SeMzJ+wRa1awgtdrIKfk1NP - vgKVCNZBAgMBAAECggEBAMUMAtJe7J6Tx/TuqF0swfvGHAHt2eGM0cCzpMATh1xe - rylPSgMNG4faXDcSj4AX3U+ZrKCjHHGruo7jsc5yqm8IsxOtOAjajOwU0vnNh5mn - zCKMXUBQk8lqM1JXyOFmKS8wnsug1NRSJIuMUjbtAf5QxlSg2oHAZUa61cBoqAyk - KXbw9uBYnM4n8WGXdax/LLPuonjnz2Sc35CC1LhRAF/K7oyjg7KvScnphIFRaLiU - X4tFH0nLpcao5de0fP5eUEkbUZ3hE6MEZvOsxn5CFkjH2VdtZ9D5dc3ArV3UMe26 - +3swdenriYZ73HNJDiLAdeIVh9IrGVxhH9UowF9psIUCgYEA/Ldlx4vTTlM7URFn - luqK7D8WH9x4JiCLEGxU80nJxxIgF8eqhOFzsQemytTrf4o1xAkyyPIweHzwApCA - lBdwC4Mc44DjoLFVdTET9hEq7E/UK81znc0mD4v8Hz2JI6h3f2sQrcEAPBvjBwtc - TpS9WlSBKSO3NOb3Hlucq7COVKcCgYEA4KyZ+dOyKVLyGjd0g22v4YW7VC016Hql - uQ7SN1vuI3zQMa2rZfEv5z2L7olJKrDFcmqk8W1tfElrMaSsuohm8khhx0lPtHMw - 4Su/tci/3rEUl+DPrQExdjrrDXCqpUunOAlMP9qElsNBGdkrQ6QlMnSVVi2v8Vf1 - f86Mey2UEtcCgYEAqcOlmqPigfZFnZLcjLPoOQW0HhkjmTE5WgH8GybRZmpVpsPZ - V8R/zEeAkzbvMFEvBw7Kz9RqHTaIoKBjz5fjC8i7ClVWFGesKbqbVyx3MiH6PKaa - aUIbtEvsRSw4SPztsWnB3YcOWlK9csj97Efc36Zu0a0NcHtLPFh8aZWEN3cCgYEA - oQFv8oWPlmeXkcwN1iWjtfT1EtS3XhuOaXjCkuNxW8MVG5S+UHawAoGrpsyBP3Og - e2cLPuxRWpDunYvKMH6Rb60JTRwvXzxxWdvVLbtoLHkwLcrwaKWDQZvlWCNWVtBJ - TDH1j4jUHYpdO93SUE3wTiEX58Mj48tJ5kYpjBhUlc8CgYEA7PG3ORGqZtfCiNmj - CxvPtQiFC+ogf+v8cMQtrKVTgpnI2pxzG+cSXYvL4cnyY2JnwqarWorUic8JU2e2 - EhW53PWUg7VpITlLsqOpATIDiviFAN4qOOxgDt5v0C1PyB3aXe2B5VA3IgczssyR - OLy7p/DhOpu2bqnpKyIkAuzZgFc= - """), + MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDdytxHN5whXTwy + 6HqQDQK5Uqc+RTZssL7pulXv+IFngPeozA7xDTb6A/vWk82gBDWeyJ/FHiT2YFVg + 6NqvflFWm4WYtFFUxquCvGDhZYN9WAsyE54LLz5OXgyn/JEveeSvQwl3ntEI49w8 + Tzgn/UKurUu7Lb6GxdKPbktUkrHajosTS1/A9ae5901QfMdG42gFHzc6mohPS5cf + XlMdlL7RlxDCskxwph7glaXqhdZyxZu1Mb6vtAshEpyTYgbuOMcWkTzdDoi/YeSF + y2AZmh/BJNnIyYnx4KWi+9pYUsNosvZa4jc3Bkz/+SeMzJ+wRa1awgtdrIKfk1NP + vgKVCNZBAgMBAAECggEBAMUMAtJe7J6Tx/TuqF0swfvGHAHt2eGM0cCzpMATh1xe + rylPSgMNG4faXDcSj4AX3U+ZrKCjHHGruo7jsc5yqm8IsxOtOAjajOwU0vnNh5mn + zCKMXUBQk8lqM1JXyOFmKS8wnsug1NRSJIuMUjbtAf5QxlSg2oHAZUa61cBoqAyk + KXbw9uBYnM4n8WGXdax/LLPuonjnz2Sc35CC1LhRAF/K7oyjg7KvScnphIFRaLiU + X4tFH0nLpcao5de0fP5eUEkbUZ3hE6MEZvOsxn5CFkjH2VdtZ9D5dc3ArV3UMe26 + +3swdenriYZ73HNJDiLAdeIVh9IrGVxhH9UowF9psIUCgYEA/Ldlx4vTTlM7URFn + luqK7D8WH9x4JiCLEGxU80nJxxIgF8eqhOFzsQemytTrf4o1xAkyyPIweHzwApCA + lBdwC4Mc44DjoLFVdTET9hEq7E/UK81znc0mD4v8Hz2JI6h3f2sQrcEAPBvjBwtc + TpS9WlSBKSO3NOb3Hlucq7COVKcCgYEA4KyZ+dOyKVLyGjd0g22v4YW7VC016Hql + uQ7SN1vuI3zQMa2rZfEv5z2L7olJKrDFcmqk8W1tfElrMaSsuohm8khhx0lPtHMw + 4Su/tci/3rEUl+DPrQExdjrrDXCqpUunOAlMP9qElsNBGdkrQ6QlMnSVVi2v8Vf1 + f86Mey2UEtcCgYEAqcOlmqPigfZFnZLcjLPoOQW0HhkjmTE5WgH8GybRZmpVpsPZ + V8R/zEeAkzbvMFEvBw7Kz9RqHTaIoKBjz5fjC8i7ClVWFGesKbqbVyx3MiH6PKaa + aUIbtEvsRSw4SPztsWnB3YcOWlK9csj97Efc36Zu0a0NcHtLPFh8aZWEN3cCgYEA + oQFv8oWPlmeXkcwN1iWjtfT1EtS3XhuOaXjCkuNxW8MVG5S+UHawAoGrpsyBP3Og + e2cLPuxRWpDunYvKMH6Rb60JTRwvXzxxWdvVLbtoLHkwLcrwaKWDQZvlWCNWVtBJ + TDH1j4jUHYpdO93SUE3wTiEX58Mj48tJ5kYpjBhUlc8CgYEA7PG3ORGqZtfCiNmj + CxvPtQiFC+ogf+v8cMQtrKVTgpnI2pxzG+cSXYvL4cnyY2JnwqarWorUic8JU2e2 + EhW53PWUg7VpITlLsqOpATIDiviFAN4qOOxgDt5v0C1PyB3aXe2B5VA3IgczssyR + OLy7p/DhOpu2bqnpKyIkAuzZgFc= + """), // Version: 3 (0x2) @@ -203,57 +214,57 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) CLIENT_EXAMPLE_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDZjCCAk6gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAzMzU5WhcNNDIwMjE5MjAzMzU5WjBaMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG - A1UECwwEVGVzdDEVMBMGA1UEAwwMRG8tTm90LVJlcGx5MIIBIjANBgkqhkiG9w0B - AQEFAAOCAQ8AMIIBCgKCAQEA2yJgm3Lthr+97vdEWTb4zaNuLTa/DkCXdmVNIQk9 - kVn2hjZrPc+JghBCaWpohGVTQ+zxplIJXk+QVZ0ePEimE7ahBClz4MlAgMpt1uxy - mYYUAsSZDCaFUI9Cpx1f0BiSWu330196K/AfRIoT+/SOZucnpbepxyrt+Az5SKrH - TJR/OSqeX4XKGPoRI96pKxDOV8pY5/I9h9yKGuxfufbpOdVODngVLcMKgBAkiD+2 - sguEHM+iGLx970+W6yycu1dFY1CAgWLUF3evUxe8avwePgx7lTFXnNueYt96Ny9v - L1o/WzoBe3z1mTl5Qb//3tYbXn8vdiDYm0dT8wImpDbpvwIDAQABo00wSzAJBgNV - HRMEAjAAMB0GA1UdDgQWBBSXqW/B1BVjNgowSwa3MBiHMkzp6zAfBgNVHSMEGDAW - gBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEABIMAjT5T - lZDV/1wmdKCyJQJ7WUjA44N5/yBGtEmpAJ0VM7/COnk8lqiYxrk50wK7lt0tiklX - 4aLqbAgnDc27z9AQGHOqB69dZprGQT9PsTByjK6i7KPGs30ygyND41j0rju/GM2e - 3xprZbusODENRyL196QV4ai0WVe1hEvv0wTMIcnXYmZHMP8ArdVRHWaDQF6zW0Mh - QbFqklt5W0ZIl2ZmC8z7z2Z6jv/BYyDo3U96LfdCWsEKxSKiX/PGHqZu4D3A4VSE - 0+fE7cX61kgRdGvZJgFjtYxtfkXd1HlyJ48Dqilzl+rvgvR5XA68zijjN0khPhml - wZhPIOCIaWMZYw== - -----END CERTIFICATE-----""", + """ + -----BEGIN CERTIFICATE----- + MIIDZjCCAk6gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx + EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT + BFRlc3QwHhcNMjIwMjI1MjAzMzU5WhcNNDIwMjE5MjAzMzU5WjBaMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG + A1UECwwEVGVzdDEVMBMGA1UEAwwMRG8tTm90LVJlcGx5MIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEA2yJgm3Lthr+97vdEWTb4zaNuLTa/DkCXdmVNIQk9 + kVn2hjZrPc+JghBCaWpohGVTQ+zxplIJXk+QVZ0ePEimE7ahBClz4MlAgMpt1uxy + mYYUAsSZDCaFUI9Cpx1f0BiSWu330196K/AfRIoT+/SOZucnpbepxyrt+Az5SKrH + TJR/OSqeX4XKGPoRI96pKxDOV8pY5/I9h9yKGuxfufbpOdVODngVLcMKgBAkiD+2 + sguEHM+iGLx970+W6yycu1dFY1CAgWLUF3evUxe8avwePgx7lTFXnNueYt96Ny9v + L1o/WzoBe3z1mTl5Qb//3tYbXn8vdiDYm0dT8wImpDbpvwIDAQABo00wSzAJBgNV + HRMEAjAAMB0GA1UdDgQWBBSXqW/B1BVjNgowSwa3MBiHMkzp6zAfBgNVHSMEGDAW + gBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEABIMAjT5T + lZDV/1wmdKCyJQJ7WUjA44N5/yBGtEmpAJ0VM7/COnk8lqiYxrk50wK7lt0tiklX + 4aLqbAgnDc27z9AQGHOqB69dZprGQT9PsTByjK6i7KPGs30ygyND41j0rju/GM2e + 3xprZbusODENRyL196QV4ai0WVe1hEvv0wTMIcnXYmZHMP8ArdVRHWaDQF6zW0Mh + QbFqklt5W0ZIl2ZmC8z7z2Z6jv/BYyDo3U96LfdCWsEKxSKiX/PGHqZu4D3A4VSE + 0+fE7cX61kgRdGvZJgFjtYxtfkXd1HlyJ48Dqilzl+rvgvR5XA68zijjN0khPhml + wZhPIOCIaWMZYw== + -----END CERTIFICATE-----""", """ - MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbImCbcu2Gv73u - 90RZNvjNo24tNr8OQJd2ZU0hCT2RWfaGNms9z4mCEEJpamiEZVND7PGmUgleT5BV - nR48SKYTtqEEKXPgyUCAym3W7HKZhhQCxJkMJoVQj0KnHV/QGJJa7ffTX3or8B9E - ihP79I5m5yelt6nHKu34DPlIqsdMlH85Kp5fhcoY+hEj3qkrEM5Xyljn8j2H3Ioa - 7F+59uk51U4OeBUtwwqAECSIP7ayC4Qcz6IYvH3vT5brLJy7V0VjUICBYtQXd69T - F7xq/B4+DHuVMVec255i33o3L28vWj9bOgF7fPWZOXlBv//e1htefy92INibR1Pz - AiakNum/AgMBAAECggEAW0WxWW4AMyzwDnWdWU+FSBm3TUvNPkF3FNBS1NzFcSI4 - hWRrPJ6R1sOw9blleSe/C77IVA89abPYGWDM9C0KR5G89T/SzSDmJf6qy2dGwF1R - PmnmmWH+CzTwfSzF+KYTZ55QqBDPkTd9vo2Ij1woaAIFyId8RsHBxpyYxESlqGY4 - C6IzEqxFQ0obHXasNR+dP4iOWS4ONhxeUHixcrDHxbmoqmHt0WuJwXhlOjxHgr+i - lUPTe5y+Y2B1gVNYrN4KlDTJqJ6lu4n6MFQ46jhfddzTk3uiEOTVWK6nE8Cf0NM7 - djTzTcR8xAVpoY5XDlk0aBfEd8Np7TLSjV4vU3J04QKBgQD6scazH/H9Yu9ZbR7w - EeN/k7uDDlgahWg8/93syzdFtSNIRGvdalNMhTfM/zXaM/Cl63gvZilWxC+56Uvg - 6QC+rBUwzZrm7ryb6hT6Zyoo4w72bw3jGOJ3e2/bclSLrAcJnL/1Gq87J3CS16wl - NIHrlOlY8orToEdki+6HaagyEQKBgQDfxZz4Uqsa+jDO/rEm959+nz2RkaXYu1Ld - DhYONxmlw69/BbwzOvzr88qKNbd+b+oIK8kpm7Lvpc2/cuqItTFdehmw+tGhMWYo - XizKCeKeCByFTjXI2/PEPUHMy0D8M68Tx/Hq0NbIYqCyzkaamHhXpuJGftxGfd3/ - U0NB4WGOzwKBgQDgnyN7YfcwY1I0XUqoLk8aA2Oy5MpaUQh6B4RwZBENO2T2np/L - TzZ9zKuX2WAGOB26fMY+KhqGLNjaike7qOpK7eM6zC6sFmMWjGHpj0A+TFwewJi/ - z48zIX2zMbjBQQ05NqLkWdmCdi8u02HiIC78x3thgEiVn/n4BE1gNXJIEQKBgEdr - dfcXw36/vZZDWd07CU/LmUX9u3YaC498MHPnCCuM8lVTSkb7m7/fNpS4IlGbfJGR - EApUpF6yh6GEFvD9C71u/AYtd3zAHH/j1t3BG/AeXKP7W1U5RmsqtfacJKiaAlYI - 6eBtOTAJsop/Ja+v3DD1laC0Wq+w+orEU2ISgiWnAoGBAK9/9m3RCYPNYzS/PQ2B - AgE2FQRuY8FXxHegZo2tBBwIojPeVHO1OoThYVNgiQfW9k27dFkRwXVAtt6Jqgax - fvOby8rWRStXH2qHVyvHicceL7iXs6v2bX20Szsy44eMkoFfAImea6ZdErLdVWvI - fxlYpTIVpBt3Nu2BRJn28ili - """); + MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbImCbcu2Gv73u + 90RZNvjNo24tNr8OQJd2ZU0hCT2RWfaGNms9z4mCEEJpamiEZVND7PGmUgleT5BV + nR48SKYTtqEEKXPgyUCAym3W7HKZhhQCxJkMJoVQj0KnHV/QGJJa7ffTX3or8B9E + ihP79I5m5yelt6nHKu34DPlIqsdMlH85Kp5fhcoY+hEj3qkrEM5Xyljn8j2H3Ioa + 7F+59uk51U4OeBUtwwqAECSIP7ayC4Qcz6IYvH3vT5brLJy7V0VjUICBYtQXd69T + F7xq/B4+DHuVMVec255i33o3L28vWj9bOgF7fPWZOXlBv//e1htefy92INibR1Pz + AiakNum/AgMBAAECggEAW0WxWW4AMyzwDnWdWU+FSBm3TUvNPkF3FNBS1NzFcSI4 + hWRrPJ6R1sOw9blleSe/C77IVA89abPYGWDM9C0KR5G89T/SzSDmJf6qy2dGwF1R + PmnmmWH+CzTwfSzF+KYTZ55QqBDPkTd9vo2Ij1woaAIFyId8RsHBxpyYxESlqGY4 + C6IzEqxFQ0obHXasNR+dP4iOWS4ONhxeUHixcrDHxbmoqmHt0WuJwXhlOjxHgr+i + lUPTe5y+Y2B1gVNYrN4KlDTJqJ6lu4n6MFQ46jhfddzTk3uiEOTVWK6nE8Cf0NM7 + djTzTcR8xAVpoY5XDlk0aBfEd8Np7TLSjV4vU3J04QKBgQD6scazH/H9Yu9ZbR7w + EeN/k7uDDlgahWg8/93syzdFtSNIRGvdalNMhTfM/zXaM/Cl63gvZilWxC+56Uvg + 6QC+rBUwzZrm7ryb6hT6Zyoo4w72bw3jGOJ3e2/bclSLrAcJnL/1Gq87J3CS16wl + NIHrlOlY8orToEdki+6HaagyEQKBgQDfxZz4Uqsa+jDO/rEm959+nz2RkaXYu1Ld + DhYONxmlw69/BbwzOvzr88qKNbd+b+oIK8kpm7Lvpc2/cuqItTFdehmw+tGhMWYo + XizKCeKeCByFTjXI2/PEPUHMy0D8M68Tx/Hq0NbIYqCyzkaamHhXpuJGftxGfd3/ + U0NB4WGOzwKBgQDgnyN7YfcwY1I0XUqoLk8aA2Oy5MpaUQh6B4RwZBENO2T2np/L + TzZ9zKuX2WAGOB26fMY+KhqGLNjaike7qOpK7eM6zC6sFmMWjGHpj0A+TFwewJi/ + z48zIX2zMbjBQQ05NqLkWdmCdi8u02HiIC78x3thgEiVn/n4BE1gNXJIEQKBgEdr + dfcXw36/vZZDWd07CU/LmUX9u3YaC498MHPnCCuM8lVTSkb7m7/fNpS4IlGbfJGR + EApUpF6yh6GEFvD9C71u/AYtd3zAHH/j1t3BG/AeXKP7W1U5RmsqtfacJKiaAlYI + 6eBtOTAJsop/Ja+v3DD1laC0Wq+w+orEU2ISgiWnAoGBAK9/9m3RCYPNYzS/PQ2B + AgE2FQRuY8FXxHegZo2tBBwIojPeVHO1OoThYVNgiQfW9k27dFkRwXVAtt6Jqgax + fvOby8rWRStXH2qHVyvHicceL7iXs6v2bX20Szsy44eMkoFfAImea6ZdErLdVWvI + fxlYpTIVpBt3Nu2BRJn28ili + """); final String keyAlgo; final String certStr; @@ -359,10 +370,24 @@ private static SSLContext createSSLContext( } } + // Set the date for the verifying of certificates. + DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); + Date verifyingDate = df.parse("02/02/2023"); + // Create an SSLContext object. TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX"); - tmf.init(ts); + if (ts != null) { + PKIXBuilderParameters pkixParams = + new PKIXBuilderParameters(ts, null); + pkixParams.setDate(verifyingDate); + pkixParams.setRevocationEnabled(false); + ManagerFactoryParameters managerFactoryParameters = + new CertPathTrustManagerParameters(pkixParams); + tmf.init(managerFactoryParameters); + } else { + tmf.init((KeyStore)null); + } SSLContext context = SSLContext.getInstance("TLS"); if (endEntityCerts != null && endEntityCerts.length != 0) { @@ -370,7 +395,16 @@ private static SSLContext createSSLContext( KeyManagerFactory.getInstance("NewSunX509"); kmf.init(ks, passphrase); - context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + KeyManager[] kms = kmf.getKeyManagers(); + if (kms != null && kms.length != 0) { + KeyManager km = kms[0]; + Field verificationDateField = + km.getClass().getDeclaredField("verificationDate"); + verificationDateField.setAccessible(true); + verificationDateField.set(km, verifyingDate); + } + + context.init(kms, tmf.getTrustManagers(), null); } else { context.init(null, tmf.getTrustManagers(), null); } From ffea91377b86ed221c9d4bdd6db351f8654ad6a0 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 22 Dec 2022 10:23:56 +0000 Subject: [PATCH 022/205] 8244592: Start supporting SOURCE_DATE_EPOCH Reviewed-by: mbaesken Backport-of: 1a16a4b62829e54a4af5446ef15b981212a70718 --- make/Init.gmk | 3 + make/InitSupport.gmk | 9 ++ make/autoconf/configure.ac | 1 + make/autoconf/jdk-options.m4 | 73 ++++++++++ make/autoconf/jdk-version.m4 | 2 +- make/autoconf/spec.gmk.in | 3 + make/autoconf/util.m4 | 249 ++++++++++++++++++++++++++++++++++- 7 files changed, 336 insertions(+), 4 deletions(-) diff --git a/make/Init.gmk b/make/Init.gmk index 6897c343219..3ed46780ffe 100644 --- a/make/Init.gmk +++ b/make/Init.gmk @@ -226,6 +226,9 @@ else # HAS_SPEC=true # Parse COMPARE_BUILD (for makefile development) $(eval $(call ParseCompareBuild)) + # Setup reproducible build environment + $(eval $(call SetupReproducibleBuild)) + # If no LOG= was given on command line, but we have a non-standard default # value, use that instead and re-parse log level. ifeq ($(LOG), ) diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index baefc8941b3..9c11e2c2bcd 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -303,6 +303,15 @@ else # $(HAS_SPEC)=true topdir=$(TOPDIR) endif + # Setup the build environment to match the requested specification on + # level of reproducible builds + define SetupReproducibleBuild + ifeq ($$(SOURCE_DATE), updated) + SOURCE_DATE := $$(shell $$(DATE) +"%s") + endif + export SOURCE_DATE_EPOCH := $$(SOURCE_DATE) + endef + # Parse COMPARE_BUILD into COMPARE_BUILD_* # Syntax: COMPARE_BUILD=CONF=:PATCH=: # MAKE=:COMP_OPTS=: diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index c015f7312ab..393e80405b7 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -235,6 +235,7 @@ JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST JDKOPT_EXCLUDE_TRANSLATIONS JDKOPT_ENABLE_DISABLE_MANPAGES +JDKOPT_SETUP_REPRODUCIBLE_BUILD ############################################################################### # diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 43a7b5617c8..fc02940d0c2 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -683,3 +683,76 @@ AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT], AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT) ]) + +################################################################################ +# +# Check and set options related to reproducible builds. +# +AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD], +[ + AC_ARG_WITH([source-date], [AS_HELP_STRING([--with-source-date], + [how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@updated@:>@])], + [with_source_date_present=true], [with_source_date_present=false]) + + AC_MSG_CHECKING([what source date to use]) + + if test "x$with_source_date" = xyes; then + AC_MSG_ERROR([--with-source-date must have a value]) + elif test "x$with_source_date" = xupdated || test "x$with_source_date" = x; then + # Tell the makefiles to update at each build + SOURCE_DATE=updated + AC_MSG_RESULT([determined at build time, from 'updated']) + elif test "x$with_source_date" = xcurrent; then + # Set the current time + SOURCE_DATE=$($DATE +"%s") + AC_MSG_RESULT([$SOURCE_DATE, from 'current']) + elif test "x$with_source_date" = xversion; then + # Use the date from version-numbers + UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE) + if test "x$SOURCE_DATE" = x; then + AC_MSG_RESULT([unavailable]) + AC_MSG_ERROR([Cannot convert DEFAULT_VERSION_DATE to timestamp]) + fi + AC_MSG_RESULT([$SOURCE_DATE, from 'version']) + else + # It's a timestamp, an ISO-8601 date, or an invalid string + # Additional [] needed to keep m4 from mangling shell constructs. + if [ [[ "$with_source_date" =~ ^[0-9][0-9]*$ ]] ] ; then + SOURCE_DATE=$with_source_date + AC_MSG_RESULT([$SOURCE_DATE, from timestamp on command line]) + else + UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date) + if test "x$SOURCE_DATE" != x; then + AC_MSG_RESULT([$SOURCE_DATE, from ISO-8601 date on command line]) + else + AC_MSG_RESULT([unavailable]) + AC_MSG_ERROR([Cannot parse date string "$with_source_date"]) + fi + fi + fi + + REPRODUCIBLE_BUILD_DEFAULT=$with_source_date_present + + if test "x$OPENJDK_BUILD_OS" = xwindows && \ + test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = xfalse; then + # To support banning absolute paths on Windows, we must use the -pathmap + # method, which requires reproducible builds. + REPRODUCIBLE_BUILD_DEFAULT=true + fi + + UTIL_ARG_ENABLE(NAME: reproducible-build, DEFAULT: $REPRODUCIBLE_BUILD_DEFAULT, + RESULT: ENABLE_REPRODUCIBLE_BUILD, + DESC: [enable reproducible builds (not yet fully functional)], + DEFAULT_DESC: [enabled if --with-source-date is given or on Windows without absolute paths]) + + if test "x$OPENJDK_BUILD_OS" = xwindows && \ + test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = xfalse && \ + test "x$ENABLE_REPRODUCIBLE_BUILD" = xfalse; then + AC_MSG_NOTICE([On Windows it is not possible to combine --disable-reproducible-builds]) + AC_MSG_NOTICE([with --disable-absolute-paths-in-output.]) + AC_MSG_ERROR([Cannot continue]) + fi + + AC_SUBST(SOURCE_DATE) + AC_SUBST(ENABLE_REPRODUCIBLE_BUILD) +]) diff --git a/make/autoconf/jdk-version.m4 b/make/autoconf/jdk-version.m4 index 2620b013572..f0d1edfcbfd 100644 --- a/make/autoconf/jdk-version.m4 +++ b/make/autoconf/jdk-version.m4 @@ -36,7 +36,7 @@ AC_DEFUN([JDKVER_CHECK_AND_SET_NUMBER], [ # Additional [] needed to keep m4 from mangling shell constructs. - if [ ! [[ "$2" =~ ^0*([1-9][0-9]*)|(0)$ ]] ] ; then + if [ ! [[ "$2" =~ ^0*([1-9][0-9]*)$|^0*(0)$ ]] ] ; then AC_MSG_ERROR(["$2" is not a valid numerical value for $1]) fi # Extract the version number without leading zeros. diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 1746be3aa88..51dad49d1ac 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -126,6 +126,9 @@ RELEASE_FILE_OS_NAME:=@RELEASE_FILE_OS_NAME@ RELEASE_FILE_OS_ARCH:=@RELEASE_FILE_OS_ARCH@ RELEASE_FILE_LIBC:=@RELEASE_FILE_LIBC@ +SOURCE_DATE := @SOURCE_DATE@ +ENABLE_REPRODUCIBLE_BUILD := @ENABLE_REPRODUCIBLE_BUILD@ + LIBM:=@LIBM@ LIBDL:=@LIBDL@ diff --git a/make/autoconf/util.m4 b/make/autoconf/util.m4 index c768e4264e4..bb6bbe1c2da 100644 --- a/make/autoconf/util.m4 +++ b/make/autoconf/util.m4 @@ -52,7 +52,7 @@ m4_include([util_paths.m4]) AC_DEFUN([UTIL_DEFUN_NAMED], [ AC_DEFUN($1, [ - m4_foreach(arg, m4_split($2), [ + m4_foreach(arg, m4_split(m4_normalize($2)), [ m4_if(m4_bregexp(arg, [^\*]), -1, [ m4_set_add(legal_named_args, arg) @@ -65,11 +65,12 @@ AC_DEFUN([UTIL_DEFUN_NAMED], ]) m4_foreach([arg], [$3], [ + m4_if(m4_bregexp(arg, [: ]), -1, m4_define([arg], m4_bpatsubst(arg, [:], [: ]))) m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ]))) - m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: arg_name is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(legal_named_args, [ ])'.])]) + m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: m4_if(arg_name, , arg, arg_name) is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(defined_args, [ ]) m4_set_contents(legal_named_args, [ ])'.])]) m4_set_remove(required_named_args, arg_name) m4_set_remove(legal_named_args, arg_name) - m4_pushdef([ARG_][]arg_name, m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ]))))) + m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))), [^\s*], [])) m4_set_add(defined_args, arg_name) m4_undefine([arg_name]) ]) @@ -94,6 +95,83 @@ AC_DEFUN([UTIL_DEFUN_NAMED], ]) ]) +############################################################################### +# Assert that a programmatic condition holds. If not, exit with an error message. +# Check that a shell expression gives return code 0 +# +# $1: The shell expression to evaluate +# $2: A message to describe the expression in case of failure +# $2: An message to print in case of failure [optional] +# +AC_DEFUN([UTIL_ASSERT_SHELL_TEST], +[ + ASSERTION_MSG="m4_normalize([$3])" + if $1; then + $ECHO Assertion failed: $2 + if test "x$3" != x; then + $ECHO Assertion message: "$3" + fi + exit 1 + fi +]) + + +############################################################################### +# Assert that a programmatic condition holds. If not, exit with an error message. +# Check that two strings are equal. +# +# $1: The actual string found +# $2: The expected string +# $3: An message to print in case of failure [optional] +# +AC_DEFUN([UTIL_ASSERT_STRING_EQUALS], +[ + UTIL_ASSERT_SHELL_TEST( + [test "x[$1]" != "x[$2]"], + [Actual value '[$1]' \("[$1]"\) did not match expected value '[$2]' \("[$2]"\)], + $3) +]) + +############################################################################### +# Assert that a programmatic condition holds. If not, exit with an error message. +# Check that two strings not are equal. +# +# $1: The actual string found +# $2: The expected string +# $3: An message to print in case of failure [optional] +# +AC_DEFUN([UTIL_ASSERT_STRING_NOT_EQUALS], +[ + UTIL_ASSERT_SHELL_TEST( + [test "x[$1]" = "x[$2]"], + [Actual value '[$1]' \("[$1]"\) unexpectedly matched '[$2]' \("[$2]"\)], + $3) +]) + +############################################################################### +# Assert that a programmatic condition holds. If not, exit with an error message. +# Check that the given expression evaluates to the string 'true' +# +# $1: The expression to evaluate +# $2: An message to print in case of failure [optional] +# +AC_DEFUN([UTIL_ASSERT_TRUE], +[ + UTIL_ASSERT_STRING_EQUALS($1, true, $3) +]) + +############################################################################### +# Assert that a programmatic condition holds. If not, exit with an error message. +# Check that the given expression does not evaluate to the string 'true' +# +# $1: The expression to evaluate +# $2: An message to print in case of failure [optional] +# +AC_DEFUN([UTIL_ASSERT_NOT_TRUE], +[ + UTIL_ASSERT_STRING_NOT_EQUALS($1, true, $3) +]) + ############################################################################### # Check if a list of space-separated words are selected only from a list of # space-separated legal words. Typical use is to see if a user-specified @@ -148,6 +226,29 @@ AC_DEFUN([UTIL_GET_MATCHING_VALUES], fi ]) +############################################################################### +# Converts an ISO-8601 date/time string to a unix epoch timestamp. If no +# suitable conversion method was found, an empty string is returned. +# +# Sets the specified variable to the resulting list. +# +# $1: result variable name +# $2: input date/time string +AC_DEFUN([UTIL_GET_EPOCH_TIMESTAMP], +[ + timestamp=$($DATE --utc --date=$2 +"%s" 2> /dev/null) + if test "x$timestamp" = x; then + # GNU date format did not work, try BSD date options + timestamp=$($DATE -j -f "%F %T" "$2" "+%s" 2> /dev/null) + if test "x$timestamp" = x; then + # Perhaps the time was missing + timestamp=$($DATE -j -f "%F %T" "$2 00:00:00" "+%s" 2> /dev/null) + # If this did not work, we give up and return the empty string + fi + fi + $1=$timestamp +]) + ############################################################################### # Sort a space-separated list, and remove duplicates. # @@ -226,3 +327,145 @@ AC_DEFUN([UTIL_ALIASED_ARG_ENABLE], translit(patsubst($2, --), -, _)="$[enable_]translit($1, -, _)" ]) ]) + +############################################################################### +# Creates a command-line option using the --enable-* pattern. Will return a +# value of 'true' or 'false' in the RESULT variable, depending on whether the +# option was enabled or not by the user. The option can not be turned on if it +# is not available, as specified by AVAILABLE and/or CHECK_AVAILABLE. +# +# Arguments: +# NAME: The base name of this option (i.e. what follows --enable-). Required. +# RESULT: The name of the variable to set to the result. Defaults to +# _ENABLED. +# DEFAULT: The default value for this option. Can be true, false or auto. +# Defaults to true. +# AVAILABLE: If true, this option is allowed to be selected. Defaults to true. +# DESC: A description of this option. Defaults to a generic and unhelpful +# string. +# DEFAULT_DESC: A message describing the default value, for the help. Defaults +# to the literal value of DEFAULT. +# CHECKING_MSG: The message to present to user when checking this option. +# Defaults to a generic message. +# CHECK_AVAILABLE: An optional code block to execute to determine if the +# option should be available. Must set AVAILABLE to 'false' if not. +# IF_GIVEN: An optional code block to execute if the option was given on the +# command line (regardless of the value). +# IF_NOT_GIVEN: An optional code block to execute if the option was not given +# on the command line (regardless of the value). +# IF_ENABLED: An optional code block to execute if the option is turned on. +# IF_DISABLED: An optional code block to execute if the option is turned off. +# +UTIL_DEFUN_NAMED([UTIL_ARG_ENABLE], + [*NAME RESULT DEFAULT AVAILABLE DESC DEFAULT_DESC CHECKING_MSG + CHECK_AVAILABLE IF_GIVEN IF_NOT_GIVEN IF_ENABLED IF_DISABLED], [$@], +[ + ########################## + # Part 1: Set up m4 macros + ########################## + + # If DEFAULT is not specified, set it to 'true'. + m4_define([ARG_DEFAULT], m4_if(ARG_DEFAULT, , true, ARG_DEFAULT)) + + # If AVAILABLE is not specified, set it to 'true'. + m4_define([ARG_AVAILABLE], m4_if(ARG_AVAILABLE, , true, ARG_AVAILABLE)) + + # If DEFAULT_DESC is not specified, calculate it from DEFAULT. + m4_define([ARG_DEFAULT_DESC], m4_if(ARG_DEFAULT_DESC, , m4_if(ARG_DEFAULT, true, enabled, m4_if(ARG_DEFAULT, false, disabled, ARG_DEFAULT)), ARG_DEFAULT_DESC)) + + # If RESULT is not specified, set it to 'ARG_NAME[_ENABLED]'. + m4_define([ARG_RESULT], m4_if(ARG_RESULT, , m4_translit(ARG_NAME, [a-z-], [A-Z_])[_ENABLED], ARG_RESULT)) + # Construct shell variable names for the option + m4_define(ARG_OPTION, [enable_]m4_translit(ARG_NAME, [-], [_])) + m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN]) + + # If DESC is not specified, set it to a generic description. + m4_define([ARG_DESC], m4_if(ARG_DESC, , [Enable the ARG_NAME feature], m4_normalize(ARG_DESC))) + + # If CHECKING_MSG is not specified, set it to a generic description. + m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --enable-ARG_NAME], m4_normalize(ARG_CHECKING_MSG))) + + # If the code blocks are not given, set them to the empty statements to avoid + # tripping up bash. + m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE)) + m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN)) + m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN)) + m4_define([ARG_IF_ENABLED], m4_if(ARG_IF_ENABLED, , :, ARG_IF_ENABLED)) + m4_define([ARG_IF_DISABLED], m4_if(ARG_IF_DISABLED, , :, ARG_IF_DISABLED)) + + ########################## + # Part 2: Set up autoconf shell code + ########################## + + # Check that DEFAULT has a valid value + if test "[x]ARG_DEFAULT" != xtrue && test "[x]ARG_DEFAULT" != xfalse && \ + test "[x]ARG_DEFAULT" != xauto ; then + AC_MSG_ERROR([Internal error: Argument DEFAULT to [UTIL_ARG_ENABLE] can only be true, false or auto, was: 'ARG_DEFAULT']) + fi + + # Check that AVAILABLE has a valid value + if test "[x]ARG_AVAILABLE" != xtrue && test "[x]ARG_AVAILABLE" != xfalse; then + AC_MSG_ERROR([Internal error: Argument AVAILABLE to [UTIL_ARG_ENABLE] can only be true or false, was: 'ARG_AVAILABLE']) + fi + + AC_ARG_ENABLE(ARG_NAME, AS_HELP_STRING([--enable-]ARG_NAME, + [ARG_DESC [ARG_DEFAULT_DESC]]), [ARG_GIVEN=true], [ARG_GIVEN=false]) + + # Check if the option is available + AVAILABLE=ARG_AVAILABLE + # Run the available check block (if any), which can overwrite AVAILABLE. + ARG_CHECK_AVAILABLE + + # Check if the option should be turned on + AC_MSG_CHECKING(ARG_CHECKING_MSG) + if test x$ARG_GIVEN = xfalse; then + if test ARG_DEFAULT = auto; then + # If not given, and default is auto, set it to true iff it's available. + ARG_RESULT=$AVAILABLE + REASON="from default 'auto'" + else + ARG_RESULT=ARG_DEFAULT + REASON="default" + fi + else + if test x$ARG_OPTION = xyes; then + ARG_RESULT=true + REASON="from command line" + elif test x$ARG_OPTION = xno; then + ARG_RESULT=false + REASON="from command line" + elif test x$ARG_OPTION = xauto; then + if test ARG_DEFAULT = auto; then + # If both given and default is auto, set it to true iff it's available. + ARG_RESULT=$AVAILABLE + else + ARG_RESULT=ARG_DEFAULT + fi + REASON="from command line 'auto'" + else + AC_MSG_ERROR([Option [--enable-]ARG_NAME can only be 'yes', 'no' or 'auto']) + fi + fi + + if test x$ARG_RESULT = xtrue; then + AC_MSG_RESULT([enabled, $REASON]) + if test x$AVAILABLE = xfalse; then + AC_MSG_ERROR([Option [--enable-]ARG_NAME is not available]) + fi + else + AC_MSG_RESULT([disabled, $REASON]) + fi + + # Execute result payloads, if present + if test x$ARG_GIVEN = xtrue; then + ARG_IF_GIVEN + else + ARG_IF_NOT_GIVEN + fi + + if test x$ARG_RESULT = xtrue; then + ARG_IF_ENABLED + else + ARG_IF_DISABLED + fi +]) From bcda0410a9e9f49449bb7869ee894026fa109de8 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 23 Dec 2022 08:28:28 +0000 Subject: [PATCH 023/205] 8256240: Reproducible builds should turn on the "deterministic" flag for Visual Studio 8281262: Windows builds in different directories are not fully reproducible Reviewed-by: phh Backport-of: b0485b9632e3879365497de9e6c2c55d839236db --- make/TestImage.gmk | 4 +-- make/autoconf/configure.ac | 3 ++- make/autoconf/flags-cflags.m4 | 38 +++++++++++++++++++++++++++-- make/autoconf/flags-ldflags.m4 | 16 +++++++++--- test/jdk/build/AbsPathsInImage.java | 12 +++++---- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/make/TestImage.gmk b/make/TestImage.gmk index d5ef69fd904..552dce07d56 100644 --- a/make/TestImage.gmk +++ b/make/TestImage.gmk @@ -37,8 +37,8 @@ FIXPATH_ECHO := $(FIXPATH) $(call FixPath, $(ECHO)) $(BUILD_INFO_PROPERTIES): $(call MakeTargetDir) $(ECHO) "# Build info properties for JDK tests" > $@ - $(ECHO) "build.workspace.root=$(call FixPath, $(WORKSPACE_ROOT))" >> $@ - $(ECHO) "build.output.root=$(call FixPath, $(OUTPUTDIR))" >> $@ + $(ECHO) 'build.workspace.root=$(call FixPath, $(WORKSPACE_ROOT))' >> $@ + $(ECHO) 'build.output.root=$(call FixPath, $(OUTPUTDIR))' >> $@ prepare-test-image: $(BUILD_INFO_PROPERTIES) $(call MakeDir, $(TEST_IMAGE_DIR)) diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index 393e80405b7..6192411da41 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -195,7 +195,8 @@ FLAGS_POST_TOOLCHAIN PLATFORM_SETUP_OPENJDK_TARGET_BITS PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS -# Configure flags for the tools +# Configure flags for the tools. Need to know if we should build reproducible. +JDKOPT_SETUP_REPRODUCIBLE_BUILD FLAGS_SETUP_FLAGS # Setup debug symbols (need objcopy from the toolchain for that) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 49a7c68038b..3c5ba9cccec 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -813,6 +813,18 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized" fi + if test "x$TOOLCHAIN_TYPE" = xmicrosoft && test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then + # Enabling deterministic creates warnings if __DATE__ or __TIME__ are + # used, and since we are, silence that warning. + REPRODUCIBLE_CFLAGS="-experimental:deterministic -wd5048" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${REPRODUCIBLE_CFLAGS}], + PREFIX: $3, + IF_FALSE: [ + REPRODUCIBLE_CFLAGS= + ] + ) + fi + # Prevent the __FILE__ macro from generating absolute paths into the built # binaries. Depending on toolchain, different mitigations are possible. # * GCC and Clang of new enough versions have -fmacro-prefix-map. @@ -831,6 +843,27 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], FILE_MACRO_CFLAGS= ] ) + elif test "x$TOOLCHAIN_TYPE" = xmicrosoft && + test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then + # There is a known issue with the pathmap if the mapping is made to the + # empty string. Add a minimal string "s" as prefix to work around this. + # PATHMAP_FLAGS is also added to LDFLAGS in flags-ldflags.m4. + PATHMAP_FLAGS="-pathmap:${WORKSPACE_ROOT}=s" + FILE_MACRO_CFLAGS="$PATHMAP_FLAGS" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}], + PREFIX: $3, + IF_FALSE: [ + PATHMAP_FLAGS= + FILE_MACRO_CFLAGS= + ] + ) + fi + + AC_MSG_CHECKING([how to prevent absolute paths in output]) + if test "x$FILE_MACRO_CFLAGS" != x; then + AC_MSG_RESULT([using compiler options]) + else + AC_MSG_RESULT([using relative paths]) fi fi AC_SUBST(FILE_MACRO_CFLAGS) @@ -839,12 +872,13 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \ $TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \ $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \ - $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS" + $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS \ + $REPRODUCIBLE_CFLAGS" CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \ $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \ $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \ - $FILE_MACRO_CFLAGS" + $FILE_MACRO_CFLAGS $REPRODUCIBLE_CFLAGS" # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags. # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index 7d511ca1a57..2202bb69e96 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -147,9 +147,17 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], fi fi + if test "x$ENABLE_REPRODUCIBLE_BUILD" = "xtrue"; then + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + REPRODUCIBLE_LDFLAGS="-experimental:deterministic" + fi + fi + if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then BASIC_LDFLAGS="$BASIC_LDFLAGS -pdbaltpath:%_PDB%" + # PATHMAP_FLAGS is setup in flags-cflags.m4. + FILE_MACRO_LDFLAGS="${PATHMAP_FLAGS}" fi fi @@ -211,13 +219,15 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP], LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \ $OS_LDFLAGS $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}" $2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \ - ${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS" + ${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS \ + $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" $2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \ - ${$1_CPU_EXECUTABLE_LDFLAGS}" + ${$1_CPU_EXECUTABLE_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" $2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS $OS_LDFLAGS_JVM_ONLY \ $DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \ - ${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS}" + ${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS} \ + $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" AC_SUBST($2LDFLAGS_JDKLIB) AC_SUBST($2LDFLAGS_JDKEXE) diff --git a/test/jdk/build/AbsPathsInImage.java b/test/jdk/build/AbsPathsInImage.java index 78406b9b91c..64a2239844f 100644 --- a/test/jdk/build/AbsPathsInImage.java +++ b/test/jdk/build/AbsPathsInImage.java @@ -95,6 +95,13 @@ public static void main(String[] args) throws Exception { if (buildOutputRoot == null) { throw new Error("Could not find build output root, test cannot run"); } + // Validate the root paths + if (!Paths.get(buildWorkspaceRoot).isAbsolute()) { + throw new Error("Workspace root is not an absolute path: " + buildWorkspaceRoot); + } + if (!Paths.get(buildOutputRoot).isAbsolute()) { + throw new Error("Output root is not an absolute path: " + buildOutputRoot); + } List searchPatterns = new ArrayList<>(); expandPatterns(searchPatterns, buildWorkspaceRoot); @@ -158,11 +165,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO return super.visitFile(file, attrs); } else if (fileName.endsWith(".debuginfo") || fileName.endsWith(".pdb")) { // Do nothing - } else if (fileName.endsWith("jvm.dll")) { - // On Windows, the Microsoft toolchain does not provide a way - // to reliably remove all absolute paths from __FILE__ usage. - // Until that is fixed, we simply exclude jvm.dll from this - // test. } else if (fileName.endsWith(".zip")) { scanZipFile(file, searchPatterns); } else { From ca49dbf39916e4d68e81e139a14d922f6144e8ee Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 23 Dec 2022 08:46:16 +0000 Subject: [PATCH 024/205] 8298527: Cygwin's uname -m returns different string than before Backport-of: 1da982b4f4653002177b1bb2deee7688f2600c05 --- make/autoconf/build-aux/config.guess | 65 +++++++++++++++------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/make/autoconf/build-aux/config.guess b/make/autoconf/build-aux/config.guess index 7a31eb2c148..a88a9adec3f 100644 --- a/make/autoconf/build-aux/config.guess +++ b/make/autoconf/build-aux/config.guess @@ -29,7 +29,40 @@ # and fix the broken property, if needed. DIR=`dirname $0` -OUT=`. $DIR/autoconf-config.guess` +OUT=`. $DIR/autoconf-config.guess 2> /dev/null` + +# Handle some cases that autoconf-config.guess is not capable of +if [ "x$OUT" = x ]; then + if [ `uname -s` = Linux ]; then + # Test and fix little endian MIPS. + if [ `uname -m` = mipsel ]; then + OUT=mipsel-unknown-linux-gnu + elif [ `uname -m` = mips64el ]; then + OUT=mips64el-unknown-linux-gnu + # Test and fix little endian PowerPC64. + elif [ `uname -m` = ppc64le ]; then + OUT=powerpc64le-unknown-linux-gnu + # Test and fix LoongArch64. + elif [ `uname -m` = loongarch64 ]; then + OUT=loongarch64-unknown-linux-gnu + # Test and fix RISC-V. + elif [ `uname -m` = riscv64 ]; then + OUT=riscv64-unknown-linux-gnu + fi + # Test and fix cygwin machine arch .x86_64 + elif [[ `uname -s` = CYGWIN* ]]; then + if [ `uname -m` = ".x86_64" ]; then + OUT=x86_64-unknown-cygwin + fi + fi + + if [ "x$OUT" = x ]; then + # Run autoconf-config.guess again to get the error message. + . $DIR/autoconf-config.guess > /dev/null + else + printf "guessed by custom config.guess... " >&2 + fi +fi # Test and fix solaris on x86_64 echo $OUT | grep i386-pc-solaris > /dev/null 2> /dev/null @@ -88,36 +121,6 @@ if test $? = 0; then OUT=powerpc$KERNEL_BITMODE`echo $OUT | sed -e 's/[^-]*//'` fi -# Test and fix little endian PowerPC64. -# TODO: should be handled by autoconf-config.guess. -if [ "x$OUT" = x ]; then - if [ `uname -m` = ppc64le ]; then - if [ `uname -s` = Linux ]; then - OUT=powerpc64le-unknown-linux-gnu - fi - fi -fi - -# Test and fix little endian MIPS. -if [ "x$OUT" = x ]; then - if [ `uname -s` = Linux ]; then - if [ `uname -m` = mipsel ]; then - OUT=mipsel-unknown-linux-gnu - elif [ `uname -m` = mips64el ]; then - OUT=mips64el-unknown-linux-gnu - fi - fi -fi - -# Test and fix LoongArch64. -if [ "x$OUT" = x ]; then - if [ `uname -s` = Linux ]; then - if [ `uname -m` = loongarch64 ]; then - OUT=loongarch64-unknown-linux-gnu - fi - fi -fi - # Test and fix cpu on macos-aarch64, uname -p reports arm, buildsys expects aarch64 echo $OUT | grep arm-apple-darwin > /dev/null 2> /dev/null if test $? = 0; then From c46dcc56aa5824b14b37069d8ab85dda1eec0f3f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 26 Dec 2022 23:16:48 +0000 Subject: [PATCH 025/205] 8252715: Problem list java/awt/event/KeyEvent/KeyTyped/CtrlASCII.java on Linux Backport-of: d0f4366a859dd7ba9243495dadb460e78ad27006 --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index a1eabaab95d..6d3fccf35a4 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -171,6 +171,7 @@ java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java 8169476 windows java/awt/event/KeyEvent/KeyChar/KeyCharTest.java 8169474,8224055 macosx-all,windows-all java/awt/event/KeyEvent/ExtendedModifiersTest/ExtendedModifiersTest.java 8129778 generic-all java/awt/event/KeyEvent/KeyMaskTest/KeyMaskTest.java 8129778 generic-all +java/awt/event/KeyEvent/KeyTyped/CtrlASCII.java 8252713 linux-all java/awt/event/MouseEvent/MouseButtonsAndKeyMasksTest/MouseButtonsAndKeyMasksTest.java 8129778 generic-all java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java 8194947 generic-all From ce10688829436a4172ce303283ead277b7e4c8db Mon Sep 17 00:00:00 2001 From: Karm Michal Babacek Date: Tue, 27 Dec 2022 21:55:29 +0000 Subject: [PATCH 026/205] 8245245: WebSocket can lose the URL encoding of URI query parameters 8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body The fix updates jdk.internal.net.http.websocket.OpeningHandshake to avoid double encoding and decoding of URL Reviewed-by: phh, sgehwolf Backport-of: c07ce7eec71aefbd3cb624e03ca53f5148d01f19 --- .../net/http/websocket/OpeningHandshake.java | 16 +- .../websocket/HandshakeUrlEncodingTest.java | 214 ++++++++++++++++++ 2 files changed, 222 insertions(+), 8 deletions(-) create mode 100644 test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java b/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java index 63270bf5a5c..c0c3ab6e871 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java @@ -171,15 +171,15 @@ private static Collection createRequestSubprotocols( static URI createRequestURI(URI uri) { String s = uri.getScheme(); assert "ws".equalsIgnoreCase(s) || "wss".equalsIgnoreCase(s); - String scheme = "ws".equalsIgnoreCase(s) ? "http" : "https"; + String newUri = uri.toString(); + if (s.equalsIgnoreCase("ws")) { + newUri = "http" + newUri.substring(2); + } + else { + newUri = "https" + newUri.substring(3); + } try { - return new URI(scheme, - uri.getUserInfo(), - uri.getHost(), - uri.getPort(), - uri.getPath(), - uri.getQuery(), - null); // No fragment + return new URI(newUri); } catch (URISyntaxException e) { // Shouldn't happen: URI invariant throw new InternalError(e); diff --git a/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java new file mode 100644 index 00000000000..2b6b59d464b --- /dev/null +++ b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java @@ -0,0 +1,214 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8245245 + * @summary Test for Websocket URI encoding during HandShake + * @library /lib/testlibrary + * @library /test/lib + * @build jdk.testlibrary.SimpleSSLContext + * @modules java.net.http + * jdk.httpserver + * @run testng/othervm -Djdk.internal.httpclient.debug=true HandshakeUrlEncodingTest + */ + +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsServer; +import com.sun.net.httpserver.HttpExchange; +import jdk.test.lib.net.URIBuilder; +import jdk.testlibrary.SimpleSSLContext; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.WebSocket; +import java.net.http.WebSocketHandshakeException; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static java.net.http.HttpClient.Builder.NO_PROXY; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.fail; +import static java.lang.System.out; + +public class HandshakeUrlEncodingTest { + + SSLContext sslContext; + HttpServer httpTestServer; + HttpsServer httpsTestServer; + String httpURI; + String httpsURI; + + static String queryPart; + + static final int ITERATION_COUNT = 10; + // a shared executor helps reduce the amount of threads created by the test + static final ExecutorService executor = Executors.newCachedThreadPool(); + + @DataProvider(name = "variants") + public Object[][] variants() { + return new Object[][]{ + { httpURI, false }, + { httpsURI, false }, + { httpURI, true }, + { httpsURI, true } + }; + } + + HttpClient newHttpClient() { + return HttpClient.newBuilder() + .proxy(NO_PROXY) + .executor(executor) + .sslContext(sslContext) + .build(); + } + + @Test(dataProvider = "variants") + public void test(String uri, boolean sameClient) { + HttpClient client = null; + out.println("The url is " + uri); + for (int i = 0; i < ITERATION_COUNT; i++) { + System.out.printf("iteration %s%n", i); + if (!sameClient || client == null) + client = newHttpClient(); + + try { + client.newWebSocketBuilder() + .buildAsync(URI.create(uri), new WebSocket.Listener() { }) + .join(); + fail("Expected to throw"); + } catch (CompletionException ce) { + final Throwable t = getCompletionCause(ce); + if (!(t instanceof WebSocketHandshakeException)) { + throw new AssertionError("Unexpected exception", t); + } + final WebSocketHandshakeException wse = (WebSocketHandshakeException) t; + assertNotNull(wse.getResponse()); + assertNotNull(wse.getResponse().uri()); + assertNotNull(wse.getResponse().statusCode()); + final String rawQuery = wse.getResponse().uri().getRawQuery(); + final String expectedRawQuery = "&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; + assertEquals(rawQuery, expectedRawQuery); + // Unlike later JDKs, 11u does not have JDK-8240666 patched currently. + // We need to check whether a body is present. This is OK as previous assertions verify the fix of JDK-8245245. + if (wse.getResponse().body() != null && + (wse.getResponse().body().getClass().equals(String.class))) { + final String body = (String) wse.getResponse().body(); + final String expectedBody = "/?" + expectedRawQuery; + assertEquals(body, expectedBody); + } + out.println("Status code is " + wse.getResponse().statusCode()); + out.println("Response is " + wse.getResponse()); + assertEquals(wse.getResponse().statusCode(), 400); + } + } + } + + @BeforeTest + public void setup() throws Exception { + sslContext = new SimpleSSLContext().get(); + if (sslContext == null) + throw new AssertionError("Unexpected null sslContext"); + + + InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + queryPart = "?&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; + httpTestServer = HttpServer.create(sa, 10); + httpURI = URIBuilder.newBuilder() + .scheme("ws") + .host("localhost") + .port(httpTestServer.getAddress().getPort()) + .path("/") + .build() + .toString() + queryPart; + + httpTestServer.createContext("/", new UrlHandler()); + + httpsTestServer = HttpsServer.create(sa, 10); + httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); + httpsURI = URIBuilder.newBuilder() + .scheme("wss") + .host("localhost") + .port(httpsTestServer.getAddress().getPort()) + .path("/") + .build() + .toString() + queryPart; + + httpsTestServer.createContext("/", new UrlHandler()); + + httpTestServer.start(); + httpsTestServer.start(); + } + + @AfterTest + public void teardown() { + httpTestServer.stop(0); + httpsTestServer.stop(0); + executor.shutdownNow(); + } + + private static Throwable getCompletionCause(Throwable x) { + if (!(x instanceof CompletionException) + && !(x instanceof ExecutionException)) return x; + final Throwable cause = x.getCause(); + if (cause == null) { + throw new InternalError("Unexpected null cause", x); + } + return cause; + } + + static class UrlHandler implements HttpHandler { + + @Override + public void handle(HttpExchange e) throws IOException { + try(InputStream is = e.getRequestBody(); + OutputStream os = e.getResponseBody()) { + String testUri = "/?&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; + URI uri = e.getRequestURI(); + byte[] bytes = is.readAllBytes(); + if (uri.toString().equals(testUri)) { + bytes = testUri.getBytes(); + } + e.sendResponseHeaders(400, bytes.length); + os.write(bytes); + + } + } + } +} + From 4895d4ce5e2f9acefa6656471ebfb510125b3c31 Mon Sep 17 00:00:00 2001 From: "Nagata, Haruhito" Date: Tue, 27 Dec 2022 22:05:55 +0000 Subject: [PATCH 027/205] 8283606: Tests may fail with zh locale on MacOS Reviewed-by: clanger Backport-of: 7d545084f45af44386cb38172fd783f889a8c4e7 --- .../TestEmptyBootstrapMethodsAttr.java | 8 +++--- test/jdk/tools/pack200/DeprecatePack200.java | 26 +++++++++---------- .../javadoc/tool/6964914/TestStdDoclet.java | 4 ++- .../javadoc/tool/6964914/TestUserDoclet.java | 4 ++- .../jdk/javadoc/tool/EnsureNewOldDoclet.java | 11 +++++--- .../ClassPathWithDoubleQuotesTest.java | 6 ++--- .../options/smokeTests/OptionSmokeTest.java | 3 ++- .../javac/platform/PlatformProviderTest.java | 6 +++-- .../tools/javadoc/6964914/TestStdDoclet.java | 4 ++- .../tools/javadoc/6964914/TestUserDoclet.java | 4 ++- .../tools/jdeps/MultiReleaseJar.java | 16 ++++++------ 11 files changed, 54 insertions(+), 38 deletions(-) diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java index 0100d0433cf..06bdf07f662 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.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 @@ -56,7 +56,8 @@ public static void main(String args[]) throws Throwable { // ======= execute test case #1 // Expect a lack of main method, this implies that the class loaded correctly // with an empty bootstrap_methods and did not generate a ClassFormatError. - pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className); + pb = ProcessTools.createJavaProcessBuilder("-cp", ".", + "-Duser.language=en", "-Duser.country=US", className); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.ClassFormatError"); output.shouldContain("Main method not found in class " + className); @@ -70,7 +71,8 @@ public static void main(String args[]) throws Throwable { // ======= execute test case #2 // Expect a lack of main method, this implies that the class loaded correctly // with an empty bootstrap_methods and did not generate ClassFormatError. - pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className); + pb = ProcessTools.createJavaProcessBuilder("-cp", ".", + "-Duser.language=en", "-Duser.country=US", className); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.ClassFormatError"); output.shouldContain("Main method not found in class " + className); diff --git a/test/jdk/tools/pack200/DeprecatePack200.java b/test/jdk/tools/pack200/DeprecatePack200.java index df9f4c777d6..74fee8aa779 100644 --- a/test/jdk/tools/pack200/DeprecatePack200.java +++ b/test/jdk/tools/pack200/DeprecatePack200.java @@ -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 @@ -52,19 +52,19 @@ public class DeprecatePack200 { public static final Object[][] provide() { return cases; } private static final Object[][] cases = { - { PACK200_MSG, 1, List.of(PACK200_CMD) }, - { PACK200_MSG, 1, List.of(PACK200_CMD, "-V") }, - { PACK200_MSG, 2, List.of(PACK200_CMD, "--help") }, - { PACK200_MSG, 0, List.of(PACK200_CMD, "-XDsuppress-tool-removal-message") }, - { PACK200_MSG, 0, List.of(PACK200_CMD, "--version", "-XDsuppress-tool-removal-message") }, - { PACK200_MSG, 0, List.of(PACK200_CMD, "-h", "-XDsuppress-tool-removal-message") }, + { PACK200_MSG, 1, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US") }, + { PACK200_MSG, 1, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-V") }, + { PACK200_MSG, 2, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "--help") }, + { PACK200_MSG, 0, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-XDsuppress-tool-removal-message") }, + { PACK200_MSG, 0, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "--version", "-XDsuppress-tool-removal-message") }, + { PACK200_MSG, 0, List.of(PACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-h", "-XDsuppress-tool-removal-message") }, - { UNPACK200_MSG, 1, List.of(UNPACK200_CMD) }, - { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-V") }, - { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "--help") }, - { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-XDsuppress-tool-removal-message") }, - { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "--version", "-XDsuppress-tool-removal-message") }, - { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-h", "-XDsuppress-tool-removal-message") } + { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US") }, + { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-V") }, + { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "--help") }, + { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-XDsuppress-tool-removal-message") }, + { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "--version", "-XDsuppress-tool-removal-message") }, + { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-J-Duser.language=en", "-J-Duser.country=US", "-h", "-XDsuppress-tool-removal-message") } }; @Test(dataProvider = "tools") diff --git a/test/langtools/jdk/javadoc/tool/6964914/TestStdDoclet.java b/test/langtools/jdk/javadoc/tool/6964914/TestStdDoclet.java index d2ac6e657bb..12ac9d9087b 100644 --- a/test/langtools/jdk/javadoc/tool/6964914/TestStdDoclet.java +++ b/test/langtools/jdk/javadoc/tool/6964914/TestStdDoclet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,8 @@ void run() throws Exception { List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); cmdArgs.addAll(Arrays.asList( + "-J-Duser.language=en", + "-J-Duser.country=US", "-classpath", ".", // insulates us from ambient classpath "-Xdoclint:none", "-package", diff --git a/test/langtools/jdk/javadoc/tool/6964914/TestUserDoclet.java b/test/langtools/jdk/javadoc/tool/6964914/TestUserDoclet.java index f585c7c6511..1e131f19941 100644 --- a/test/langtools/jdk/javadoc/tool/6964914/TestUserDoclet.java +++ b/test/langtools/jdk/javadoc/tool/6964914/TestUserDoclet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,8 @@ void run() throws Exception { List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); cmdArgs.addAll(Arrays.asList( + "-J-Duser.language=en", + "-J-Duser.country=US", "-doclet", thisClassName, "-docletpath", testClasses.getPath(), new File(testSrc, thisClassName + ".java").getPath() diff --git a/test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java b/test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java index 36dc5a3e76c..1594835f9ea 100644 --- a/test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java +++ b/test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, 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 @@ -111,7 +111,8 @@ public static void main(String... args) throws Exception { // outcome: new tool and new doclet @Test public void testDefault() throws Exception { - setArgs("-classpath", ".", // insulates us from ambient classpath + setArgs("-J-Duser.language=en", "-J-Duser.country=US", + "-classpath", ".", // insulates us from ambient classpath testSrc.toString()); Task.Result tr = task.run(Task.Expect.SUCCESS); List out = tr.getOutputLines(Task.OutputKind.STDOUT); @@ -122,7 +123,8 @@ public void testDefault() throws Exception { // outcome: old tool @Test public void testOldDoclet() throws Exception { - setArgs("-classpath", ".", // ambient classpath insulation + setArgs("-J-Duser.language=en", "-J-Duser.country=US", + "-classpath", ".", // ambient classpath insulation "-doclet", OLD_DOCLET_CLASS_NAME, "-docletpath", @@ -139,7 +141,8 @@ public void testOldDoclet() throws Exception { // outcome: new doclet and new taglet should register @Test public void testNewDocletNewTaglet() throws Exception { - setArgs("-classpath", ".", // ambient classpath insulation + setArgs("-J-Duser.language=en", "-J-Duser.country=US", + "-classpath", ".", // ambient classpath insulation "-doclet", NEW_STDDOCLET, "-taglet", diff --git a/test/langtools/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java b/test/langtools/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java index 8c9cf5e58fb..f4d37313f48 100644 --- a/test/langtools/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java +++ b/test/langtools/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -119,7 +119,7 @@ public void test(Path base) throws Exception { "and for which they are a legal filename character"); String log = new JavacTask(tb, Task.Mode.EXEC) .envVar("CLASSPATH", "Ztest/jarOut/J.jar" + File.pathSeparator + "test/srcZ") - .options("-XDrawDiagnostics") + .options("-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US") .files("test/src/A.java").run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.STDERR); @@ -131,7 +131,7 @@ public void test(Path base) throws Exception { System.err.println("invoking javac EXEC mode with double quotes in the CLASSPATH env variable"); String log2 = new JavacTask(tb, Task.Mode.EXEC) .envVar("CLASSPATH", "\"test/jarOut/J.jar" + File.pathSeparator + "test/src\"") - .options("-Xlint:path", "-XDrawDiagnostics") + .options("-Xlint:path", "-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US") .files("test/src/A.java").run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.STDERR); diff --git a/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java b/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java index 2c428a6c419..0419a34fce6 100644 --- a/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java +++ b/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -201,6 +201,7 @@ public void unmatchedQuoteInEnvVar(Path base) throws Exception { tb.writeJavaFiles(src, "class Dummy {}"); String log = new JavacTask(tb, Task.Mode.EXEC) .envVar("JDK_JAVAC_OPTIONS", "--add-exports jdk.compiler" + fileSeparator + "com.sun.tools.javac.jvm=\"ALL-UNNAMED") + .options("-J-Duser.language=en", "-J-Duser.country=US") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() diff --git a/test/langtools/tools/javac/platform/PlatformProviderTest.java b/test/langtools/tools/javac/platform/PlatformProviderTest.java index e9e3183326b..27dce5062d2 100644 --- a/test/langtools/tools/javac/platform/PlatformProviderTest.java +++ b/test/langtools/tools/javac/platform/PlatformProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, 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 @@ -130,7 +130,9 @@ void doTestFailure() { Task.Result result = new JavacTask(tb, Task.Mode.EXEC) .outdir(".") - .options("-J--class-path=" + System.getProperty("test.classes"), + .options("-J-Duser.language=en", "-J-Duser.country=US", + "-J--class-path=" + System.getProperty("test.classes"), + "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", "-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "--release", diff --git a/test/langtools/tools/javadoc/6964914/TestStdDoclet.java b/test/langtools/tools/javadoc/6964914/TestStdDoclet.java index 50621e67889..d9110d3fa65 100644 --- a/test/langtools/tools/javadoc/6964914/TestStdDoclet.java +++ b/test/langtools/tools/javadoc/6964914/TestStdDoclet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,8 @@ void run() throws Exception { List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); cmdArgs.addAll(Arrays.asList( + "-J-Duser.language=en", + "-J-Duser.country=US", "-classpath", ".", // insulates us from ambient classpath "-Xdoclint:none", "-package", diff --git a/test/langtools/tools/javadoc/6964914/TestUserDoclet.java b/test/langtools/tools/javadoc/6964914/TestUserDoclet.java index 28ab02b89f4..ed2ae829b26 100644 --- a/test/langtools/tools/javadoc/6964914/TestUserDoclet.java +++ b/test/langtools/tools/javadoc/6964914/TestUserDoclet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,6 +60,8 @@ void run() throws Exception { List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); cmdArgs.addAll(Arrays.asList( + "-J-Duser.language=en", + "-J-Duser.country=US", "-doclet", thisClassName, "-docletpath", testClasses.getPath(), new File(testSrc, thisClassName + ".java").getPath() diff --git a/test/langtools/tools/jdeps/MultiReleaseJar.java b/test/langtools/tools/jdeps/MultiReleaseJar.java index 94cbeee89d6..8ba642083f1 100644 --- a/test/langtools/tools/jdeps/MultiReleaseJar.java +++ b/test/langtools/tools/jdeps/MultiReleaseJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -80,10 +80,10 @@ public void initialize() throws Exception { @Test public void basic() throws Exception { - Result r = run("jdeps --multi-release 9 -v missing.jar"); + Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9 -v missing.jar"); checkResult(r, false, "Warning: Path does not exist: missing.jar"); - r = run("jdeps -v Version.jar"); + r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v Version.jar"); checkResult(r, false, "--multi-release option is not set"); r = run("jdeps --multi-release base -v Version.jar"); @@ -115,10 +115,10 @@ public void basic() throws Exception { "9/test.NonPublic" ); - r = run("jdeps --multi-release 8 -v Version.jar"); + r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 8 -v Version.jar"); checkResult(r, false, "Error: invalid argument for option: 8"); - r = run("jdeps --multi-release 9.1 -v Version.jar"); + r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9.1 -v Version.jar"); checkResult(r, false, "Error: invalid argument for option: 9.1"); runJdeps("Main.class"); @@ -127,10 +127,10 @@ public void basic() throws Exception { private void runJdeps(String path) throws Exception { - Result r = run("jdeps -v -R -cp Version.jar " + path); + Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar " + path); checkResult(r, false, "--multi-release option is not set"); - r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path); + r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path); checkResult(r, false, "Error: unknown option: -multi-release", "Usage: jdeps Date: Thu, 29 Dec 2022 12:59:03 +0000 Subject: [PATCH 028/205] 8293767: AWT test TestSinhalaChar.java has old SCCS markings Backport-of: 141d5f5deec488531e410af875c781f4b70490da --- test/jdk/java/awt/font/TextLayout/TestSinhalaChar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/awt/font/TextLayout/TestSinhalaChar.java b/test/jdk/java/awt/font/TextLayout/TestSinhalaChar.java index 2d934c87dbf..59ba55cbd9d 100644 --- a/test/jdk/java/awt/font/TextLayout/TestSinhalaChar.java +++ b/test/jdk/java/awt/font/TextLayout/TestSinhalaChar.java @@ -22,7 +22,7 @@ */ /** - * @test @(#)TestSinhalaChar.java + * @test * @key headful * @summary verify lack of crash on U+0DDD. * @bug 6795060 From a3f37e5b5ca7113e21176052187abab9b9d3795a Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 29 Dec 2022 12:59:57 +0000 Subject: [PATCH 029/205] 8298027: Remove SCCS id's from awt jtreg tests Backport-of: ba2d28e911f4f523334f98fd0186680acafb6f0a --- test/jdk/java/awt/font/TextLayout/TestOldHangul.java | 3 +-- test/jdk/java/awt/font/TextLayout/TestTibetan.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/jdk/java/awt/font/TextLayout/TestOldHangul.java b/test/jdk/java/awt/font/TextLayout/TestOldHangul.java index b52ba38557d..5327c20dba3 100644 --- a/test/jdk/java/awt/font/TextLayout/TestOldHangul.java +++ b/test/jdk/java/awt/font/TextLayout/TestOldHangul.java @@ -21,7 +21,7 @@ * */ -/* @test @(#)TestOldHangul.java +/* @test * @summary Verify Old Hangul display * @bug 6886358 * @ignore Requires a special font installed. @@ -80,4 +80,3 @@ public void actionPerformed(ActionEvent actionEvent) { frame.setVisible(true); } } - diff --git a/test/jdk/java/awt/font/TextLayout/TestTibetan.java b/test/jdk/java/awt/font/TextLayout/TestTibetan.java index bc55472a3cd..86594ddf4c1 100644 --- a/test/jdk/java/awt/font/TextLayout/TestTibetan.java +++ b/test/jdk/java/awt/font/TextLayout/TestTibetan.java @@ -21,7 +21,7 @@ * */ -/* @test @(#)TestTibetan.java +/* @test * @summary verify tibetan output * @bug 6886358 * @ignore Requires a special font installed @@ -84,4 +84,3 @@ public void actionPerformed(ActionEvent actionEvent) { frame.setVisible(true); } } - From 4640c05b2dc9b0fb871df57dc72ca8255aecfede Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 29 Dec 2022 21:31:42 +0000 Subject: [PATCH 030/205] 8255710: Opensource unit/regression tests for CMM Backport-of: 98ccfbf46915791208f80b51f68f3916a68b8aaf --- .../java/awt/color/GetInstanceNullData.java | 59 +++++++++++++ .../java/awt/color/GetNameExceptionTest.java | 50 +++++++++++ test/jdk/java/awt/color/GetNameTest.java | 65 ++++++++++++++ .../awt/color/ICC_ProfileSetNullDataTest.java | 51 +++++++++++ .../java/awt/color/MultiThreadCMMTest.java | 87 +++++++++++++++++++ .../java/awt/color/StandardProfileTest.java | 55 ++++++++++++ .../java/awt/color/StandardProfileTest.policy | 30 +++++++ test/jdk/java/awt/color/XYZTest.java | 60 +++++++++++++ 8 files changed, 457 insertions(+) create mode 100644 test/jdk/java/awt/color/GetInstanceNullData.java create mode 100644 test/jdk/java/awt/color/GetNameExceptionTest.java create mode 100644 test/jdk/java/awt/color/GetNameTest.java create mode 100644 test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java create mode 100644 test/jdk/java/awt/color/MultiThreadCMMTest.java create mode 100644 test/jdk/java/awt/color/StandardProfileTest.java create mode 100644 test/jdk/java/awt/color/StandardProfileTest.policy create mode 100644 test/jdk/java/awt/color/XYZTest.java diff --git a/test/jdk/java/awt/color/GetInstanceNullData.java b/test/jdk/java/awt/color/GetInstanceNullData.java new file mode 100644 index 00000000000..9543455477a --- /dev/null +++ b/test/jdk/java/awt/color/GetInstanceNullData.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1999, 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 + * 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.ICC_Profile; +import java.awt.color.ICC_ProfileGray; +import java.awt.color.ICC_ProfileRGB; + +/** + * @test + * @bug 4176618 7042594 + * @summary This interactive test verifies that passing null to + * ICC_ProfileRGB.getInstance() does not crash the VM. + * An IllegalArgumentException: Invalid ICC Profile Data should be + * generated. + */ +public final class GetInstanceNullData { + + public static void main(String[] argv) { + byte b[] = null; + try { + ICC_ProfileRGB p = (ICC_ProfileRGB) ICC_ProfileRGB.getInstance(b); + throw new RuntimeException("IllegalArgumentException is expected"); + } catch (IllegalArgumentException ignored) { + // expected + } + try { + ICC_ProfileGray p = (ICC_ProfileGray) ICC_ProfileGray.getInstance(b); + throw new RuntimeException("IllegalArgumentException is expected"); + } catch (IllegalArgumentException ignored) { + // expected + } + try { + ICC_Profile p = ICC_Profile.getInstance(b); + throw new RuntimeException("IllegalArgumentException is expected"); + } catch (IllegalArgumentException ignored) { + // expected + } + } +} diff --git a/test/jdk/java/awt/color/GetNameExceptionTest.java b/test/jdk/java/awt/color/GetNameExceptionTest.java new file mode 100644 index 00000000000..ffb861da9e5 --- /dev/null +++ b/test/jdk/java/awt/color/GetNameExceptionTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2003, 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 + * 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.ColorSpace; + +/** + * @test + * @bug 4752851 + * @summary spec for ColorSpace.getName() does not describe case of wrong param + */ +public final class GetNameExceptionTest { + + public static void main(String[] args) { + test(ColorSpace.getInstance(ColorSpace.CS_sRGB)); + test(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)); + test(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)); + test(ColorSpace.getInstance(ColorSpace.CS_PYCC)); + test(ColorSpace.getInstance(ColorSpace.CS_GRAY)); + } + + private static void test(ColorSpace cs) { + try { + cs.getName(cs.getNumComponents()); + throw new RuntimeException("Method ColorSpace.getName(int) should" + + " throw exception for incorrect input"); + } catch (IllegalArgumentException ignored) { + // expected + } + } +} diff --git a/test/jdk/java/awt/color/GetNameTest.java b/test/jdk/java/awt/color/GetNameTest.java new file mode 100644 index 00000000000..dd7966446f2 --- /dev/null +++ b/test/jdk/java/awt/color/GetNameTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2005, 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 + * 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.ColorSpace; +import java.util.HashMap; +import java.util.Map; + +/** + * @test + * @bug 4967082 + * @summary ColorSpace.getName(int) should return significant values for some CS + */ +public final class GetNameTest { + + private static final Map colorSpaces = new HashMap<>(5); + + static { + colorSpaces.put(ColorSpace.CS_CIEXYZ, new String[] {"X", "Y", "Z"}); + colorSpaces.put(ColorSpace.CS_sRGB, + new String[] {"Red", "Green", "Blue"}); + colorSpaces.put(ColorSpace.CS_LINEAR_RGB, + new String[] {"Red", "Green", "Blue"}); + colorSpaces.put(ColorSpace.CS_GRAY, new String[] {"Gray"}); + colorSpaces.put(ColorSpace.CS_PYCC, + new String[] {"Unnamed color component(0)", + "Unnamed color component(1)", + "Unnamed color component(2)"}); + }; + + public static void main(String[] args) { + for (int csType : colorSpaces.keySet()) { + ColorSpace cs = ColorSpace.getInstance(csType); + String[] names = colorSpaces.get(csType); + for (int i = 0; i < cs.getNumComponents(); i++) { + String name = cs.getName(i); + if (!name.equals(names[i])) { + System.err.println("ColorSpace with type=" + cs.getType() + + " has wrong name of " + i + + " component"); + throw new RuntimeException("Wrong name of the component"); + } + } + } + } +} diff --git a/test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java b/test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java new file mode 100644 index 00000000000..a327fa791fb --- /dev/null +++ b/test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2004, 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 + * 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.ColorSpace; +import java.awt.color.ICC_Profile; + +/** + * @test + * @bug 4823896 7042594 + * @summary Test checks behavior of the ICC_Profile.setData(int, byte[]) + */ +public final class ICC_ProfileSetNullDataTest { + + public static void main(String[] args) { + test(ICC_Profile.getInstance(ColorSpace.CS_sRGB)); + test(ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB)); + test(ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ)); + test(ICC_Profile.getInstance(ColorSpace.CS_PYCC)); + test(ICC_Profile.getInstance(ColorSpace.CS_GRAY)); + } + + private static void test(ICC_Profile profile) { + byte[] tagData = null; + try { + profile.setData(ICC_Profile.icSigCmykData, tagData); + } catch (IllegalArgumentException e) { + return; + } + throw new RuntimeException("IllegalArgumentException expected"); + } +} diff --git a/test/jdk/java/awt/color/MultiThreadCMMTest.java b/test/jdk/java/awt/color/MultiThreadCMMTest.java new file mode 100644 index 00000000000..2db27665b93 --- /dev/null +++ b/test/jdk/java/awt/color/MultiThreadCMMTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2005, 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 + * 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.image.DirectColorModel; + +/** + * @test + * @bug 6245283 + * @summary Checks the behavior of the DirectColorModel.getRed(int) + * with multiple threads. + */ +public final class MultiThreadCMMTest extends Thread { + /* Number of concurent threads creating and accessing + * DirectColorModel object + */ + private static final int THREAD_COUNT = 100; + private static final int ITERATION_COUNT = 20; + + private static volatile boolean failed = false; + private static volatile Exception failureException = null; + + private static synchronized void setStatusFailed(Exception e) { + /* Store first occurred exception */ + if (!failed) { + failureException = e; + failed = true; + } + } + + public static void main(String [] args) throws Exception { + + Thread [] threadArray = new Thread [THREAD_COUNT]; + for (int i = 0; i < ITERATION_COUNT; i++) { + for (int j = 0; j < threadArray.length; j++) { + threadArray[j] = new MultiThreadCMMTest(); + }; + + for (int j = 0; j < threadArray.length; j++) { + threadArray[j].start(); + } + + /* Ensure that all threads are finished */ + for (int j = 0; j < threadArray.length; j++) { + threadArray[j].join(); + if (failed) { + throw new RuntimeException(failureException); + } + } + } + } + + public void run() { + int rMask16 = 0xF800; + int gMask16 = 0x07C0; + int bMask16 = 0x003E; + int r; + try { + for(int i=0; i < 1000; i++) { + DirectColorModel dcm = + new DirectColorModel(16, rMask16, gMask16, bMask16); + r = dcm.getRed(10); + } + } catch(Exception e) { + setStatusFailed(e); + } + } +} diff --git a/test/jdk/java/awt/color/StandardProfileTest.java b/test/jdk/java/awt/color/StandardProfileTest.java new file mode 100644 index 00000000000..24ff53b7dd7 --- /dev/null +++ b/test/jdk/java/awt/color/StandardProfileTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004, 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 + * 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.ColorSpace; +import java.awt.color.ICC_Profile; + +/** + * @test + * @bug 5042429 + * @summary This test verifies if ICC_profile instances for standard ColorSpace + * types are created without security exceptions if access to file + * system is prohibited. + * @run main/othervm/policy=StandardProfileTest.policy StandardProfileTest + */ +public final class StandardProfileTest { + + public static void main(String[] args) { + if (System.getSecurityManager() == null) { + throw new RuntimeException("SecurityManager is null"); + } + + int[] types = { + ColorSpace.CS_CIEXYZ, + ColorSpace.CS_GRAY, + ColorSpace.CS_LINEAR_RGB, + ColorSpace.CS_PYCC, + ColorSpace.CS_sRGB } ; + + for (int t = 0; t 0.01f) || + (Math.abs(mxyz[1] - 1.0000f) > 0.01f) || + (Math.abs(mxyz[2] - 1.0891f) > 0.01f)) { + throw new Error("sRGB (1.0, 1.0, 1.0) doesn't convert " + + "correctly to CIEXYZ"); + } + } +} From 7f2cea1626ede6ed77fd7e61187ec1078d6cb904 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 30 Dec 2022 08:16:34 +0000 Subject: [PATCH 031/205] 8213130: Update ProblemList after verification of jtreg tests in Win 7 Backport-of: 04104ceaea8cf2f2c52b85baa24f7da4f1e49f6b --- test/jdk/ProblemList.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 6d3fccf35a4..69975721e6f 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -470,7 +470,10 @@ java/awt/Toolkit/DesktopProperties/rfe4758438.java 8193547 linux-all java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all - +java/awt/im/memoryleak/InputContextMemoryLeakTest.java 8023814 linux-all,solaris-all +java/awt/MenuBar/8007006/bug8007006.java 8213122 windows-all +# below test fails only on Win 7 +java/awt/font/FontNames/LocaleFamilyNames.java 8213129 windows-all java/awt/GraphicsDevice/DisplayModes/CycleDMImage.java 7099223 linux-all,solaris-all,windows-all java/awt/keyboard/AllKeyCode/AllKeyCode.java 8242930 macosx-all @@ -763,8 +766,10 @@ javax/swing/JEditorPane/8195095/ImageViewTest.java 8202656 windows-all javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java 202880 linux-all javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all -java/awt/im/memoryleak/InputContextMemoryLeakTest.java 8023814 linux-all,solaris-all - +javax/swing/JComboBox/WindowsComboBoxSize/WindowsComboBoxSizeTest.java 8213116 windows-all +javax/swing/JComboBox/4199622/bug4199622.java 8213122 windows-all +javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java 8213122 windows-all +javax/swing/JPopupMenu/7154841/bug7154841.java 8213122 windows-all ############################################################################ From 4c2ff0846677f1a7fe49b78e2e59d7741b1134a7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:29:17 +0000 Subject: [PATCH 032/205] 8212165: JGSS: Fix cut/paste error in NativeUtil.c Backport-of: 2a105069423ca7bcd82e8e8453be1f7686616008 --- src/java.security.jgss/share/native/libj2gss/NativeUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.security.jgss/share/native/libj2gss/NativeUtil.c b/src/java.security.jgss/share/native/libj2gss/NativeUtil.c index 8e40177babf..3fba9fcdbfa 100644 --- a/src/java.security.jgss/share/native/libj2gss/NativeUtil.c +++ b/src/java.security.jgss/share/native/libj2gss/NativeUtil.c @@ -145,7 +145,7 @@ DEF_JNI_OnLoad(JavaVM *jvm, void *reserved) { return JNI_ERR; } CLS_GSSNameElement = (*env)->NewGlobalRef(env, cls); - if (CLS_GSSException == NULL) { + if (CLS_GSSNameElement == NULL) { return JNI_ERR; } cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSCredElement"); From ffc2cedb411adb1e91589d8c742e941478fbca9b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:31:09 +0000 Subject: [PATCH 033/205] 8212216: JGSS: Fix leak in exception cases in getJavaOID() Backport-of: 10027304cdf135738eb558ae533c4751cac7b71e --- .../share/native/libj2gss/NativeUtil.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/java.security.jgss/share/native/libj2gss/NativeUtil.c b/src/java.security.jgss/share/native/libj2gss/NativeUtil.c index 3fba9fcdbfa..b7ec48ba512 100644 --- a/src/java.security.jgss/share/native/libj2gss/NativeUtil.c +++ b/src/java.security.jgss/share/native/libj2gss/NativeUtil.c @@ -724,17 +724,14 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) { if (jbytes == NULL) { return NULL; } - (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr); - if ((*env)->ExceptionCheck(env)) { - return NULL; + if (!(*env)->ExceptionCheck(env)) { + (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr); } - (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements); - if ((*env)->ExceptionCheck(env)) { - return NULL; + if (!(*env)->ExceptionCheck(env)) { + (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements); } - result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes); - if ((*env)->ExceptionCheck(env)) { - return NULL; + if (!(*env)->ExceptionCheck(env)) { + result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes); } (*env)->DeleteLocalRef(env, jbytes); return result; From d52365e876f5d5d99d57a76f60c888805dd4dff6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:35:11 +0000 Subject: [PATCH 034/205] 8230731: SA tests fail with "Windbg Error: ReadVirtual failed" Backport-of: c6c1f9bad9c1742bc3fe44607df864ed05fe2195 --- .../windows/native/libsaproc/sawindbg.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp b/src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp index 72f3d0774ea..314cf69c957 100644 --- a/src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp +++ b/src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp @@ -742,11 +742,9 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebugger CHECK_EXCEPTION_(0); ULONG bytesRead; - COM_VERIFY_OK_(ptrIDebugDataSpaces->ReadVirtual((ULONG64)address, arrayBytes, - (ULONG)numBytes, &bytesRead), - "Windbg Error: ReadVirtual failed!", 0); - - if (bytesRead != numBytes) { + const HRESULT hr = ptrIDebugDataSpaces->ReadVirtual((ULONG64)address, arrayBytes, + (ULONG)numBytes, &bytesRead); + if (hr != S_OK || bytesRead != numBytes) { return 0; } From 984e4565c0af40ed42e9546a308068b8936422b9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:38:29 +0000 Subject: [PATCH 035/205] 8256934: C2: assert(C->live_nodes() <= C->max_node_limit()) failed: Live Node limit exceeded limit Backport-of: 9ad19f7838e6f6e128583c191c5507c1e2bd5083 --- src/hotspot/share/opto/loopopts.cpp | 18 ++++- .../loopopts/TestPartialPeelingSinkNodes.java | 73 +++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestPartialPeelingSinkNodes.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 980b1e8409c..6edb4314534 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -2698,6 +2698,12 @@ int PhaseIdealLoop::clone_for_use_outside_loop( IdealLoopTree *loop, Node* n, No worklist.push(use); } } + + if (C->check_node_count(worklist.size() + NodeLimitFudgeFactor, + "Too many clones required in clone_for_use_outside_loop in partial peeling")) { + return -1; + } + while( worklist.size() ) { Node *use = worklist.pop(); if (!has_node(use) || use->in(0) == C->top()) continue; @@ -3251,6 +3257,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { #endif // Evacuate nodes in peel region into the not_peeled region if possible + bool too_many_clones = false; uint new_phi_cnt = 0; uint cloned_for_outside_use = 0; for (uint i = 0; i < peel_list.size();) { @@ -3267,7 +3274,12 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { // if not pinned and not a load (which maybe anti-dependent on a store) // and not a CMove (Matcher expects only bool->cmove). if ( n->in(0) == NULL && !n->is_Load() && !n->is_CMove() ) { - cloned_for_outside_use += clone_for_use_outside_loop(loop, n, worklist); + int new_clones = clone_for_use_outside_loop(loop, n, worklist); + if (new_clones == -1) { + too_many_clones = true; + break; + } + cloned_for_outside_use += new_clones; sink_list.push(n); peel >>= n->_idx; // delete n from peel set. not_peel <<= n->_idx; // add n to not_peel set. @@ -3295,9 +3307,9 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { bool exceed_node_budget = !may_require_nodes(estimate); bool exceed_phi_limit = new_phi_cnt > old_phi_cnt + PartialPeelNewPhiDelta; - if (exceed_node_budget || exceed_phi_limit) { + if (too_many_clones || exceed_node_budget || exceed_phi_limit) { #ifndef PRODUCT - if (TracePartialPeeling) { + if (TracePartialPeeling && exceed_phi_limit) { tty->print_cr("\nToo many new phis: %d old %d new cmpi: %c", new_phi_cnt, old_phi_cnt, new_peel_if != NULL?'T':'F'); } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestPartialPeelingSinkNodes.java b/test/hotspot/jtreg/compiler/loopopts/TestPartialPeelingSinkNodes.java new file mode 100644 index 00000000000..d62d1028a7b --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestPartialPeelingSinkNodes.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 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 + * 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 8256934 + * @summary Sinking of nodes in partial peeling creates too many clones resulting in a live node limit exceeded assertion failure. + * @requires vm.compiler2.enabled + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,compiler.loopopts.TestPartialPeelingSinkNodes::test + * compiler.loopopts.TestPartialPeelingSinkNodes + */ + +package compiler.loopopts; + +public class TestPartialPeelingSinkNodes { + static int i5 = 168, iFld = 2, x, y; + static boolean b = false, b2 = false; + + public static void main(String[] strArr) { + test(); + } + + // The algorithm in partial peeling creates ~90000 nodes for this method which triggers the assertion failure. + public static void test() { + for (int i = 0; i < 2480; i++) { + int i2 = -37052, i3 = 39651, i4 = -37052; + int i5 = 168, i6 = -133, i7 = 1, i8 = -10; + double d = -20.82293; + + float fArr[] = new float[400]; + for (int j = 0; j < 400; j++) { + fArr[j] = (j % 2 == 0) ? 0.300F + j : 0.300F - j; + } + + while (--i5 > 0) { + i6 = 1; + do { + i4 += (((i6 * i2) + i3) - i3); + i2 += i4; + } while (++i6 < 9); + i3 -= i4; + for (i7 = 1; i7 < 18; i7++) { + i4 = i5; + d -= i4; + i2 -= i8; + i2 = i8; + } + } + } + } +} + From 5971a6a72570b59bbea32b4430a16089d0638310 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:40:07 +0000 Subject: [PATCH 036/205] 8280391: NMT: Correct NMT tag on CollectedHeap Backport-of: 44db4794d29c6e0755a6dc0ea1346f48f918155b --- src/hotspot/share/gc/shared/collectedHeap.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index 8deb320b320..beca58a8ef6 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, 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 @@ -101,7 +101,7 @@ class ParallelObjectIterator : public CHeapObj { // ShenandoahHeap // ZCollectedHeap // -class CollectedHeap : public CHeapObj { +class CollectedHeap : public CHeapObj { friend class VMStructs; friend class JVMCIVMStructs; friend class IsGCActiveMark; // Block structured external access to _is_gc_active From c898a3ed8863b3dff61bd2b8d7b64caab8371d3f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:41:52 +0000 Subject: [PATCH 037/205] 8284023: java.sun.awt.X11GraphicsDevice.getDoubleBufferVisuals() leaks XdbeScreenVisualInfo Backport-of: ec205f68a883cef6b98f26a06baf675f7da26928 --- src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 3ff3e8dc283..bf19bc8ffb6 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -1640,6 +1640,9 @@ Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals(JNIEnv *env, break; } } + AWT_LOCK(); + XdbeFreeVisualInfo(visScreenInfo); + AWT_UNLOCK(); #endif /* !HEADLESS */ } From d1f6bd1690f995bfce5db1724e76c6b152c3aa91 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:44:49 +0000 Subject: [PATCH 038/205] 8285399: JNI exception pending in awt_GraphicsEnv.c:1432 Backport-of: c156bcc599534ae989bc9cbd001e7c150da8096c --- src/java.desktop/unix/native/common/awt/awt.h | 3 +++ src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/unix/native/common/awt/awt.h b/src/java.desktop/unix/native/common/awt/awt.h index 18a6dee275b..dbe236eee47 100644 --- a/src/java.desktop/unix/native/common/awt/awt.h +++ b/src/java.desktop/unix/native/common/awt/awt.h @@ -85,6 +85,9 @@ extern void awt_output_flush(); #define AWT_LOCK_IMPL() \ do { \ + if ((*env)->ExceptionCheck(env)) { \ + (*env)->ExceptionClear(env); \ + } \ (*env)->CallStaticVoidMethod(env, tkClass, awtLockMID); \ if ((*env)->ExceptionCheck(env)) { \ (*env)->ExceptionClear(env); \ diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index bf19bc8ffb6..a1dbf67d45f 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -1635,10 +1635,10 @@ Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals(JNIEnv *env, AWT_FLUSH_UNLOCK(); for (i = 0; i < visScreenInfo->count; i++) { XdbeVisualInfo* visInfo = visScreenInfo->visinfo; - (*env)->CallVoidMethod(env, this, midAddVisual, (visInfo[i]).visual); if ((*env)->ExceptionCheck(env)) { break; } + (*env)->CallVoidMethod(env, this, midAddVisual, (visInfo[i]).visual); } AWT_LOCK(); XdbeFreeVisualInfo(visScreenInfo); From f6aef8aa146b22e91c64e1a89ad6d316e9631e3e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 Jan 2023 11:48:53 +0000 Subject: [PATCH 039/205] 8065097: [macosx] javax/swing/Popup/TaskbarPositionTest.java fails because Popup is one pixel off Backport-of: 649f2d8835027128c6c8cf37236808094a12a35f --- test/jdk/ProblemList.txt | 1 - .../swing/Popup/TaskbarPositionTest.java | 220 ++++++++++-------- 2 files changed, 127 insertions(+), 94 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 69975721e6f..e1043c2dd2a 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -765,7 +765,6 @@ javax/swing/JTextArea/TextViewOOM/TextViewOOM.java 8167355 generic-all javax/swing/JEditorPane/8195095/ImageViewTest.java 8202656 windows-all javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java 202880 linux-all javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all -javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all javax/swing/JComboBox/WindowsComboBoxSize/WindowsComboBoxSizeTest.java 8213116 windows-all javax/swing/JComboBox/4199622/bug4199622.java 8213122 windows-all javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java 8213122 windows-all diff --git a/test/jdk/javax/swing/Popup/TaskbarPositionTest.java b/test/jdk/javax/swing/Popup/TaskbarPositionTest.java index c91a8f38597..a088cb07a9a 100644 --- a/test/jdk/javax/swing/Popup/TaskbarPositionTest.java +++ b/test/jdk/javax/swing/Popup/TaskbarPositionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 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 @@ -21,27 +21,51 @@ * questions. */ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseAdapter; +import javax.swing.AbstractAction; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JSeparator; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.event.PopupMenuListener; +import javax.swing.event.PopupMenuEvent; /** * @test * @bug 4245587 4474813 4425878 4767478 8015599 * @key headful - * @author Mark Davidson * @summary Tests the location of the heavy weight popup portion of JComboBox, * JMenu and JPopupMenu. * @library ../regtesthelpers * @build Util * @run main TaskbarPositionTest */ -public class TaskbarPositionTest extends JFrame implements ActionListener { +public class TaskbarPositionTest implements ActionListener { private boolean done; private Throwable error; private static TaskbarPositionTest test; + private static JFrame frame; private static JPopupMenu popupMenu; private static JPanel panel; private static JComboBox combo1; @@ -63,27 +87,25 @@ public class TaskbarPositionTest extends JFrame implements ActionListener { }; public TaskbarPositionTest() { - super("Use CTRL-down to show a JPopupMenu"); - setContentPane(panel = createContentPane()); - setJMenuBar(createMenuBar("1 - First Menu", true)); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame = new JFrame("Use CTRL-down to show a JPopupMenu"); + frame.setContentPane(panel = createContentPane()); + frame.setJMenuBar(createMenuBar("1 - First Menu", true)); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // CTRL-down will show the popup. panel.getInputMap().put(KeyStroke.getKeyStroke( KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); panel.getActionMap().put("OPEN_POPUP", new PopupHandler()); - pack(); + frame.pack(); Toolkit toolkit = Toolkit.getDefaultToolkit(); fullScreenBounds = new Rectangle(new Point(), toolkit.getScreenSize()); screenBounds = new Rectangle(new Point(), toolkit.getScreenSize()); - // Place the frame near the bottom. This is a pretty wild guess. - this.setLocation(0, (int) screenBounds.getHeight() - 2 * this.getHeight()); // Reduce the screen bounds by the insets. - GraphicsConfiguration gc = this.getGraphicsConfiguration(); + GraphicsConfiguration gc = frame.getGraphicsConfiguration(); if (gc != null) { Insets screenInsets = toolkit.getScreenInsets(gc); screenBounds = gc.getBounds(); @@ -93,7 +115,9 @@ public TaskbarPositionTest() { screenBounds.y += screenInsets.top; } - setVisible(true); + // Place the frame near the bottom. + frame.setLocation(0, screenBounds.y + screenBounds.height - frame.getHeight()); + frame.setVisible(true); } public static class ComboPopupCheckListener implements PopupMenuListener { @@ -113,7 +137,8 @@ public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) { if (pm != null) { Point p = pm.getLocation(); SwingUtilities.convertPointToScreen(p, pm); - if (p.y < cpos.y) { + if (p.y+1 < cpos.y) { + System.out.println("p.y " + p.y + " cpos.y " + cpos.y); throw new RuntimeException("ComboBox popup is wrongly aligned"); } // check that popup was opened down } @@ -261,81 +286,90 @@ public void actionPerformed(ActionEvent evt) { public static void main(String[] args) throws Throwable { - - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - test = new TaskbarPositionTest(); - } - }); - - // Use Robot to automate the test - Robot robot; - robot = new Robot(); - robot.setAutoDelay(125); - - // 1 - menu - Util.hitMnemonics(robot, KeyEvent.VK_1); - - robot.waitForIdle(); - isPopupOnScreen(menu1.getPopupMenu(), screenBounds); - - // 2 menu with sub menu - robot.keyPress(KeyEvent.VK_RIGHT); - robot.keyRelease(KeyEvent.VK_RIGHT); - Util.hitMnemonics(robot, KeyEvent.VK_S); - - robot.waitForIdle(); - isPopupOnScreen(menu2.getPopupMenu(), screenBounds); - - robot.keyPress(KeyEvent.VK_ENTER); - robot.keyRelease(KeyEvent.VK_ENTER); - - // Focus should go to non editable combo box - robot.waitForIdle(); - Thread.sleep(500); - - robot.keyPress(KeyEvent.VK_DOWN); - - // How do we check combo boxes? - - // Editable combo box - robot.keyPress(KeyEvent.VK_TAB); - robot.keyRelease(KeyEvent.VK_TAB); - robot.keyPress(KeyEvent.VK_DOWN); - robot.keyRelease(KeyEvent.VK_DOWN); - - // combo1.getUI(); - - // Popup from Text field - robot.keyPress(KeyEvent.VK_TAB); - robot.keyRelease(KeyEvent.VK_TAB); - robot.keyPress(KeyEvent.VK_CONTROL); - robot.keyPress(KeyEvent.VK_DOWN); - robot.keyRelease(KeyEvent.VK_DOWN); - robot.keyRelease(KeyEvent.VK_CONTROL); - - // Popup from a mouse click. - Point pt = new Point(2, 2); - SwingUtilities.convertPointToScreen(pt, panel); - robot.mouseMove((int) pt.getX(), (int) pt.getY()); - robot.mousePress(InputEvent.BUTTON3_MASK); - robot.mouseRelease(InputEvent.BUTTON3_MASK); - - robot.waitForIdle(); - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - test.setLocation(-30, 100); - combo1.addPopupMenuListener(new ComboPopupCheckListener()); - combo1.requestFocus(); - } - }); - - robot.keyPress(KeyEvent.VK_DOWN); - robot.keyRelease(KeyEvent.VK_DOWN); - robot.keyPress(KeyEvent.VK_ESCAPE); - robot.keyRelease(KeyEvent.VK_ESCAPE); - - robot.waitForIdle(); - Thread.sleep(500); + try { + // Use Robot to automate the test + Robot robot; + robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + test = new TaskbarPositionTest(); + } + }); + + robot.waitForIdle(); + robot.delay(1000); + + // 1 - menu + Util.hitMnemonics(robot, KeyEvent.VK_1); + + robot.waitForIdle(); + SwingUtilities.invokeAndWait(() -> isPopupOnScreen(menu1.getPopupMenu(), screenBounds)); + + // 2 menu with sub menu + robot.keyPress(KeyEvent.VK_RIGHT); + robot.keyRelease(KeyEvent.VK_RIGHT); + Util.hitMnemonics(robot, KeyEvent.VK_S); + + robot.waitForIdle(); + SwingUtilities.invokeAndWait(() -> isPopupOnScreen(menu2.getPopupMenu(), screenBounds)); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + + // Focus should go to non editable combo box + robot.waitForIdle(); + robot.delay(500); + + robot.keyPress(KeyEvent.VK_DOWN); + + // How do we check combo boxes? + + // Editable combo box + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + + // combo1.getUI(); + + // Popup from Text field + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_CONTROL); + + // Popup from a mouse click. + Point pt = new Point(2, 2); + SwingUtilities.convertPointToScreen(pt, panel); + robot.mouseMove(pt.x, pt.y); + robot.mousePress(InputEvent.BUTTON3_MASK); + robot.mouseRelease(InputEvent.BUTTON3_MASK); + + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(-30, 100); + combo1.addPopupMenuListener(new ComboPopupCheckListener()); + combo1.requestFocus(); + } + }); + + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + + robot.waitForIdle(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } } } From f9f3fcb9e5fb5050008d72b5c7c37ea4a0ebccfa Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Tue, 3 Jan 2023 10:16:25 +0000 Subject: [PATCH 040/205] 8299445: EndingDotHostname.java fails because of compilation errors Reviewed-by: mdoerr --- .../net/ssl/templates/SSLExampleCert.java | 309 +++++++++--------- 1 file changed, 153 insertions(+), 156 deletions(-) diff --git a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java index 0b82aed3b7b..1a3145cdbc9 100644 --- a/test/jdk/javax/net/ssl/templates/SSLExampleCert.java +++ b/test/jdk/javax/net/ssl/templates/SSLExampleCert.java @@ -82,60 +82,59 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) CA_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDtDCCApygAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAxMjA0WhcNNDIwMjIwMjAxMjA0WjBDMQswCQYDVQQG - EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEQMA4GA1UEChMHRXhhbXBsZTENMAsG - A1UECxMEVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOGhEDj - lZ5R6o20kJdgrIRcY1he4qKLWQ4vU0thqAg4mEcKCZZn4/NL05UgJCFLwYaxMZZe - etb/WaTRvQpDDFh7AhsMR24m6zKKJVk9E/e/8ur7sGDIVq8hZOBTq85ZdxPj/zKW - wB1BR/RcY4DsGno1USlkV7TVeZc1qpJHTPImesevzH7zX8nhnFlf4TTQbpQt6RxU - cr+udWpMOyP9xMerIyp7jpPy79tIaGP2x7ryt2BB9FU4RwPk4DcdfOkmdS86md1c - GI9H5qM5rUzyqey0J8wMRLj+E0Vx0F1XELZeTtyulbIbhrBhu/KOXZG2zNIeK+2F - XxDlx9tD+bbcJfUCAwEAAaOBsTCBrjAdBgNVHQ4EFgQULjM9fwJnC3Tp1QYM8HNL - y60btl0wbAYDVR0jBGUwY4AULjM9fwJnC3Tp1QYM8HNLy60btl2hR6RFMEMxCzAJ - BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRAwDgYDVQQKEwdFeGFtcGxl - MQ0wCwYDVQQLEwRUZXN0ggIQATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE - AwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAR0Mk+2X/rr4kYYfHsQUIsROwDZSQhQr3 - QOeLc7fyTjkM96OHXN2dKVoOcpzgKi1goHW7lh8vVmKRQk2wfFqRZV9/kQBFK/gz - QtN5gp+pA8Wk912Uj5gD0loiPcRf5bDElvLnr2iwt4VdKkvGIYa9Eu9CYbkf1x3t - ahVLmrZLBkqvKxo4MG4KGYXkqtII3M6clM4ScFa/0rR1nGZOgZyqG7AMMHc01csA - oLlEZx2hUcpJbz+sfCGUWYaF2uKJvuWMNFbGSDhfs8pOMGgelMOHaKVtgOEfEASN - TSqzqn0vzjJ78Mi6mN7/6L/onDKzROxClw0hc6L+PIhIHftD1ckvVQ== - -----END CERTIFICATE-----""", - - """ - MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIn/uWtEzLDK8CAggA - MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIk7+JC4ErMDBIIEyA3yvNhMm/Oj - ZdkN0HSzPyLv9bOfUyyx4NA121kizZIq/FkUjn8pGxzU63rzMk2vU1hmp2/O3ymr - vmV7gzXRp4ULZCjFwn4cLxi9ieKgBOr9MmgTlRc1oZ9P/Y8eWhmjGxA2CU3fy7Kv - DyzftqAetV8YzTelk8xqxLrGevB16O3zDbFj4dcmG7a0i75kqlI8QyQklJ9uyE10 - SELWFlV6w+3GD82YrbR/8v4fE5KP/nAPbtN4h4C7MY3kJQL+apHr5B3Jst+6N62t - JzmxGS5z3ZVT3Bn3mxi8awo8/XS8s+ZOSnH6nHvz83NBUQwSkVbtujlg+yMD2jg4 - Nt3LWfLnF8Q6n4oAQ1ZP9KJyVIh8+PN12txIRoWq1pF74hJmbfVfiCSR/tMrw6lr - XqlkG1Mi7RmpTCz9ScTUBWY/dyScYFITenv/WE+UnfQ+DXBC+78lkmL36M0Rx/ip - S4O1Tgy/z/MIv1s+ZpAFsRRczlpo9lbVEMuSGEWWTIQJCRPFV8Y1NKHmWUgeZpl3 - 2YUjpHNyQt/a1s1h1g5w9+UNuABt/3cUUnlA7psueb6l4x6M92QFBOpe1xUDL51D - RpaipVl1luFWvE84hqgCIv8Kh9EbkAlclmK8CIOkMQAabk0GmhCfEdm+PCW61Cao - rfCMwZ9Bx6zAcXGRrvl0sK35z8C3r8wLftaS/5xF6RTJBy6XY2iiFW6D44qZDFbh - 0rWV8zDtCf2+OZtEvPkeUn3sjevDW78TM6F7HBjXAeIFrNyJGVe2CTlEJLoZi5pX - W1blhMJ93N1mLiDYisILANmJRBfGMt0tYE/pGcJRlkuqG0qylnqRojjL83CTQvFy - 46q/obR36enRDvCZPvQrX2dB7Vkgpkz/drZ6+avmKdQcTjY/ycCd3DclwexhgUoX - QDntZuJQLp7C4tFfHRy2uh4DOEjzMP6a/NQ3q7p6vc6BTNTFZRUAdyNwcEDIzSLM - nZSPFBiz+gukhtNSCO28kLc8OX1hYsSAMgzbImcMtAiQHG3bFAJ0cs0jF4U9VrJt - 4/97kiDBuCgGb2b5t0+uDqipE6G4B6494IGm5KoIPAPbXMJQstmuzjTJt95UTF+p - e60AnWIXcvEOouIIMzC7gH2g23St5Bo6NixfxcmVfkFa92TDlCTxEz5Z5mnma06k - Pao4Km1eJkYS/QaCDnCZs/yCAMhINUTTDd0/7Y9YE3Dmd5B1s2wOa+ovESSL3Mdv - dZoxh91QR+6hQuz3iYztC/BszMtATH8MznAoco0QFAhKi56Wppe+p1ATLWFMqk4W - elX9vtw5XLucKy5cMkQYh144SnrerlPJTAOGy0XXKunj8ceZfEN6zcS9Us9IN5aF - iENMFHjPsscrrKFhKypaMIn67PuIhVhw4PnGrWejr6TM1gUx+zOcRCwT+5ka2L7U - aqmgS8cDg5ZfAHcbig7No9kku/OSk+5QzkVKca2TZQHm++60oQTzRl3/NWiELO+e - Sl6r8i7dS0Kv3bB/AbLfIHtDgebxUh78qXMel/OUWd58ezxBS74rZ4AQTpYcdTbR - jKHploWi8h5yXYn/YdEZG1vW/zYseFNb7QKT5Cznucl8O/+lNZIOVw63Pq368dTD - tG1GZkIlwM+jlJjRew05YQ== - """), + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDtDCCApygAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx\n" + + "EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT\n" + + "BFRlc3QwHhcNMjIwMjI1MjAxMjA0WhcNNDIwMjIwMjAxMjA0WjBDMQswCQYDVQQG\n" + + "EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEQMA4GA1UEChMHRXhhbXBsZTENMAsG\n" + + "A1UECxMEVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOGhEDj\n" + + "lZ5R6o20kJdgrIRcY1he4qKLWQ4vU0thqAg4mEcKCZZn4/NL05UgJCFLwYaxMZZe\n" + + "etb/WaTRvQpDDFh7AhsMR24m6zKKJVk9E/e/8ur7sGDIVq8hZOBTq85ZdxPj/zKW\n" + + "wB1BR/RcY4DsGno1USlkV7TVeZc1qpJHTPImesevzH7zX8nhnFlf4TTQbpQt6RxU\n" + + "cr+udWpMOyP9xMerIyp7jpPy79tIaGP2x7ryt2BB9FU4RwPk4DcdfOkmdS86md1c\n" + + "GI9H5qM5rUzyqey0J8wMRLj+E0Vx0F1XELZeTtyulbIbhrBhu/KOXZG2zNIeK+2F\n" + + "XxDlx9tD+bbcJfUCAwEAAaOBsTCBrjAdBgNVHQ4EFgQULjM9fwJnC3Tp1QYM8HNL\n" + + "y60btl0wbAYDVR0jBGUwY4AULjM9fwJnC3Tp1QYM8HNLy60btl2hR6RFMEMxCzAJ\n" + + "BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRAwDgYDVQQKEwdFeGFtcGxl\n" + + "MQ0wCwYDVQQLEwRUZXN0ggIQATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE\n" + + "AwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAR0Mk+2X/rr4kYYfHsQUIsROwDZSQhQr3\n" + + "QOeLc7fyTjkM96OHXN2dKVoOcpzgKi1goHW7lh8vVmKRQk2wfFqRZV9/kQBFK/gz\n" + + "QtN5gp+pA8Wk912Uj5gD0loiPcRf5bDElvLnr2iwt4VdKkvGIYa9Eu9CYbkf1x3t\n" + + "ahVLmrZLBkqvKxo4MG4KGYXkqtII3M6clM4ScFa/0rR1nGZOgZyqG7AMMHc01csA\n" + + "oLlEZx2hUcpJbz+sfCGUWYaF2uKJvuWMNFbGSDhfs8pOMGgelMOHaKVtgOEfEASN\n" + + "TSqzqn0vzjJ78Mi6mN7/6L/onDKzROxClw0hc6L+PIhIHftD1ckvVQ==\n" + + "-----END CERTIFICATE-----", + + "MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIn/uWtEzLDK8CAggA\n" + + "MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECIk7+JC4ErMDBIIEyA3yvNhMm/Oj\n" + + "ZdkN0HSzPyLv9bOfUyyx4NA121kizZIq/FkUjn8pGxzU63rzMk2vU1hmp2/O3ymr\n" + + "vmV7gzXRp4ULZCjFwn4cLxi9ieKgBOr9MmgTlRc1oZ9P/Y8eWhmjGxA2CU3fy7Kv\n" + + "DyzftqAetV8YzTelk8xqxLrGevB16O3zDbFj4dcmG7a0i75kqlI8QyQklJ9uyE10\n" + + "SELWFlV6w+3GD82YrbR/8v4fE5KP/nAPbtN4h4C7MY3kJQL+apHr5B3Jst+6N62t\n" + + "JzmxGS5z3ZVT3Bn3mxi8awo8/XS8s+ZOSnH6nHvz83NBUQwSkVbtujlg+yMD2jg4\n" + + "Nt3LWfLnF8Q6n4oAQ1ZP9KJyVIh8+PN12txIRoWq1pF74hJmbfVfiCSR/tMrw6lr\n" + + "XqlkG1Mi7RmpTCz9ScTUBWY/dyScYFITenv/WE+UnfQ+DXBC+78lkmL36M0Rx/ip\n" + + "S4O1Tgy/z/MIv1s+ZpAFsRRczlpo9lbVEMuSGEWWTIQJCRPFV8Y1NKHmWUgeZpl3\n" + + "2YUjpHNyQt/a1s1h1g5w9+UNuABt/3cUUnlA7psueb6l4x6M92QFBOpe1xUDL51D\n" + + "RpaipVl1luFWvE84hqgCIv8Kh9EbkAlclmK8CIOkMQAabk0GmhCfEdm+PCW61Cao\n" + + "rfCMwZ9Bx6zAcXGRrvl0sK35z8C3r8wLftaS/5xF6RTJBy6XY2iiFW6D44qZDFbh\n" + + "0rWV8zDtCf2+OZtEvPkeUn3sjevDW78TM6F7HBjXAeIFrNyJGVe2CTlEJLoZi5pX\n" + + "W1blhMJ93N1mLiDYisILANmJRBfGMt0tYE/pGcJRlkuqG0qylnqRojjL83CTQvFy\n" + + "46q/obR36enRDvCZPvQrX2dB7Vkgpkz/drZ6+avmKdQcTjY/ycCd3DclwexhgUoX\n" + + "QDntZuJQLp7C4tFfHRy2uh4DOEjzMP6a/NQ3q7p6vc6BTNTFZRUAdyNwcEDIzSLM\n" + + "nZSPFBiz+gukhtNSCO28kLc8OX1hYsSAMgzbImcMtAiQHG3bFAJ0cs0jF4U9VrJt\n" + + "4/97kiDBuCgGb2b5t0+uDqipE6G4B6494IGm5KoIPAPbXMJQstmuzjTJt95UTF+p\n" + + "e60AnWIXcvEOouIIMzC7gH2g23St5Bo6NixfxcmVfkFa92TDlCTxEz5Z5mnma06k\n" + + "Pao4Km1eJkYS/QaCDnCZs/yCAMhINUTTDd0/7Y9YE3Dmd5B1s2wOa+ovESSL3Mdv\n" + + "dZoxh91QR+6hQuz3iYztC/BszMtATH8MznAoco0QFAhKi56Wppe+p1ATLWFMqk4W\n" + + "elX9vtw5XLucKy5cMkQYh144SnrerlPJTAOGy0XXKunj8ceZfEN6zcS9Us9IN5aF\n" + + "iENMFHjPsscrrKFhKypaMIn67PuIhVhw4PnGrWejr6TM1gUx+zOcRCwT+5ka2L7U\n" + + "aqmgS8cDg5ZfAHcbig7No9kku/OSk+5QzkVKca2TZQHm++60oQTzRl3/NWiELO+e\n" + + "Sl6r8i7dS0Kv3bB/AbLfIHtDgebxUh78qXMel/OUWd58ezxBS74rZ4AQTpYcdTbR\n" + + "jKHploWi8h5yXYn/YdEZG1vW/zYseFNb7QKT5Cznucl8O/+lNZIOVw63Pq368dTD\n" + + "tG1GZkIlwM+jlJjRew05YQ==" + ), // Version: 3 (0x2) // Serial Number: 4098 (0x1002) @@ -149,57 +148,56 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) SERVER_EXAMPLE_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDaTCCAlGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAzMTI5WhcNNDIwMjE5MjAzMTI5WjBdMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG - A1UECwwEVGVzdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMIIBIjANBgkqhkiG - 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3crcRzecIV08Muh6kA0CuVKnPkU2bLC+6bpV - 7/iBZ4D3qMwO8Q02+gP71pPNoAQ1nsifxR4k9mBVYOjar35RVpuFmLRRVMargrxg - 4WWDfVgLMhOeCy8+Tl4Mp/yRL3nkr0MJd57RCOPcPE84J/1Crq1Luy2+hsXSj25L - VJKx2o6LE0tfwPWnufdNUHzHRuNoBR83OpqIT0uXH15THZS+0ZcQwrJMcKYe4JWl - 6oXWcsWbtTG+r7QLIRKck2IG7jjHFpE83Q6Iv2HkhctgGZofwSTZyMmJ8eClovva - WFLDaLL2WuI3NwZM//knjMyfsEWtWsILXayCn5NTT74ClQjWQQIDAQABo00wSzAJ - BgNVHRMEAjAAMB0GA1UdDgQWBBQ9nPjenO4PMLtMTBddNiIDsPywjzAfBgNVHSME - GDAWgBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEAVOvM - fMDOxOCkWB244cx7J+f2qZU6/1qGlJUiL0WRLRj1XEmB8AYSZEb6Os1suF8sotka - nA9Aw1SFA/wNyrSKazXNlOKo0In1mu/OjHU7n6XYVAyDmFGziYY8zTqG1h8ZPrI7 - oAkNgnNDwmwy7uCAvMj+Q4QQ0Q4YxTHV/i3X1HuEwThRgz9cJGdDRIAsimRHDSDO - 5hsIJo6VASz0ISrYMxNZQ1og+XktdNssPK616bPf+APwXXnsWSuGkIdGDU059DII - cTSsLTbWkTWDXAAQo+sfDZUrvqopCK000eoywEmPQrTf7O8oAQdRvTsyxwMvOONd - EWQ9pDW9+RC8l5DtRA== - -----END CERTIFICATE-----""", - - """ - MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDdytxHN5whXTwy - 6HqQDQK5Uqc+RTZssL7pulXv+IFngPeozA7xDTb6A/vWk82gBDWeyJ/FHiT2YFVg - 6NqvflFWm4WYtFFUxquCvGDhZYN9WAsyE54LLz5OXgyn/JEveeSvQwl3ntEI49w8 - Tzgn/UKurUu7Lb6GxdKPbktUkrHajosTS1/A9ae5901QfMdG42gFHzc6mohPS5cf - XlMdlL7RlxDCskxwph7glaXqhdZyxZu1Mb6vtAshEpyTYgbuOMcWkTzdDoi/YeSF - y2AZmh/BJNnIyYnx4KWi+9pYUsNosvZa4jc3Bkz/+SeMzJ+wRa1awgtdrIKfk1NP - vgKVCNZBAgMBAAECggEBAMUMAtJe7J6Tx/TuqF0swfvGHAHt2eGM0cCzpMATh1xe - rylPSgMNG4faXDcSj4AX3U+ZrKCjHHGruo7jsc5yqm8IsxOtOAjajOwU0vnNh5mn - zCKMXUBQk8lqM1JXyOFmKS8wnsug1NRSJIuMUjbtAf5QxlSg2oHAZUa61cBoqAyk - KXbw9uBYnM4n8WGXdax/LLPuonjnz2Sc35CC1LhRAF/K7oyjg7KvScnphIFRaLiU - X4tFH0nLpcao5de0fP5eUEkbUZ3hE6MEZvOsxn5CFkjH2VdtZ9D5dc3ArV3UMe26 - +3swdenriYZ73HNJDiLAdeIVh9IrGVxhH9UowF9psIUCgYEA/Ldlx4vTTlM7URFn - luqK7D8WH9x4JiCLEGxU80nJxxIgF8eqhOFzsQemytTrf4o1xAkyyPIweHzwApCA - lBdwC4Mc44DjoLFVdTET9hEq7E/UK81znc0mD4v8Hz2JI6h3f2sQrcEAPBvjBwtc - TpS9WlSBKSO3NOb3Hlucq7COVKcCgYEA4KyZ+dOyKVLyGjd0g22v4YW7VC016Hql - uQ7SN1vuI3zQMa2rZfEv5z2L7olJKrDFcmqk8W1tfElrMaSsuohm8khhx0lPtHMw - 4Su/tci/3rEUl+DPrQExdjrrDXCqpUunOAlMP9qElsNBGdkrQ6QlMnSVVi2v8Vf1 - f86Mey2UEtcCgYEAqcOlmqPigfZFnZLcjLPoOQW0HhkjmTE5WgH8GybRZmpVpsPZ - V8R/zEeAkzbvMFEvBw7Kz9RqHTaIoKBjz5fjC8i7ClVWFGesKbqbVyx3MiH6PKaa - aUIbtEvsRSw4SPztsWnB3YcOWlK9csj97Efc36Zu0a0NcHtLPFh8aZWEN3cCgYEA - oQFv8oWPlmeXkcwN1iWjtfT1EtS3XhuOaXjCkuNxW8MVG5S+UHawAoGrpsyBP3Og - e2cLPuxRWpDunYvKMH6Rb60JTRwvXzxxWdvVLbtoLHkwLcrwaKWDQZvlWCNWVtBJ - TDH1j4jUHYpdO93SUE3wTiEX58Mj48tJ5kYpjBhUlc8CgYEA7PG3ORGqZtfCiNmj - CxvPtQiFC+ogf+v8cMQtrKVTgpnI2pxzG+cSXYvL4cnyY2JnwqarWorUic8JU2e2 - EhW53PWUg7VpITlLsqOpATIDiviFAN4qOOxgDt5v0C1PyB3aXe2B5VA3IgczssyR - OLy7p/DhOpu2bqnpKyIkAuzZgFc= - """), + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDaTCCAlGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx\n" + + "EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT\n" + + "BFRlc3QwHhcNMjIwMjI1MjAzMTI5WhcNNDIwMjE5MjAzMTI5WjBdMQswCQYDVQQG\n" + + "EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG\n" + + "A1UECwwEVGVzdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMIIBIjANBgkqhkiG\n" + + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3crcRzecIV08Muh6kA0CuVKnPkU2bLC+6bpV\n" + + "7/iBZ4D3qMwO8Q02+gP71pPNoAQ1nsifxR4k9mBVYOjar35RVpuFmLRRVMargrxg\n" + + "4WWDfVgLMhOeCy8+Tl4Mp/yRL3nkr0MJd57RCOPcPE84J/1Crq1Luy2+hsXSj25L\n" + + "VJKx2o6LE0tfwPWnufdNUHzHRuNoBR83OpqIT0uXH15THZS+0ZcQwrJMcKYe4JWl\n" + + "6oXWcsWbtTG+r7QLIRKck2IG7jjHFpE83Q6Iv2HkhctgGZofwSTZyMmJ8eClovva\n" + + "WFLDaLL2WuI3NwZM//knjMyfsEWtWsILXayCn5NTT74ClQjWQQIDAQABo00wSzAJ\n" + + "BgNVHRMEAjAAMB0GA1UdDgQWBBQ9nPjenO4PMLtMTBddNiIDsPywjzAfBgNVHSME\n" + + "GDAWgBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEAVOvM\n" + + "fMDOxOCkWB244cx7J+f2qZU6/1qGlJUiL0WRLRj1XEmB8AYSZEb6Os1suF8sotka\n" + + "nA9Aw1SFA/wNyrSKazXNlOKo0In1mu/OjHU7n6XYVAyDmFGziYY8zTqG1h8ZPrI7\n" + + "oAkNgnNDwmwy7uCAvMj+Q4QQ0Q4YxTHV/i3X1HuEwThRgz9cJGdDRIAsimRHDSDO\n" + + "5hsIJo6VASz0ISrYMxNZQ1og+XktdNssPK616bPf+APwXXnsWSuGkIdGDU059DII\n" + + "cTSsLTbWkTWDXAAQo+sfDZUrvqopCK000eoywEmPQrTf7O8oAQdRvTsyxwMvOONd\n" + + "EWQ9pDW9+RC8l5DtRA==\n" + + "-----END CERTIFICATE-----", + + "MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDdytxHN5whXTwy\n" + + "6HqQDQK5Uqc+RTZssL7pulXv+IFngPeozA7xDTb6A/vWk82gBDWeyJ/FHiT2YFVg\n" + + "6NqvflFWm4WYtFFUxquCvGDhZYN9WAsyE54LLz5OXgyn/JEveeSvQwl3ntEI49w8\n" + + "Tzgn/UKurUu7Lb6GxdKPbktUkrHajosTS1/A9ae5901QfMdG42gFHzc6mohPS5cf\n" + + "XlMdlL7RlxDCskxwph7glaXqhdZyxZu1Mb6vtAshEpyTYgbuOMcWkTzdDoi/YeSF\n" + + "y2AZmh/BJNnIyYnx4KWi+9pYUsNosvZa4jc3Bkz/+SeMzJ+wRa1awgtdrIKfk1NP\n" + + "vgKVCNZBAgMBAAECggEBAMUMAtJe7J6Tx/TuqF0swfvGHAHt2eGM0cCzpMATh1xe\n" + + "rylPSgMNG4faXDcSj4AX3U+ZrKCjHHGruo7jsc5yqm8IsxOtOAjajOwU0vnNh5mn\n" + + "zCKMXUBQk8lqM1JXyOFmKS8wnsug1NRSJIuMUjbtAf5QxlSg2oHAZUa61cBoqAyk\n" + + "KXbw9uBYnM4n8WGXdax/LLPuonjnz2Sc35CC1LhRAF/K7oyjg7KvScnphIFRaLiU\n" + + "X4tFH0nLpcao5de0fP5eUEkbUZ3hE6MEZvOsxn5CFkjH2VdtZ9D5dc3ArV3UMe26\n" + + "+3swdenriYZ73HNJDiLAdeIVh9IrGVxhH9UowF9psIUCgYEA/Ldlx4vTTlM7URFn\n" + + "luqK7D8WH9x4JiCLEGxU80nJxxIgF8eqhOFzsQemytTrf4o1xAkyyPIweHzwApCA\n" + + "lBdwC4Mc44DjoLFVdTET9hEq7E/UK81znc0mD4v8Hz2JI6h3f2sQrcEAPBvjBwtc\n" + + "TpS9WlSBKSO3NOb3Hlucq7COVKcCgYEA4KyZ+dOyKVLyGjd0g22v4YW7VC016Hql\n" + + "uQ7SN1vuI3zQMa2rZfEv5z2L7olJKrDFcmqk8W1tfElrMaSsuohm8khhx0lPtHMw\n" + + "4Su/tci/3rEUl+DPrQExdjrrDXCqpUunOAlMP9qElsNBGdkrQ6QlMnSVVi2v8Vf1\n" + + "f86Mey2UEtcCgYEAqcOlmqPigfZFnZLcjLPoOQW0HhkjmTE5WgH8GybRZmpVpsPZ\n" + + "V8R/zEeAkzbvMFEvBw7Kz9RqHTaIoKBjz5fjC8i7ClVWFGesKbqbVyx3MiH6PKaa\n" + + "aUIbtEvsRSw4SPztsWnB3YcOWlK9csj97Efc36Zu0a0NcHtLPFh8aZWEN3cCgYEA\n" + + "oQFv8oWPlmeXkcwN1iWjtfT1EtS3XhuOaXjCkuNxW8MVG5S+UHawAoGrpsyBP3Og\n" + + "e2cLPuxRWpDunYvKMH6Rb60JTRwvXzxxWdvVLbtoLHkwLcrwaKWDQZvlWCNWVtBJ\n" + + "TDH1j4jUHYpdO93SUE3wTiEX58Mj48tJ5kYpjBhUlc8CgYEA7PG3ORGqZtfCiNmj\n" + + "CxvPtQiFC+ogf+v8cMQtrKVTgpnI2pxzG+cSXYvL4cnyY2JnwqarWorUic8JU2e2\n" + + "EhW53PWUg7VpITlLsqOpATIDiviFAN4qOOxgDt5v0C1PyB3aXe2B5VA3IgczssyR\n" + + "OLy7p/DhOpu2bqnpKyIkAuzZgFc=" + ), // Version: 3 (0x2) @@ -214,57 +212,56 @@ public enum SSLExampleCert { // Public Key Algorithm: rsaEncryption // RSA Public-Key: (2048 bit) CLIENT_EXAMPLE_RSA("RSA", - """ - -----BEGIN CERTIFICATE----- - MIIDZjCCAk6gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx - EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT - BFRlc3QwHhcNMjIwMjI1MjAzMzU5WhcNNDIwMjE5MjAzMzU5WjBaMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG - A1UECwwEVGVzdDEVMBMGA1UEAwwMRG8tTm90LVJlcGx5MIIBIjANBgkqhkiG9w0B - AQEFAAOCAQ8AMIIBCgKCAQEA2yJgm3Lthr+97vdEWTb4zaNuLTa/DkCXdmVNIQk9 - kVn2hjZrPc+JghBCaWpohGVTQ+zxplIJXk+QVZ0ePEimE7ahBClz4MlAgMpt1uxy - mYYUAsSZDCaFUI9Cpx1f0BiSWu330196K/AfRIoT+/SOZucnpbepxyrt+Az5SKrH - TJR/OSqeX4XKGPoRI96pKxDOV8pY5/I9h9yKGuxfufbpOdVODngVLcMKgBAkiD+2 - sguEHM+iGLx970+W6yycu1dFY1CAgWLUF3evUxe8avwePgx7lTFXnNueYt96Ny9v - L1o/WzoBe3z1mTl5Qb//3tYbXn8vdiDYm0dT8wImpDbpvwIDAQABo00wSzAJBgNV - HRMEAjAAMB0GA1UdDgQWBBSXqW/B1BVjNgowSwa3MBiHMkzp6zAfBgNVHSMEGDAW - gBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEABIMAjT5T - lZDV/1wmdKCyJQJ7WUjA44N5/yBGtEmpAJ0VM7/COnk8lqiYxrk50wK7lt0tiklX - 4aLqbAgnDc27z9AQGHOqB69dZprGQT9PsTByjK6i7KPGs30ygyND41j0rju/GM2e - 3xprZbusODENRyL196QV4ai0WVe1hEvv0wTMIcnXYmZHMP8ArdVRHWaDQF6zW0Mh - QbFqklt5W0ZIl2ZmC8z7z2Z6jv/BYyDo3U96LfdCWsEKxSKiX/PGHqZu4D3A4VSE - 0+fE7cX61kgRdGvZJgFjtYxtfkXd1HlyJ48Dqilzl+rvgvR5XA68zijjN0khPhml - wZhPIOCIaWMZYw== - -----END CERTIFICATE-----""", - - """ - MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbImCbcu2Gv73u - 90RZNvjNo24tNr8OQJd2ZU0hCT2RWfaGNms9z4mCEEJpamiEZVND7PGmUgleT5BV - nR48SKYTtqEEKXPgyUCAym3W7HKZhhQCxJkMJoVQj0KnHV/QGJJa7ffTX3or8B9E - ihP79I5m5yelt6nHKu34DPlIqsdMlH85Kp5fhcoY+hEj3qkrEM5Xyljn8j2H3Ioa - 7F+59uk51U4OeBUtwwqAECSIP7ayC4Qcz6IYvH3vT5brLJy7V0VjUICBYtQXd69T - F7xq/B4+DHuVMVec255i33o3L28vWj9bOgF7fPWZOXlBv//e1htefy92INibR1Pz - AiakNum/AgMBAAECggEAW0WxWW4AMyzwDnWdWU+FSBm3TUvNPkF3FNBS1NzFcSI4 - hWRrPJ6R1sOw9blleSe/C77IVA89abPYGWDM9C0KR5G89T/SzSDmJf6qy2dGwF1R - PmnmmWH+CzTwfSzF+KYTZ55QqBDPkTd9vo2Ij1woaAIFyId8RsHBxpyYxESlqGY4 - C6IzEqxFQ0obHXasNR+dP4iOWS4ONhxeUHixcrDHxbmoqmHt0WuJwXhlOjxHgr+i - lUPTe5y+Y2B1gVNYrN4KlDTJqJ6lu4n6MFQ46jhfddzTk3uiEOTVWK6nE8Cf0NM7 - djTzTcR8xAVpoY5XDlk0aBfEd8Np7TLSjV4vU3J04QKBgQD6scazH/H9Yu9ZbR7w - EeN/k7uDDlgahWg8/93syzdFtSNIRGvdalNMhTfM/zXaM/Cl63gvZilWxC+56Uvg - 6QC+rBUwzZrm7ryb6hT6Zyoo4w72bw3jGOJ3e2/bclSLrAcJnL/1Gq87J3CS16wl - NIHrlOlY8orToEdki+6HaagyEQKBgQDfxZz4Uqsa+jDO/rEm959+nz2RkaXYu1Ld - DhYONxmlw69/BbwzOvzr88qKNbd+b+oIK8kpm7Lvpc2/cuqItTFdehmw+tGhMWYo - XizKCeKeCByFTjXI2/PEPUHMy0D8M68Tx/Hq0NbIYqCyzkaamHhXpuJGftxGfd3/ - U0NB4WGOzwKBgQDgnyN7YfcwY1I0XUqoLk8aA2Oy5MpaUQh6B4RwZBENO2T2np/L - TzZ9zKuX2WAGOB26fMY+KhqGLNjaike7qOpK7eM6zC6sFmMWjGHpj0A+TFwewJi/ - z48zIX2zMbjBQQ05NqLkWdmCdi8u02HiIC78x3thgEiVn/n4BE1gNXJIEQKBgEdr - dfcXw36/vZZDWd07CU/LmUX9u3YaC498MHPnCCuM8lVTSkb7m7/fNpS4IlGbfJGR - EApUpF6yh6GEFvD9C71u/AYtd3zAHH/j1t3BG/AeXKP7W1U5RmsqtfacJKiaAlYI - 6eBtOTAJsop/Ja+v3DD1laC0Wq+w+orEU2ISgiWnAoGBAK9/9m3RCYPNYzS/PQ2B - AgE2FQRuY8FXxHegZo2tBBwIojPeVHO1OoThYVNgiQfW9k27dFkRwXVAtt6Jqgax - fvOby8rWRStXH2qHVyvHicceL7iXs6v2bX20Szsy44eMkoFfAImea6ZdErLdVWvI - fxlYpTIVpBt3Nu2BRJn28ili - """); + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDZjCCAk6gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx\n" + + "EzARBgNVBAgTCkNhbGlmb3JuaWExEDAOBgNVBAoTB0V4YW1wbGUxDTALBgNVBAsT\n" + + "BFRlc3QwHhcNMjIwMjI1MjAzMzU5WhcNNDIwMjE5MjAzMzU5WjBaMQswCQYDVQQG\n" + + "EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEQMA4GA1UECgwHRXhhbXBsZTENMAsG\n" + + "A1UECwwEVGVzdDEVMBMGA1UEAwwMRG8tTm90LVJlcGx5MIIBIjANBgkqhkiG9w0B\n" + + "AQEFAAOCAQ8AMIIBCgKCAQEA2yJgm3Lthr+97vdEWTb4zaNuLTa/DkCXdmVNIQk9\n" + + "kVn2hjZrPc+JghBCaWpohGVTQ+zxplIJXk+QVZ0ePEimE7ahBClz4MlAgMpt1uxy\n" + + "mYYUAsSZDCaFUI9Cpx1f0BiSWu330196K/AfRIoT+/SOZucnpbepxyrt+Az5SKrH\n" + + "TJR/OSqeX4XKGPoRI96pKxDOV8pY5/I9h9yKGuxfufbpOdVODngVLcMKgBAkiD+2\n" + + "sguEHM+iGLx970+W6yycu1dFY1CAgWLUF3evUxe8avwePgx7lTFXnNueYt96Ny9v\n" + + "L1o/WzoBe3z1mTl5Qb//3tYbXn8vdiDYm0dT8wImpDbpvwIDAQABo00wSzAJBgNV\n" + + "HRMEAjAAMB0GA1UdDgQWBBSXqW/B1BVjNgowSwa3MBiHMkzp6zAfBgNVHSMEGDAW\n" + + "gBQuMz1/AmcLdOnVBgzwc0vLrRu2XTANBgkqhkiG9w0BAQsFAAOCAQEABIMAjT5T\n" + + "lZDV/1wmdKCyJQJ7WUjA44N5/yBGtEmpAJ0VM7/COnk8lqiYxrk50wK7lt0tiklX\n" + + "4aLqbAgnDc27z9AQGHOqB69dZprGQT9PsTByjK6i7KPGs30ygyND41j0rju/GM2e\n" + + "3xprZbusODENRyL196QV4ai0WVe1hEvv0wTMIcnXYmZHMP8ArdVRHWaDQF6zW0Mh\n" + + "QbFqklt5W0ZIl2ZmC8z7z2Z6jv/BYyDo3U96LfdCWsEKxSKiX/PGHqZu4D3A4VSE\n" + + "0+fE7cX61kgRdGvZJgFjtYxtfkXd1HlyJ48Dqilzl+rvgvR5XA68zijjN0khPhml\n" + + "wZhPIOCIaWMZYw==\n" + + "-----END CERTIFICATE-----", + + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbImCbcu2Gv73u\n" + + "90RZNvjNo24tNr8OQJd2ZU0hCT2RWfaGNms9z4mCEEJpamiEZVND7PGmUgleT5BV\n" + + "nR48SKYTtqEEKXPgyUCAym3W7HKZhhQCxJkMJoVQj0KnHV/QGJJa7ffTX3or8B9E\n" + + "ihP79I5m5yelt6nHKu34DPlIqsdMlH85Kp5fhcoY+hEj3qkrEM5Xyljn8j2H3Ioa\n" + + "7F+59uk51U4OeBUtwwqAECSIP7ayC4Qcz6IYvH3vT5brLJy7V0VjUICBYtQXd69T\n" + + "F7xq/B4+DHuVMVec255i33o3L28vWj9bOgF7fPWZOXlBv//e1htefy92INibR1Pz\n" + + "AiakNum/AgMBAAECggEAW0WxWW4AMyzwDnWdWU+FSBm3TUvNPkF3FNBS1NzFcSI4\n" + + "hWRrPJ6R1sOw9blleSe/C77IVA89abPYGWDM9C0KR5G89T/SzSDmJf6qy2dGwF1R\n" + + "PmnmmWH+CzTwfSzF+KYTZ55QqBDPkTd9vo2Ij1woaAIFyId8RsHBxpyYxESlqGY4\n" + + "C6IzEqxFQ0obHXasNR+dP4iOWS4ONhxeUHixcrDHxbmoqmHt0WuJwXhlOjxHgr+i\n" + + "lUPTe5y+Y2B1gVNYrN4KlDTJqJ6lu4n6MFQ46jhfddzTk3uiEOTVWK6nE8Cf0NM7\n" + + "djTzTcR8xAVpoY5XDlk0aBfEd8Np7TLSjV4vU3J04QKBgQD6scazH/H9Yu9ZbR7w\n" + + "EeN/k7uDDlgahWg8/93syzdFtSNIRGvdalNMhTfM/zXaM/Cl63gvZilWxC+56Uvg\n" + + "6QC+rBUwzZrm7ryb6hT6Zyoo4w72bw3jGOJ3e2/bclSLrAcJnL/1Gq87J3CS16wl\n" + + "NIHrlOlY8orToEdki+6HaagyEQKBgQDfxZz4Uqsa+jDO/rEm959+nz2RkaXYu1Ld\n" + + "DhYONxmlw69/BbwzOvzr88qKNbd+b+oIK8kpm7Lvpc2/cuqItTFdehmw+tGhMWYo\n" + + "XizKCeKeCByFTjXI2/PEPUHMy0D8M68Tx/Hq0NbIYqCyzkaamHhXpuJGftxGfd3/\n" + + "U0NB4WGOzwKBgQDgnyN7YfcwY1I0XUqoLk8aA2Oy5MpaUQh6B4RwZBENO2T2np/L\n" + + "TzZ9zKuX2WAGOB26fMY+KhqGLNjaike7qOpK7eM6zC6sFmMWjGHpj0A+TFwewJi/\n" + + "z48zIX2zMbjBQQ05NqLkWdmCdi8u02HiIC78x3thgEiVn/n4BE1gNXJIEQKBgEdr\n" + + "dfcXw36/vZZDWd07CU/LmUX9u3YaC498MHPnCCuM8lVTSkb7m7/fNpS4IlGbfJGR\n" + + "EApUpF6yh6GEFvD9C71u/AYtd3zAHH/j1t3BG/AeXKP7W1U5RmsqtfacJKiaAlYI\n" + + "6eBtOTAJsop/Ja+v3DD1laC0Wq+w+orEU2ISgiWnAoGBAK9/9m3RCYPNYzS/PQ2B\n" + + "AgE2FQRuY8FXxHegZo2tBBwIojPeVHO1OoThYVNgiQfW9k27dFkRwXVAtt6Jqgax\n" + + "fvOby8rWRStXH2qHVyvHicceL7iXs6v2bX20Szsy44eMkoFfAImea6ZdErLdVWvI\n" + + "fxlYpTIVpBt3Nu2BRJn28ili" + ); final String keyAlgo; final String certStr; From 62191cd7e159d5da0e7f466cbf665fa9a4bb6787 Mon Sep 17 00:00:00 2001 From: Joshua Cao Date: Tue, 3 Jan 2023 17:46:05 +0000 Subject: [PATCH 041/205] 8221621: FindTests.gmk cannot handle "=" in TEST.groups comments Backport-of: 88db8649dfe5788e2cb19bacae497a6c01d10d9c --- make/common/FindTests.gmk | 1 + 1 file changed, 1 insertion(+) diff --git a/make/common/FindTests.gmk b/make/common/FindTests.gmk index 35a9e20f305..283f93e918f 100644 --- a/make/common/FindTests.gmk +++ b/make/common/FindTests.gmk @@ -53,6 +53,7 @@ define FindJtregGroupsBody -e 's/^groups\w*=//p' $1/TEST.ROOT) $1_JTREG_GROUP_FILES := $$(addprefix $1/, $$($1_JTREG_GROUP_FILENAMES)) $1_JTREG_TEST_GROUPS := $$(strip $$(shell $$(SED) -n \ + -e 's/^\#.*//g' \ -e 's/\([^ ]*\)\w*=.*/\1/gp' $$(wildcard $$($1_JTREG_GROUP_FILES)) \ | $$(SORT) -u)) endif From d2c8326ac79142f834e3a1e92484a45735c6c4a8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Jan 2023 10:25:53 +0000 Subject: [PATCH 042/205] 8210373: Deadlock in libj2gss.so when loading "j2gss" and "net" libraries in parallel. Backport-of: 991f7c1303998b090cdc25f87b253afaf7302ec6 --- .../sun/security/jgss/wrapper/SunNativeProvider.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java index 78db8bc9b60..b3d31f1a215 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -73,8 +73,12 @@ public HashMap run() { DEBUG = Boolean.parseBoolean (System.getProperty(DEBUG_PROP)); try { + // Ensure the InetAddress class is loaded before + // loading j2gss. The library will access this class + // and a deadlock might happen. See JDK-8210373. + Class.forName("java.net.InetAddress"); System.loadLibrary("j2gss"); - } catch (Error err) { + } catch (ClassNotFoundException | Error err) { debug("No j2gss library found!"); if (DEBUG) err.printStackTrace(); return null; From d8450efaca8a61ffa026dd4477ac024b2e801680 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Jan 2023 10:27:25 +0000 Subject: [PATCH 043/205] 8271506: Add ResourceHashtable support for deleting selected entries Reviewed-by: mbaesken Backport-of: 0b51fe2bce55991e608352954a2266f4702642bf --- src/hotspot/share/utilities/resourceHash.hpp | 26 +++++++++++++++++++ .../gtest/utilities/test_resourceHash.cpp | 25 ++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/hotspot/share/utilities/resourceHash.hpp b/src/hotspot/share/utilities/resourceHash.hpp index 6941d407ad8..df773c9c1e6 100644 --- a/src/hotspot/share/utilities/resourceHash.hpp +++ b/src/hotspot/share/utilities/resourceHash.hpp @@ -173,6 +173,32 @@ class ResourceHashtable : public ResourceObj { static size_t node_size() { return sizeof(Node); } + + // ITER contains bool do_entry(K const&, V const&), which will be + // called for each entry in the table. If do_entry() returns true, + // the entry is deleted. + template + void unlink(ITER* iter) { + Node** bucket = const_cast(_table); + while (bucket < &_table[SIZE]) { + Node** ptr = bucket; + while (*ptr != NULL) { + Node* node = *ptr; + // do_entry must clean up the key and value in Node. + bool clean = iter->do_entry(node->_key, node->_value); + if (clean) { + *ptr = node->_next; + if (ALLOC_TYPE == ResourceObj::C_HEAP) { + delete node; + } + } else { + ptr = &(node->_next); + } + } + ++bucket; + } + } + }; diff --git a/test/hotspot/gtest/utilities/test_resourceHash.cpp b/test/hotspot/gtest/utilities/test_resourceHash.cpp index bca28ea0754..29b557d3015 100644 --- a/test/hotspot/gtest/utilities/test_resourceHash.cpp +++ b/test/hotspot/gtest/utilities/test_resourceHash.cpp @@ -58,6 +58,22 @@ class CommonResourceHashtableTest : public ::testing::Test { } } }; + + class DeleterTestIter { + int _val; + public: + DeleterTestIter(int i) : _val(i) {} + + bool do_entry(K const& k, V const& v) { + if ((uintptr_t) k == (uintptr_t) _val) { + // Delete me! + return true; + } else { + return false; // continue iteration + } + } + }; + }; class SmallResourceHashtableTest : public CommonResourceHashtableTest { @@ -194,6 +210,15 @@ class GenericResourceHashtableTest : public CommonResourceHashtableTest { ASSERT_FALSE(rh.remove(as_K(index))); } rh.iterate(&et); + + // Add more entries in and then delete one. + for (uintptr_t i = 10; i > 0; --i) { + uintptr_t index = i - 1; + ASSERT_TRUE(rh.put(as_K(index), index)); + } + DeleterTestIter dt(5); + rh.unlink(&dt); + ASSERT_FALSE(rh.get(as_K(5))); } }; }; From 52737cd0da1a89693b06622e4c4ce89d0da0118a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Jan 2023 10:30:21 +0000 Subject: [PATCH 044/205] 8280401: [sspi] gss_accept_sec_context leaves output_token uninitialized Backport-of: 6352c020c25f2701afb4fabee0cc7fcef2d407fb --- .../windows/native/libsspi_bridge/sspi.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp b/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp index 96f994ba43e..173202d3e70 100644 --- a/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp +++ b/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp @@ -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 @@ -1035,6 +1035,10 @@ gss_accept_sec_context(OM_uint32 *minor_status, { PP(">>>> Calling UNIMPLEMENTED gss_accept_sec_context..."); PP("gss_accept_sec_context is not supported in this initiator-only library"); + if (output_token) { + output_token->length = 0; + output_token->value = NULL; + } return GSS_S_FAILURE; } From 60732964fda512ef03d0107c1e8226aaa123ed7e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 4 Jan 2023 21:57:28 +0000 Subject: [PATCH 045/205] 8299616: [11u] Bootcycle build fails after JDK-8257679 backport Reviewed-by: andrew, clanger --- make/autoconf/bootcycle-spec.gmk.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/make/autoconf/bootcycle-spec.gmk.in b/make/autoconf/bootcycle-spec.gmk.in index f7056140b79..cbd3551ff81 100644 --- a/make/autoconf/bootcycle-spec.gmk.in +++ b/make/autoconf/bootcycle-spec.gmk.in @@ -28,11 +28,19 @@ # First include the real base spec.gmk file include @SPEC@ -# Override specific values to do a boot cycle build +# Check that the user did not try to specify a different java to use for compiling. +# On windows we need to account for fixpath being first word. +ifeq ($(firstword $(JAVA)),$(FIXPATH)) + JAVA_EXEC_POS=2 +else + JAVA_EXEC_POS=1 +endif ifneq ($(word $(JAVA_EXEC_POS),$(SJAVAC_SERVER_JAVA)),$(word $(JAVA_EXEC_POS),$(JAVA))) $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified) endif +# Override specific values to do a boot cycle build + # Use a different Boot JDK BOOT_JDK := $(JDK_IMAGE_DIR) From ff60b348813fd7e32bdda322f345f90311a60207 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 07:54:00 +0000 Subject: [PATCH 046/205] 8296239: ISO 4217 Amendment 174 Update Backport-of: fd837649811c866c144c9133d211fb5ad8f994a7 --- make/data/currency/CurrencyData.properties | 4 ++-- test/jdk/java/util/Currency/ValidateISO4217.java | 4 ++-- test/jdk/java/util/Currency/tablea1.txt | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/make/data/currency/CurrencyData.properties b/make/data/currency/CurrencyData.properties index 688de592c7b..d234c96c476 100644 --- a/make/data/currency/CurrencyData.properties +++ b/make/data/currency/CurrencyData.properties @@ -32,7 +32,7 @@ formatVersion=3 # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. -dataVersion=173 +dataVersion=174 # List of all valid ISO 4217 currency codes. # To ensure compatibility, do not remove codes. @@ -189,7 +189,7 @@ CR=CRC # COTE D'IVOIRE CI=XOF # CROATIA -HR=HRK +HR=HRK;2022-12-31-23-00-00;EUR # CUBA CU=CUP # Cura\u00e7ao diff --git a/test/jdk/java/util/Currency/ValidateISO4217.java b/test/jdk/java/util/Currency/ValidateISO4217.java index a0f09842ffe..1644153b28a 100644 --- a/test/jdk/java/util/Currency/ValidateISO4217.java +++ b/test/jdk/java/util/Currency/ValidateISO4217.java @@ -24,7 +24,7 @@ * @test * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 * 8039317 8074350 8074351 8145952 8187946 8193552 8202026 8204269 - * 8208746 8209775 8264792 8274658 8283277 + * 8208746 8209775 8264792 8274658 8283277 8296239 * @summary Validate ISO 4217 data for Currency class. * @modules java.base/java.util:open * jdk.localedata @@ -34,7 +34,7 @@ * ############################################################################ * * ValidateISO4217 is a tool to detect differences between the latest ISO 4217 - * data and and Java's currency data which is based on 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 diff --git a/test/jdk/java/util/Currency/tablea1.txt b/test/jdk/java/util/Currency/tablea1.txt index 3e107823042..3eef0eba00e 100644 --- a/test/jdk/java/util/Currency/tablea1.txt +++ b/test/jdk/java/util/Currency/tablea1.txt @@ -1,12 +1,12 @@ # # -# Amendments up until ISO 4217 AMENDMENT NUMBER 173 -# (As of 23 September 2022) +# Amendments up until ISO 4217 AMENDMENT NUMBER 174 +# (As of 2 November 2022) # # Version FILEVERSION=3 -DATAVERSION=173 +DATAVERSION=174 # ISO 4217 currency data AF AFN 971 2 @@ -67,7 +67,7 @@ CD CDF 976 2 CK NZD 554 2 CR CRC 188 2 CI XOF 952 0 -HR HRK 191 2 +HR HRK 191 2 2022-12-31-23-00-00 EUR 978 2 CU CUP 192 2 CW ANG 532 2 CY EUR 978 2 From 13eadde75be0c5d3ca170b138b5e7ef00a93bcf6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 21:00:32 +0000 Subject: [PATCH 047/205] 8215372: test/jdk/java/nio/file/DirectoryStream/Basic.java not correct when using a glob Backport-of: d1951aa97cecbf6852e49bf1610f54feca9a2ec5 --- test/jdk/java/nio/file/DirectoryStream/Basic.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/nio/file/DirectoryStream/Basic.java b/test/jdk/java/nio/file/DirectoryStream/Basic.java index ecc66e4ca5f..77a550f2b22 100644 --- a/test/jdk/java/nio/file/DirectoryStream/Basic.java +++ b/test/jdk/java/nio/file/DirectoryStream/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -73,14 +73,18 @@ static void doTest(final Path dir) throws IOException { private PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:f*"); public boolean accept(Path file) { - return matcher.matches(file); + return matcher.matches(file.getFileName()); } }; + + found = false; try (DirectoryStream ds = newDirectoryStream(dir, filter)) { for (Path entry: ds) { - if (!entry.getFileName().equals(foo)) - throw new RuntimeException("entry not expected"); + if (entry.getFileName().equals(foo)) + found = true; } + if (!found) + throw new RuntimeException(String.format("Error: entry: %s was not found", foo)); } // check filtering: z* should not match any files @@ -88,7 +92,7 @@ public boolean accept(Path file) { private PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:z*"); public boolean accept(Path file) { - return matcher.matches(file); + return matcher.matches(file.getFileName()); } }; try (DirectoryStream ds = newDirectoryStream(dir, filter)) { From 1713cf1f44990eb5492e66b9fe3e03603b66e45a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 21:03:20 +0000 Subject: [PATCH 048/205] 8215759: [test] java/math/BigInteger/ModPow.java can throw an ArithmeticException Backport-of: fedf0767fce4d2df42df6988bcbf12f249e7fa26 --- test/jdk/java/math/BigInteger/ModPow.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/math/BigInteger/ModPow.java b/test/jdk/java/math/BigInteger/ModPow.java index ea4a5c0d4fa..ef8fb566047 100644 --- a/test/jdk/java/math/BigInteger/ModPow.java +++ b/test/jdk/java/math/BigInteger/ModPow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -22,18 +22,25 @@ */ /* @test - * @bug 4181191 - * @summary test BigInteger modPow method + * @bug 4181191 8215759 + * @summary test BigInteger modPow method (use -Dseed=X to set PRNG seed) + * @library /test/lib + * @build jdk.test.lib.RandomFactory + * @run main ModPow + * @key randomness */ import java.math.BigInteger; import java.util.Random; +import jdk.test.lib.RandomFactory; public class ModPow { public static void main(String[] args) { - Random rnd = new Random(1234); + Random rnd = RandomFactory.getRandom(); for (int i=0; i<2000; i++) { - BigInteger m = new BigInteger(800, rnd); + // Clamp random modulus to a positive value or modPow() will + // throw an ArithmeticException. + BigInteger m = new BigInteger(800, rnd).max(BigInteger.ONE); BigInteger base = new BigInteger(16, rnd); if (rnd.nextInt() % 1 == 0) base = base.negate(); From dc5590f2e9432d6c47df39c5a3748480fca95d49 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 21:11:00 +0000 Subject: [PATCH 049/205] 8213932: [TESTBUG] assertEquals is invoked with the arguments in the wrong order Backport-of: d98fe57b18d74236a102744f136ddb5785fe70a3 --- .../lang/invoke/CompileThresholdBootstrapTest.java | 4 ++-- test/jdk/java/lang/invoke/ConstantIdentityMHTest.java | 10 ++++------ test/jdk/java/lang/invoke/FilterArgumentsTest.java | 6 +++--- test/jdk/java/lang/invoke/lookup/SpecialStatic.java | 8 ++++---- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/test/jdk/java/lang/invoke/CompileThresholdBootstrapTest.java b/test/jdk/java/lang/invoke/CompileThresholdBootstrapTest.java index f7e0e0004e8..848264b83a3 100644 --- a/test/jdk/java/lang/invoke/CompileThresholdBootstrapTest.java +++ b/test/jdk/java/lang/invoke/CompileThresholdBootstrapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public final class CompileThresholdBootstrapTest { @Test public void testBootstrap() throws Throwable { - Assert.assertEquals(0, (int)MethodHandles.constant(int.class, (int)0).invokeExact()); + Assert.assertEquals((int)MethodHandles.constant(int.class, (int)0).invokeExact(), 0); } public static void main(String ... args) { diff --git a/test/jdk/java/lang/invoke/ConstantIdentityMHTest.java b/test/jdk/java/lang/invoke/ConstantIdentityMHTest.java index d4a7766a2a1..c0db09bb42a 100644 --- a/test/jdk/java/lang/invoke/ConstantIdentityMHTest.java +++ b/test/jdk/java/lang/invoke/ConstantIdentityMHTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 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 @@ -31,11 +31,9 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.List; import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodType.*; -import static org.testng.AssertJUnit.*; +import static org.testng.Assert.*; import org.testng.annotations.*; public class ConstantIdentityMHTest { @@ -69,9 +67,9 @@ public void testZeroNPE() { @Test void testEmpty() throws Throwable { MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class)); - assertEquals("xy", (String)cat.invoke("x","y")); + assertEquals((String)cat.invoke("x","y"), "xy"); MethodHandle mhEmpty = MethodHandles.empty(cat.type()); - assertEquals(null, (String)mhEmpty.invoke("x","y")); + assertEquals((String)mhEmpty.invoke("x","y"), null); } @Test(expectedExceptions = { NullPointerException.class }) diff --git a/test/jdk/java/lang/invoke/FilterArgumentsTest.java b/test/jdk/java/lang/invoke/FilterArgumentsTest.java index d113af0ed4b..3c4884e7c6a 100644 --- a/test/jdk/java/lang/invoke/FilterArgumentsTest.java +++ b/test/jdk/java/lang/invoke/FilterArgumentsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -85,8 +85,8 @@ static class FilterTest { void run(List expected) throws Throwable { filters.clear(); - assertEquals("x-0-z", (String)mh.invokeExact("x", 0, 'z')); - assertEquals(expected, filters); + assertEquals((String)mh.invokeExact("x", 0, 'z'), "x-0-z"); + assertEquals(filters, expected); } static String filterA(String s) { diff --git a/test/jdk/java/lang/invoke/lookup/SpecialStatic.java b/test/jdk/java/lang/invoke/lookup/SpecialStatic.java index ea587059c28..4d85261732e 100644 --- a/test/jdk/java/lang/invoke/lookup/SpecialStatic.java +++ b/test/jdk/java/lang/invoke/lookup/SpecialStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -26,7 +26,7 @@ * @summary JSR292: invokeSpecial: InternalError attempting to lookup a method * @modules java.base/jdk.internal.org.objectweb.asm * @compile -XDignore.symbol.file SpecialStatic.java - * @run junit test.java.lang.invoke.lookup.SpecialStatic + * @run testng test.java.lang.invoke.lookup.SpecialStatic */ package test.java.lang.invoke.lookup; @@ -34,9 +34,9 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import jdk.internal.org.objectweb.asm.*; -import org.junit.Test; +import org.testng.annotations.*; import static jdk.internal.org.objectweb.asm.Opcodes.*; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * Test case: From decfc860538f1c59b51edeb79893dbe21b02f360 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 21:13:45 +0000 Subject: [PATCH 050/205] 8217353: java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java fails with Unexpected reference: java.lang.ref.WeakReference Instrumented the test to relay the original exception as a suppressed exception of the secondary one, increased sleep time, adjusted iteration numbers according to timeout factor. Backport-of: 4ca19585c3e7cc63c4d11c96f12c92a6903f331d --- .../HandlersOnComplexResetUpdate.java | 48 ++++++++++++------- .../HandlersOnComplexUpdate.java | 48 ++++++++++++------- 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java index f4817d864db..97f438f5954 100644 --- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java +++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -80,6 +80,14 @@ public void run(List properties) throws Exception { } } + public static final double TIMEOUT_FACTOR; + static { + String toFactor = System.getProperty("test.timeout.factor", "1.0"); + TIMEOUT_FACTOR = Double.parseDouble(toFactor); + } + static int adjustCount(int count) { + return (int) Math.ceil(TIMEOUT_FACTOR * count); + } private static final String PREFIX = "FileHandler-" + UUID.randomUUID() + ".log"; @@ -213,11 +221,11 @@ static void test(String name, List properties) + barChild.getParent() +"\n\texpected: " + barRef.get()); } Reference ref2; - int max = 3; + int max = adjustCount(3); barChild = null; while ((ref2 = queue.poll()) == null) { System.gc(); - Thread.sleep(100); + Thread.sleep(1000); if (--max == 0) break; } @@ -328,21 +336,25 @@ static void test(String name, List properties) throw new RuntimeException(x); } }); - fooChild = null; - System.out.println("Setting fooChild to: " + fooChild); - while ((ref2 = queue.poll()) == null) { - System.gc(); - Thread.sleep(1000); - } - if (ref2 != fooRef) { - throw new RuntimeException("Unexpected reference: " - + ref2 +"\n\texpected: " + fooRef); - } - if (ref2.get() != null) { - throw new RuntimeException("Referent not cleared: " + ref2.get()); - } - System.out.println("Got fooRef after reset(), fooChild is " + fooChild); - + try { + fooChild = null; + System.out.println("Setting fooChild to: " + fooChild); + while ((ref2 = queue.poll()) == null) { + System.gc(); + Thread.sleep(1000); + } + if (ref2 != fooRef) { + throw new RuntimeException("Unexpected reference: " + + ref2 +"\n\texpected: " + fooRef); + } + if (ref2.get() != null) { + throw new RuntimeException("Referent not cleared: " + ref2.get()); + } + System.out.println("Got fooRef after reset(), fooChild is " + fooChild); + } catch(Throwable t) { + if (failed != null) t.addSuppressed(failed); + throw t; + } } if (failed != null) { // should rarely happen... diff --git a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java index 8a9fb21a4c5..cd5257cec59 100644 --- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java +++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -80,6 +80,14 @@ public void run(List properties) throws Exception { } } + public static final double TIMEOUT_FACTOR; + static { + String toFactor = System.getProperty("test.timeout.factor", "1.0"); + TIMEOUT_FACTOR = Double.parseDouble(toFactor); + } + static int adjustCount(int count) { + return (int) Math.ceil(TIMEOUT_FACTOR * count); + } private static final String PREFIX = "FileHandler-" + UUID.randomUUID() + ".log"; @@ -213,11 +221,11 @@ static void test(String name, List properties) + barChild.getParent() +"\n\texpected: " + barRef.get()); } Reference ref2; - int max = 3; + int max = adjustCount(3); barChild = null; while ((ref2 = queue.poll()) == null) { System.gc(); - Thread.sleep(100); + Thread.sleep(1000); if (--max == 0) break; } @@ -316,21 +324,25 @@ static void test(String name, List properties) throw new RuntimeException(x); } }); - fooChild = null; - System.out.println("Setting fooChild to: " + fooChild); - while ((ref2 = queue.poll()) == null) { - System.gc(); - Thread.sleep(1000); - } - if (ref2 != fooRef) { - throw new RuntimeException("Unexpected reference: " - + ref2 +"\n\texpected: " + fooRef); - } - if (ref2.get() != null) { - throw new RuntimeException("Referent not cleared: " + ref2.get()); - } - System.out.println("Got fooRef after reset(), fooChild is " + fooChild); - + try { + fooChild = null; + System.out.println("Setting fooChild to: " + fooChild); + while ((ref2 = queue.poll()) == null) { + System.gc(); + Thread.sleep(1000); + } + if (ref2 != fooRef) { + throw new RuntimeException("Unexpected reference: " + + ref2 +"\n\texpected: " + fooRef); + } + if (ref2.get() != null) { + throw new RuntimeException("Referent not cleared: " + ref2.get()); + } + System.out.println("Got fooRef after reset(), fooChild is " + fooChild); + } catch (Throwable t) { + if (failed != null) t.addSuppressed(failed); + throw t; + } } if (failed != null) { // should rarely happen... From 3c2763f9bcce6560f47f1e4cc333ad29489f9f2d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Jan 2023 21:15:30 +0000 Subject: [PATCH 051/205] 8195716: BootstrapLoggerTest : Executor still alive Make sure the test joins the active executor thread before waiting for the executor to be GC'ed. Backport-of: 2aace6bd9767c9ad91a9f273bd28165169194d93 --- .../BootstrapLogger/BootstrapLoggerTest.java | 89 ++++++++++++------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java index 1df2f408323..e7a90c7466f 100644 --- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -22,6 +22,7 @@ */ import java.io.PrintStream; +import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.lang.reflect.Array; @@ -37,6 +38,7 @@ import java.security.Policy; import java.security.ProtectionDomain; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -156,7 +158,7 @@ public static void main(String[] args) throws Exception { .collect(Collectors.toSet()); set.stream().forEach(t -> LogStream.err.println("Found: " + t)); if (set.size() > 1) { - throw new RuntimeException("Too many bootsrap threads found"); + throw new RuntimeException("Too many bootstrap threads found"); } Optional t = set.stream().findFirst(); if (t.isPresent()) { @@ -292,46 +294,73 @@ public static void main(String[] args) throws Exception { // of the executor. SimplePolicy.allowAll.set(Boolean.TRUE); try { - Stream stream = Thread.getAllStackTraces().keySet().stream(); - stream.filter((t) -> t.getName().startsWith("BootstrapMessageLoggerTask-")) - .forEach(t -> LogStream.err.println(t)); + // Though unlikely, it is not impossible that the bootstrap logger + // executor may have released its first thread and spawned a new one. + // If that happened then the executor itself might have been GC'ed + // as well and a new one might have been created. + // The code below will lookup the executor threads again and + // join them. + // Only one may be active at a given time, but that might not + // be the one referenced by threadRef. + // We're just making sure all of them have stopped running + // before verifying that the executor is eventually GC'ed. + final WeakReference previous = threadRef; + Stream> stream = Thread.getAllStackTraces().keySet().stream() + .filter((t) -> t.getName().startsWith("BootstrapMessageLoggerTask-")) + .filter((t) -> previous == null ? true : t != previous.get()) + .map((t) -> new WeakReference<>(t, queue)); + List> threads = stream.collect(Collectors.toList()); + if (previous != null) threads.add(previous); + threads.forEach(t -> LogStream.err.println(t.get())); stream = null; - if (threadRef != null && test == TestCase.SECURE_AND_WAIT) { - Thread t = threadRef.get(); - if (t != null) { - if (!(Boolean)isAlive.invoke(null)) { - throw new RuntimeException("Executor already terminated"); + + if (test == TestCase.SECURE_AND_WAIT) { + // First wait for all executor threads to terminate + for (var ref : threads) { + Thread t = ref.get(); + if (t != null) { + if (!(Boolean)isAlive.invoke(null) && t.isAlive()) { + throw new RuntimeException("Executor already terminated"); + } else { + LogStream.err.println("Executor still alive as expected: " + t.getName()); + } + LogStream.err.println("Waiting for " + t.getName() + " to terminate (join)"); + t.join(60_000); + t = null; } else { - LogStream.err.println("Executor still alive as expected."); + LogStream.err.println("WeakReference is already cleared."); + long count = Thread.getAllStackTraces().keySet().stream() + .filter((tr) -> tr.getName().startsWith("BootstrapMessageLoggerTask-")) + .count(); + if (count != 0) { + LogStream.err.println("There are " + count + " threads still lingering."); + } } - LogStream.err.println("Waiting for " + t.getName() + " to terminate (join)"); - t.join(60_000); - t = null; } - LogStream.err.println("Calling System.gc()"); - System.gc(); - LogStream.err.println("Waiting for BootstrapMessageLoggerTask to be gc'ed"); - while (queue.remove(1000) == null) { + // Then wait until all the executor threads are GC'ed + while (!threads.isEmpty()) { LogStream.err.println("Calling System.gc()"); System.gc(); - } + LogStream.err.println("Waiting for BootstrapMessageLoggerTask to be gc'ed"); + Reference tref; + while ((tref = queue.remove(1000)) == null) { + LogStream.err.println("Calling System.gc()"); + System.gc(); + } - // Call the reference here to make sure threadRef will not be - // eagerly garbage collected before the thread it references. - // otherwise, it might not be enqueued, resulting in the - // queue.remove() call above to always return null.... - if (threadRef.get() != null) { - throw new RuntimeException("Reference should have been cleared"); + threads.remove(tref); + LogStream.err.println("BootstrapMessageLoggerTask has been gc'ed: " + + threads.size() + " remaining..."); } - - LogStream.err.println("BootstrapMessageLoggerTask has been gc'ed"); - // Wait for the executor to be gc'ed... + // Then wait for the executor to be gc'ed... + LogStream.err.println("Waiting for the executor to be gc'ed: Calling System.gc()"); + System.gc(); for (int i=0; i<10; i++) { - LogStream.err.println("Calling System.gc()"); - System.gc(); if (!(Boolean)isAlive.invoke(null)) break; // It would be unexpected that we reach here... Thread.sleep(1000); + LogStream.err.println("Calling System.gc()"); + System.gc(); } if ((Boolean)isAlive.invoke(null)) { From 1d78ce4d8a49dd56ecfc3bfa14a8b5123ede841f Mon Sep 17 00:00:00 2001 From: Joshua Cao Date: Thu, 5 Jan 2023 23:26:47 +0000 Subject: [PATCH 052/205] 8221351: Crash in KlassFactory::check_shared_class_file_load_hook Reviewed-by: clanger Backport-of: e2ffa1576203d32bc74508417119ee2f6c7a6d5e --- src/hotspot/share/classfile/classLoader.cpp | 20 +++++---------- src/hotspot/share/classfile/classLoader.hpp | 6 ++++- src/hotspot/share/classfile/klassFactory.cpp | 2 +- src/hotspot/share/memory/filemap.cpp | 11 ++++++-- src/hotspot/share/memory/filemap.hpp | 2 +- test/hotspot/jtreg/TEST.groups | 15 +++++++++++ .../jtreg/runtime/appcds/TestCommon.java | 25 +++++++++++++++++++ .../appcds/customLoader/HelloCustom.java | 18 +++++++------ .../jigsaw/modulepath/ModulePathAndCP.java | 5 ++++ .../appcds/jvmti/ClassFileLoadHook.java | 24 ++++++++++++++++-- .../appcds/jvmti/ClassFileLoadHookTest.java | 8 +++--- 11 files changed, 102 insertions(+), 34 deletions(-) diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index e38afea5f27..15aadce83b2 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -483,6 +483,10 @@ ClassPathImageEntry::~ClassPathImageEntry() { } } +ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) { + return open_stream_for_loader(name, ClassLoaderData::the_null_class_loader_data(), THREAD); +} + // For a class in a named module, look it up in the jimage file using this syntax: // /// // @@ -490,7 +494,7 @@ ClassPathImageEntry::~ClassPathImageEntry() { // 1. There are no unnamed modules in the jimage file. // 2. A package is in at most one module in the jimage file. // -ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) { +ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) { jlong size; JImageLocationRef location = (*JImageFindResource)(_jimage, "", get_jimage_version_string(), name, &size); @@ -501,20 +505,8 @@ ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) { if (pkg_name != NULL) { if (!Universe::is_module_initialized()) { location = (*JImageFindResource)(_jimage, JAVA_BASE_NAME, get_jimage_version_string(), name, &size); -#if INCLUDE_CDS - // CDS uses the boot class loader to load classes whose packages are in - // modules defined for other class loaders. So, for now, get their module - // names from the "modules" jimage file. - if (DumpSharedSpaces && location == 0) { - const char* module_name = (*JImagePackageToModule)(_jimage, pkg_name); - if (module_name != NULL) { - location = (*JImageFindResource)(_jimage, module_name, get_jimage_version_string(), name, &size); - } - } -#endif - } else { - PackageEntry* package_entry = ClassLoader::get_package_entry(name, ClassLoaderData::the_null_class_loader_data(), CHECK_NULL); + PackageEntry* package_entry = ClassLoader::get_package_entry(name, loader_data, CHECK_NULL); if (package_entry != NULL) { ResourceMark rm; // Get the module name diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index 698beef0acf..5bf5fc524b1 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -61,6 +61,10 @@ class ClassPathEntry : public CHeapObj { // Attempt to locate file_name through this class path entry. // Returns a class file parsing stream if successfull. virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0; + // Open the stream for a specific class loader + virtual ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) { + return open_stream(name, THREAD); + } // Debugging NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;) }; @@ -140,7 +144,7 @@ class ClassPathImageEntry: public ClassPathEntry { ClassPathImageEntry(JImageFile* jimage, const char* name); virtual ~ClassPathImageEntry(); ClassFileStream* open_stream(const char* name, TRAPS); - + ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS); // Debugging NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) }; diff --git a/src/hotspot/share/classfile/klassFactory.cpp b/src/hotspot/share/classfile/klassFactory.cpp index a4c3f293653..1813450078b 100644 --- a/src/hotspot/share/classfile/klassFactory.cpp +++ b/src/hotspot/share/classfile/klassFactory.cpp @@ -58,7 +58,7 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook( // Post the CFLH JvmtiCachedClassFileData* cached_class_file = NULL; if (cfs == NULL) { - cfs = FileMapInfo::open_stream_for_jvmti(ik, CHECK_NULL); + cfs = FileMapInfo::open_stream_for_jvmti(ik, class_loader, CHECK_NULL); } unsigned char* ptr = (unsigned char*)cfs->buffer(); unsigned char* end_ptr = ptr + cfs->length(); diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index b42312463cb..e68c3d566b2 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -24,7 +24,9 @@ #include "precompiled.hpp" #include "jvm.h" +#include "classfile/classFileStream.hpp" #include "classfile/classLoader.inline.hpp" +#include "classfile/classLoaderData.inline.hpp" #include "classfile/classLoaderExt.hpp" #include "classfile/compactHashtable.inline.hpp" #include "classfile/stringTable.hpp" @@ -1490,7 +1492,7 @@ ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { return ent; } -ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, TRAPS) { +ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS) { int path_index = ik->shared_classpath_index(); assert(path_index >= 0, "should be called for shared built-in classes only"); assert(path_index < (int)_shared_path_table_size, "sanity"); @@ -1502,7 +1504,12 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, TRAPS) { const char* const class_name = name->as_C_string(); const char* const file_name = ClassLoader::file_name_for_class_name(class_name, name->utf8_length()); - return cpe->open_stream(file_name, THREAD); + ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); + ClassFileStream* cfs = cpe->open_stream_for_loader(file_name, loader_data, THREAD); + assert(cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders."); + log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index, + cfs->source(), cfs->length()); + return cfs; } #endif diff --git a/src/hotspot/share/memory/filemap.hpp b/src/hotspot/share/memory/filemap.hpp index 0aa59783bb6..b5e7d2dda4c 100644 --- a/src/hotspot/share/memory/filemap.hpp +++ b/src/hotspot/share/memory/filemap.hpp @@ -300,7 +300,7 @@ class FileMapInfo : public CHeapObj { static void update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS); #if INCLUDE_JVMTI - static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, TRAPS); + static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS); #endif static SharedClassPathEntry* shared_path(int index) { diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index c61ffb2987a..b26564e3e9b 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -326,6 +326,21 @@ tier1_runtime_appcds_exclude = \ runtime/appcds/ \ -:tier1_runtime_appcds +# This group should be executed with "jtreg -Dtest.cds.run.with.jfr=true ..." +# to test interaction between AppCDS and JFR. It also has the side effect of +# testing JVMTI ClassFileLoadHook. +# +# The excluded tests disallow the jdk.jfr module, which is required to +# run with JFR. +hotspot_appcds_with_jfr = \ + runtime/appcds/ \ + -runtime/appcds/cacheObject/ArchivedModuleCompareTest.java \ + -runtime/appcds/jigsaw/classpathtests/BootAppendTests.java \ + -runtime/appcds/jigsaw/classpathtests/ClassPathTests.java \ + -runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java \ + -runtime/appcds/jigsaw/JigsawOptionsCombo.java \ + -runtime/appcds/jigsaw/modulepath/MainModuleOnly.java + tier1_serviceability = \ serviceability/dcmd/compiler \ -serviceability/dcmd/compiler/CompilerQueueTest.java \ diff --git a/test/hotspot/jtreg/runtime/appcds/TestCommon.java b/test/hotspot/jtreg/runtime/appcds/TestCommon.java index 2af8dcc9dba..67934202149 100644 --- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java +++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java @@ -151,6 +151,15 @@ public static OutputAnalyzer createArchive(AppCDSOptions opts) return executeAndLog(pb, "dump"); } + // This allows you to run the AppCDS tests with JFR enabled at runtime (though not at + // dump time, as that's uncommon for typical AppCDS users). + // + // To run in this special mode, add the following to your jtreg command-line + // -Dtest.cds.run.with.jfr=true + // + // Some AppCDS tests are not compatible with this mode. See the group + // hotspot_appcds_with_jfr in ../../TEST.ROOT for details. + private static final boolean RUN_WITH_JFR = Boolean.getBoolean("test.cds.run.with.jfr"); // Execute JVM using AppCDS archive with specified AppCDSOptions public static OutputAnalyzer runWithArchive(AppCDSOptions opts) @@ -172,6 +181,22 @@ public static OutputAnalyzer runWithArchive(AppCDSOptions opts) for (String s : opts.suffix) cmd.add(s); + if (RUN_WITH_JFR) { + boolean usesJFR = false; + for (String s : cmd) { + if (s.startsWith("-XX:StartFlightRecording=") || s.startsWith("-XX:FlightRecorderOptions")) { + System.out.println("JFR option might have been specified. Don't interfere: " + s); + usesJFR = true; + break; + } + } + if (!usesJFR) { + System.out.println("JFR option not specified. Enabling JFR ..."); + cmd.add(0, "-XX:StartFlightRecording=dumponexit=true"); + System.out.println(cmd); + } + } + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); return executeAndLog(pb, "exec"); } diff --git a/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java index 9a62d2816e2..4116c48e83c 100644 --- a/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java +++ b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -28,8 +28,6 @@ * @requires vm.cds * @requires vm.cds.custom.loaders * @library /test/lib /test/hotspot/jtreg/runtime/appcds - * @modules java.base/jdk.internal.misc - * java.management * @compile test-classes/Hello.java test-classes/CustomLoadee.java * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar Hello @@ -43,6 +41,9 @@ public class HelloCustom { public static void main(String[] args) throws Exception { + run(); + } + public static void run(String... extra_runtime_args) throws Exception { String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; @@ -62,11 +63,12 @@ public static void main(String[] args) throws Exception { use_whitebox_jar); output = TestCommon.exec(appJar, - // command-line arguments ... - use_whitebox_jar, - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "Hello", customJarPath); + TestCommon.concat(extra_runtime_args, + // command-line arguments ... + use_whitebox_jar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "Hello", customJarPath)); TestCommon.checkExec(output); } } diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java index ac4f8a137e1..f3bc67129b2 100644 --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java @@ -93,6 +93,10 @@ public static void buildTestModule() throws Exception { } public static void main(String... args) throws Exception { + run(); + } + + public static void run(String... extra_runtime_args) throws Exception { // compile the modules and create the modular jar files buildTestModule(); String appClasses[] = {MAIN_CLASS, APP_CLASS}; @@ -104,6 +108,7 @@ public static void main(String... args) throws Exception { "-m", MAIN_MODULE); TestCommon.checkDump(output); String prefix[] = {"-cp", "\"\"", "-Xlog:class+load=trace"}; + prefix = TestCommon.concat(prefix, extra_runtime_args); // run with the archive with the --module-path the same as the one during // dump time. The classes should be loaded from the archive. diff --git a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java index 7d564caa8d1..9135793610c 100644 --- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java +++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, 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 @@ -41,8 +41,14 @@ public enum TestCaseId { SHARING_ON_CFLH_ON } - public static void main(String args[]) { + public static void main(String args[]) throws Exception { TestCaseId testCase = TestCaseId.valueOf(args[0]); + test1(testCase); + test2(testCase); + } + + // Test rewriting the classfile data using CFLH + static void test1(TestCaseId testCase) { WhiteBox wb = WhiteBox.getWhiteBox(); System.out.println("====== ClassFileLoadHook.main():testCase = " + testCase); @@ -81,6 +87,20 @@ public static void main(String args[]) { } } + // Test the loading of classfile data for non-boot shared classes from jrt:/xxx. + // See JDK-8221351. + static void test2(TestCaseId testCase) throws Exception { + WhiteBox wb = WhiteBox.getWhiteBox(); + Class c = Class.forName("java.sql.SQLException"); // defined by platform class loader. + + switch (testCase) { + case SHARING_ON_CFLH_OFF: + case SHARING_AUTO_CFLH_ON: + case SHARING_ON_CFLH_ON: + assertTrue(wb.isSharedClass(c), "must be shared"); + } + } + private static void assertTrue(boolean expr, String msg) { if (!expr) throw new RuntimeException(msg); diff --git a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java index 35023dddb40..eb809927618 100644 --- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java +++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, 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 @@ -27,9 +27,6 @@ * @summary Test jvmti class file loader hook interaction with AppCDS * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @requires vm.cds - * @modules java.base/jdk.internal.misc - * jdk.jartool/sun.tools.jar - * java.management * @build ClassFileLoadHook * @run main/othervm/native ClassFileLoadHookTest */ @@ -46,7 +43,8 @@ public class ClassFileLoadHookTest { "ClassFileLoadHook", "ClassFileLoadHook$TestCaseId", "ClassFileLoadHook$1", - "LoadMe" + "LoadMe", + "java/sql/SQLException" }; public static void main(String[] args) throws Exception { From 06f769a2f890225f748b6f89b4683fba0c010673 Mon Sep 17 00:00:00 2001 From: Dhamoder Nalla Date: Fri, 6 Jan 2023 05:18:10 +0000 Subject: [PATCH 053/205] 8292863: assert(_print_inlining_stream->size() > 0) failed: missing inlining msg Reviewed-by: phh --- src/hotspot/share/opto/callGenerator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/callGenerator.cpp b/src/hotspot/share/opto/callGenerator.cpp index 1b9edcc608e..46d56962be4 100644 --- a/src/hotspot/share/opto/callGenerator.cpp +++ b/src/hotspot/share/opto/callGenerator.cpp @@ -423,6 +423,7 @@ void LateInlineCallGenerator::do_late_inline() { // needs jvms for inlined state. if (!do_late_inline_check(jvms)) { map->disconnect_inputs(NULL, C); + C->print_inlining_update_delayed(this); return; } @@ -492,8 +493,6 @@ bool LateInlineMHCallGenerator::do_late_inline_check(JVMState* jvms) { CallGenerator* cg = for_method_handle_inline(jvms, _caller, method(), _input_not_const); - Compile::current()->print_inlining_update_delayed(this); - if (!_input_not_const) { _attempt++; } From dfcf7c1c29ac5ea1c23b1c64482bb2c1994d3cf1 Mon Sep 17 00:00:00 2001 From: Autumn Capasso Date: Sat, 7 Jan 2023 17:24:05 +0000 Subject: [PATCH 054/205] 8256111: Create implementation for NSAccessibilityStaticText protocol Reviewed-by: phh Backport-of: acbcde8c3c004efe3d95166f471ee77ac8415af7 --- .../awt/a11y/CommonComponentAccessibility.m | 5 +- .../awt/a11y/CommonTextAccessibility.h | 42 ++++++ .../awt/a11y/CommonTextAccessibility.m | 141 ++++++++++++++++++ .../awt/a11y/StaticTextAccessibility.h | 41 +++++ .../awt/a11y/StaticTextAccessibility.m | 45 ++++++ 5 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index e867aea0a72..3b87018c12a 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -46,13 +46,14 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:4]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:6]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"]; [rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"]; - + [rolesMap setObject:@"StaticTextAccessibility" forKey:@"hyperlink"]; + [rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"]; } /* diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.h new file mode 100644 index 00000000000..c40467cf7bf --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#ifndef COMMON_TEXT_ACCESSIBILITY +#define COMMON_TEXT_ACCESSIBILITY + +#import "CommonComponentAccessibility.h" +#import "JavaAccessibilityUtilities.h" + +#import + +@interface CommonTextAccessibility : CommonComponentAccessibility { + +} +- (nullable NSString *)accessibilityValueAttribute; +- (NSRange)accessibilityVisibleCharacterRangeAttribute; +- (nullable NSString *)accessibilityStringForRangeAttribute:(NSRange)parameter; +@end + +#endif diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m new file mode 100644 index 00000000000..c40513cbcf7 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m @@ -0,0 +1,141 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "CommonTextAccessibility.h" +#import "ThreadUtilities.h" +#import "JNIUtilities.h" + +#define DEFAULT_RANGE NSMakeRange(0, 0) +#define DEFAULT_RECT NSMakeRect(0, 0, 0, 0) + +static jclass sjc_CAccessibility = NULL; +static jmethodID sjm_getAccessibleText = NULL; +#define GET_ACCESSIBLETEXT_METHOD_RETURN(ret) \ + GET_CACCESSIBILITY_CLASS_RETURN(ret); \ + GET_STATIC_METHOD_RETURN(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", \ + "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;", ret); + +static jclass sjc_CAccessibleText = NULL; +#define GET_CACCESSIBLETEXT_CLASS() \ + GET_CLASS(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText"); +#define GET_CACCESSIBLETEXT_CLASS_RETURN(ret) \ + GET_CLASS_RETURN(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText", ret); + +static jmethodID sjm_getAccessibleEditableText = NULL; +#define GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(ret) \ + GET_CACCESSIBLETEXT_CLASS_RETURN(ret); \ + GET_STATIC_METHOD_RETURN(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", \ + "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;", ret); + +/* + * Converts an int array to an NSRange wrapped inside an NSValue + * takes [start, end] values and returns [start, end - start] + */ +static NSRange javaIntArrayToNSRange(JNIEnv* env, jintArray array) { + jint *values = (*env)->GetIntArrayElements(env, array, 0); + if (values == NULL) { + NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__); + return DEFAULT_RANGE; + }; + return NSMakeRange(values[0], values[1] - values[0]); +} + +@implementation CommonTextAccessibility + +- (nullable NSString *)accessibilityValueAttribute +{ + JNIEnv *env = [ThreadUtilities getJNIEnv]; + GET_CACCESSIBILITY_CLASS_RETURN(nil); + DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", + "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil); + if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) { + jobject axName = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, + sjm_getAccessibleName, fAccessible, fComponent); + CHECK_EXCEPTION(); + if (axName != NULL) { + NSString* str = JavaStringToNSString(env, axName); + (*env)->DeleteLocalRef(env, axName); + return str; + } + // value is still nil if no accessibleName for static text. Below, try to get the accessibleText. + } + + GET_ACCESSIBLETEXT_METHOD_RETURN(@""); + jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, + sjm_getAccessibleText, fAccessible, fComponent); + CHECK_EXCEPTION(); + if (axText == NULL) return nil; + (*env)->DeleteLocalRef(env, axText); + + GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(nil); + jobject axEditableText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, + sjm_getAccessibleEditableText, fAccessible, fComponent); + CHECK_EXCEPTION(); + if (axEditableText == NULL) return nil; + + DECLARE_STATIC_METHOD_RETURN(jm_getTextRange, sjc_CAccessibleText, "getTextRange", + "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;", nil); + jobject jrange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getTextRange, + axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent); + CHECK_EXCEPTION(); + NSString *string = JavaStringToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop) + + (*env)->DeleteLocalRef(env, jrange); + (*env)->DeleteLocalRef(env, axEditableText); + + if (string == nil) string = @""; + return string; +} + +- (NSRange)accessibilityVisibleCharacterRangeAttribute +{ + JNIEnv *env = [ThreadUtilities getJNIEnv]; + GET_CACCESSIBLETEXT_CLASS_RETURN(DEFAULT_RANGE); + DECLARE_STATIC_METHOD_RETURN(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", + "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", DEFAULT_RANGE); + jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, + jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + CHECK_EXCEPTION(); + if (axTextRange == NULL) return DEFAULT_RANGE; + + return javaIntArrayToNSRange(env, axTextRange); +} + +- (nullable NSString *)accessibilityStringForRangeAttribute:(NSRange)range +{ + JNIEnv *env = [ThreadUtilities getJNIEnv]; + GET_CACCESSIBLETEXT_CLASS_RETURN(nil); + DECLARE_STATIC_METHOD_RETURN(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", + "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;", nil); + jstring jstringForRange = (jstring)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getStringForRange, + fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop) + CHECK_EXCEPTION(); + if (jstringForRange == NULL) return @""; + NSString* str = JavaStringToNSString(env, jstringForRange); + (*env)->DeleteLocalRef(env, jstringForRange); + return str; +} + +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.h new file mode 100644 index 00000000000..e1724542408 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#ifndef STATIC_TEXT_ACCESSIBILITY +#define STATIC_TEXT_ACCESSIBILITY + +#import "CommonTextAccessibility.h" + +#import + + +@interface StaticTextAccessibility : CommonTextAccessibility { + +}; +- (nullable NSString *)accessibilityAttributedString:(NSRange)range; +- (nullable NSString *)accessibilityValue; +- (NSRange)accessibilityVisibleCharacterRange; +@end +#endif diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.m new file mode 100644 index 00000000000..470f0799c38 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/StaticTextAccessibility.m @@ -0,0 +1,45 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "StaticTextAccessibility.h" + +@implementation StaticTextAccessibility + +- (nullable NSString *)accessibilityAttributedString:(NSRange)range +{ + return [self accessibilityStringForRangeAttribute:range]; +} + +- (nullable NSString *)accessibilityValue +{ + return [self accessibilityValueAttribute]; +} + +- (NSRange)accessibilityVisibleCharacterRange +{ + return [self accessibilityVisibleCharacterRangeAttribute]; +} + +@end From 80eecc50e663155f04dcec1797efb4be4b8ee7b2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Jan 2023 15:58:23 +0000 Subject: [PATCH 055/205] 8299439: java/text/Format/NumberFormat/CurrencyFormat.java fails for hr_HR 8299483: ProblemList java/text/Format/NumberFormat/CurrencyFormat.java Backport-of: cf6c041bd82a9b62780ef3126e93865fac8c0444 --- .../sun/util/resources/ext/CurrencyNames_hr_HR.properties | 3 ++- test/jdk/ProblemList.txt | 2 +- .../text/Format/NumberFormat/CurrencySymbols.properties | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_hr_HR.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_hr_HR.properties index 70f210e2da6..56e61953a8c 100644 --- a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_hr_HR.properties +++ b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_hr_HR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, 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 @@ -35,4 +35,5 @@ # This notice and attribution to Taligent may not be removed. # Taligent is a registered trademark of Taligent, Inc. +EUR=\u20AC HRK=Kn diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index e1043c2dd2a..fad85c6606e 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -1,6 +1,6 @@ ########################################################################### # -# Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 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 diff --git a/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties b/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties index cf73a9c7e31..665dd3b290a 100644 --- a/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties +++ b/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties @@ -79,7 +79,7 @@ fr_FR=\u20AC fr_LU=\u20AC hi_IN=\u0930\u0942 hr=\u00A4 -hr_HR=Kn +hr_HR=\u20AC hu=\u00A4 hu_HU=Ft is=\u00A4 @@ -94,9 +94,9 @@ ja_JP=\uFFE5 ko=\u00A4 ko_KR=\uFFE6 lt=\u00A4 -lt_LT=Lt;2014-12-31-22-00-00;\u20AC +lt_LT=\u20AC lv=\u00A4 -lv_LV=Ls;2013-12-31-22-00-00;\u20AC +lv_LV=\u20AC mk=\u00A4 mk_MK=Den nl=\u00A4 From 369dedbaf5320c171e256bebdaf044c948620208 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Jan 2023 16:24:27 +0000 Subject: [PATCH 056/205] 8293996: C2: fix and simplify IdealLoopTree::do_remove_empty_loop Backport-of: dd51f7e0b75d3a16403608d89cd206ac0bedf882 --- src/hotspot/share/opto/loopTransform.cpp | 34 ++++++--------- .../loopopts/TestRemoveEmptyLoop.java | 41 ++++++++++++++++--- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 4b9406092f5..044fd16d1a4 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -3234,29 +3234,21 @@ bool IdealLoopTree::do_remove_empty_loop(PhaseIdealLoop *phase) { } // Replace the phi at loop head with the final value of the last - // iteration. Then the CountedLoopEnd will collapse (backedge never - // taken) and all loop-invariant uses of the exit values will be correct. - Node *phi = cl->phi(); - Node *exact_limit = phase->exact_limit(this); - if (exact_limit != cl->limit()) { - // We also need to replace the original limit to collapse loop exit. - Node* cmp = cl->loopexit()->cmp_node(); - assert(cl->limit() == cmp->in(2), "sanity"); - // Duplicate cmp node if it has other users - if (cmp->outcnt() > 1) { - cmp = cmp->clone(); - cmp = phase->_igvn.register_new_node_with_optimizer(cmp); - BoolNode *bol = cl->loopexit()->in(CountedLoopEndNode::TestValue)->as_Bool(); - phase->_igvn.replace_input_of(bol, 1, cmp); // put bol on worklist - } - phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist - phase->_igvn.replace_input_of(cmp, 2, exact_limit); // put cmp on worklist - } + // iteration (exact_limit - stride), to make sure the loop exit value + // is correct, for any users after the loop. // Note: the final value after increment should not overflow since // counted loop has limit check predicate. - Node *final = new SubINode(exact_limit, cl->stride()); - phase->register_new_node(final,cl->in(LoopNode::EntryControl)); - phase->_igvn.replace_node(phi,final); + Node* phi = cl->phi(); + Node* exact_limit = phase->exact_limit(this); + Node* final_iv = new SubINode(exact_limit, cl->stride()); + phase->register_new_node(final_iv, cl->in(LoopNode::EntryControl)); + phase->_igvn.replace_node(phi, final_iv); + + // Set loop-exit condition to false. Then the CountedLoopEnd will collapse, + // because the back edge is never taken. + Node* zero = phase->_igvn.intcon(0); + phase->_igvn.replace_input_of(cl->loopexit(), CountedLoopEndNode::TestValue, zero); + phase->C->set_major_progress(); return true; } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestRemoveEmptyLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestRemoveEmptyLoop.java index 94c79c9c214..de8397d1282 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestRemoveEmptyLoop.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestRemoveEmptyLoop.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2019, Huawei Technologies Co. Ltd. All rights reserved. + * 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 @@ -23,7 +24,7 @@ /** * @test - * @bug 8231988 + * @bug 8231988 8293996 * @summary Unexpected test result caused by C2 IdealLoopTree::do_remove_empty_loop * * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation @@ -34,9 +35,11 @@ public class TestRemoveEmptyLoop { - public void test() { + public void test_cmp_helper() { int i = 34; + // The empty loop that collapses for (; i > 0; i -= 11); + // If uses same Cmp node as the loop condition if (i < 0) { // do nothing } else { @@ -44,12 +47,38 @@ public void test() { } } - public static void main(String[] args) { - TestRemoveEmptyLoop _instance = new TestRemoveEmptyLoop(); + public void test_cmp() { + // Loop is OSR compiled, and test_cmp_helper inlined for (int i = 0; i < 50000; i++) { - _instance.test(); + test_cmp_helper(); + } + } + + void test_collapse_helper() { + int o = 11; + int e = 43542; + for (int i = 524; i < 19325; i += 1) { + // The empty loop that is supposed to collapse + for (int j = 0; j < 32767; j++) { + o++; + } + for (int k = 0; k < o; k++) { + e++; + } + } + } + + public void test_collapse() { + // Loop is OSR compiled, and test_collapse_helper inlined + for (int i = 0; i < 50000; i++) { + test_collapse_helper(); } - System.out.println("Test passed."); } + public static void main(String[] args) { + TestRemoveEmptyLoop _instance = new TestRemoveEmptyLoop(); + _instance.test_cmp(); + _instance.test_collapse(); + System.out.println("Test passed."); + } } From e92b7c3e4569d5a3a7d985f9de16aa2ee3a37115 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Jan 2023 16:29:54 +0000 Subject: [PATCH 057/205] 8290964: C2 compilation fails with assert "non-reduction loop contains reduction nodes" Backport-of: 4bdd1c914859e221c64208d47ef309d463609953 --- src/hotspot/share/opto/loopnode.cpp | 11 ----------- src/hotspot/share/opto/loopnode.hpp | 5 ----- src/hotspot/share/opto/superword.cpp | 5 ----- 3 files changed, 21 deletions(-) diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index cd3726ed46c..46c7bb12ab1 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -2556,17 +2556,6 @@ uint IdealLoopTree::est_loop_flow_merge_sz() const { return 0; } -#ifdef ASSERT -bool IdealLoopTree::has_reduction_nodes() const { - for (uint i = 0; i < _body.size(); i++) { - if (_body[i]->is_reduction()) { - return true; - } - } - return false; -} -#endif // ASSERT - #ifndef PRODUCT //------------------------------dump_head-------------------------------------- // Dump 1 liner for loop header info diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 0f72990ecff..aceab1776f0 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -658,11 +658,6 @@ class IdealLoopTree : public ResourceObj { void remove_main_post_loops(CountedLoopNode *cl, PhaseIdealLoop *phase); -#ifdef ASSERT - // Tell whether the body contains nodes marked as reductions. - bool has_reduction_nodes() const; -#endif // ASSERT - #ifndef PRODUCT void dump_head() const; // Dump loop head only void dump() const; // Dump this loop recursively diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index 231e308ca7d..fed52e48831 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -2292,11 +2292,6 @@ void SuperWord::output() { return; } - // Check that the loop to be vectorized does not have inconsistent reduction - // information, which would likely lead to a miscompilation. - assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop(), - "non-reduction loop contains reduction nodes"); - #ifndef PRODUCT if (TraceLoopOpts) { tty->print("SuperWord::output "); From ca2355098228e911e4f6521f3631cbb49f8e1a97 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Jan 2023 16:38:23 +0000 Subject: [PATCH 058/205] 8295412: support latest VS2022 MSC_VER in abstract_vm_version.cpp Backport-of: bca7ab3c1109e6cff9b50ecdd3045cb0ae8f6953 --- src/hotspot/share/runtime/abstract_vm_version.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp index 3937e954777..c46247f2bdb 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp @@ -255,6 +255,10 @@ const char* Abstract_VM_Version::internal_vm_info_string() { #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.0 (VS2022)" #elif _MSC_VER == 1931 #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.1 (VS2022)" + #elif _MSC_VER == 1932 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.2 (VS2022)" + #elif _MSC_VER == 1933 + #define HOTSPOT_BUILD_COMPILER "MS VC++ 17.3 (VS2022)" #else #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER) #endif From 03555b111908fc18866cff3249acd1b3c86689d6 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Tue, 10 Jan 2023 09:53:00 +0000 Subject: [PATCH 059/205] 8298108: Add a regression test for JDK-8297684 Backport-of: 4da8411674b7515310000bd8243860bc73f9a03d --- .../spi-calendar-provider/TestSPISigned.java | 124 ++++++++++++++++++ .../baz/CalendarDataProviderImpl.java | 50 +++++++ .../java.util.spi.CalendarDataProvider | 7 + 3 files changed, 181 insertions(+) create mode 100644 test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java create mode 100644 test/jdk/java/security/SignedJar/spi-calendar-provider/provider/baz/CalendarDataProviderImpl.java create mode 100644 test/jdk/java/security/SignedJar/spi-calendar-provider/provider/meta/META-INF/services/java.util.spi.CalendarDataProvider diff --git a/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java b/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java new file mode 100644 index 00000000000..e7cf5146252 --- /dev/null +++ b/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2022, 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 + * 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 jdk.test.lib.util.JarUtils; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import java.util.Calendar; +import java.util.Locale; +import java.util.List; +import java.util.ArrayList; +import java.nio.file.Paths; +import java.nio.file.Path; +import java.nio.file.Files; +import static java.util.Calendar.WEDNESDAY; + +/* + * @test + * @bug 8297684 8269039 + * @summary Checking custom CalendarDataProvider with SPI contained in signed jar does + * not produce NPE. + * @modules java.base/sun.security.pkcs + * java.base/sun.security.timestamp + * java.base/sun.security.x509 + * java.base/sun.security.util + * java.base/sun.security.tools.keytool + * jdk.jartool/jdk.security.jarsigner + * @library /test/lib + * @library provider + * @build baz.CalendarDataProviderImpl + * @run main/timeout=600 TestSPISigned + */ +public class TestSPISigned { + + private static final String TEST_CLASSES = System.getProperty("test.classes", "."); + private static final String TEST_SRC = System.getProperty("test.src", "."); + + private static final Path META_INF_DIR = Paths.get(TEST_SRC, "provider", "meta"); + private static final Path PROVIDER_PARENT = Paths.get(TEST_CLASSES, ".."); + private static final Path PROVIDER_DIR = PROVIDER_PARENT.resolve("provider"); + private static final Path MODS_DIR = Paths.get("mods"); + private static final Path UNSIGNED_JAR = MODS_DIR.resolve("unsigned-with-locale.jar"); + private static final Path SIGNED_JAR = MODS_DIR.resolve("signed-with-locale.jar"); + + public static void main(String[] args) throws Throwable { + if (args.length == 1) { + String arg = args[0]; + if ("run-test".equals(arg)) { + System.out.println("Debug: Running test"); + String provProp = System.getProperty("java.locale.providers"); + if (!"SPI".equals(provProp)) { + throw new RuntimeException("Test failed! Expected -Djava.locale.providers=SPI to be set for test run"); + } + doRunTest(); + } else { + throw new RuntimeException("Test failed! Expected 'run-test' arg for test run"); + } + } else { + // Set up signed jar with custom calendar data provider + // + // 1. Create jar with custom CalendarDataProvider + JarUtils.createJarFile(UNSIGNED_JAR, PROVIDER_DIR); + JarUtils.updateJarFile(UNSIGNED_JAR, META_INF_DIR); + // create signer's keypair + SecurityTools.keytool("-genkeypair -keyalg RSA -keystore ks " + + "-storepass changeit -dname CN=test -alias test") + .shouldHaveExitValue(0); + // sign jar + SecurityTools.jarsigner("-keystore ks -storepass changeit " + + "-signedjar " + SIGNED_JAR + " " + UNSIGNED_JAR + " test") + .shouldHaveExitValue(0); + // run test, which must not throw a NPE + List testRun = new ArrayList<>(); + testRun.add("-Djava.locale.providers=SPI"); + testRun.add("-cp"); + String classPath = System.getProperty("java.class.path"); + classPath = classPath + ":" + SIGNED_JAR.toAbsolutePath().toString(); + testRun.add(classPath); + testRun.add(TestSPISigned.class.getSimpleName()); + testRun.add("run-test"); + OutputAnalyzer out = ProcessTools.executeTestJvm(testRun); + out.shouldHaveExitValue(0); + out.shouldContain("DEBUG: Getting xx language"); + } + } + + private static void doRunTest() { + Locale locale = new Locale("xx", "YY"); + Calendar kcal = Calendar.getInstance(locale); + try { + check(WEDNESDAY, kcal.getFirstDayOfWeek()); + check(7, kcal.getMinimalDaysInFirstWeek()); + } catch (Throwable ex) { + throw new RuntimeException("Test failed with signed jar and " + + " argument java.locale.providers=SPI", ex); + } + } + + private static void check(T expected, T actual) { + Asserts.assertEquals(expected, actual, "Expected calendar from SPI to be in effect"); + } + +} diff --git a/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/baz/CalendarDataProviderImpl.java b/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/baz/CalendarDataProviderImpl.java new file mode 100644 index 00000000000..958aa128e93 --- /dev/null +++ b/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/baz/CalendarDataProviderImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022, 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 + * 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 baz; + +import static java.util.Calendar.*; +import java.util.Locale; +import java.util.spi.CalendarDataProvider; + +public class CalendarDataProviderImpl extends CalendarDataProvider { + private static final Locale[] locales = { new Locale("xx", "YY") }; + + @Override + public int getFirstDayOfWeek(Locale locale) { + return WEDNESDAY; + } + + @Override + public int getMinimalDaysInFirstWeek(Locale locale) { + if (locale.getLanguage().equals("xx")) { + System.out.println("DEBUG: Getting xx language"); + } + return 7; + } + + @Override + public Locale[] getAvailableLocales() { + return locales; + } +} diff --git a/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/meta/META-INF/services/java.util.spi.CalendarDataProvider b/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/meta/META-INF/services/java.util.spi.CalendarDataProvider new file mode 100644 index 00000000000..1563e3b3086 --- /dev/null +++ b/test/jdk/java/security/SignedJar/spi-calendar-provider/provider/meta/META-INF/services/java.util.spi.CalendarDataProvider @@ -0,0 +1,7 @@ +# +# +# +# fully-qualified name of the java.util.spi.CalendarDataProvider +# implementation class +# +baz.CalendarDataProviderImpl From 9c3f547f78e6b146d44b4b93102c18401821dc24 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Tue, 10 Jan 2023 10:30:51 +0000 Subject: [PATCH 060/205] 8298271: java/security/SignedJar/spi-calendar-provider/TestSPISigned.java failing on Windows Backport-of: cf93933e21d146fe296b1e4b8e2ef06b699175d6 --- .../SignedJar/spi-calendar-provider/TestSPISigned.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java b/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java index e7cf5146252..69fe8effe70 100644 --- a/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java +++ b/test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java @@ -33,6 +33,7 @@ import java.nio.file.Paths; import java.nio.file.Path; import java.nio.file.Files; +import java.io.File; import static java.util.Calendar.WEDNESDAY; /* @@ -95,7 +96,7 @@ public static void main(String[] args) throws Throwable { testRun.add("-Djava.locale.providers=SPI"); testRun.add("-cp"); String classPath = System.getProperty("java.class.path"); - classPath = classPath + ":" + SIGNED_JAR.toAbsolutePath().toString(); + classPath = classPath + File.pathSeparator + SIGNED_JAR.toAbsolutePath().toString(); testRun.add(classPath); testRun.add(TestSPISigned.class.getSimpleName()); testRun.add("run-test"); From ba60e61ca2f163367dbdce5248a8e456da76efd8 Mon Sep 17 00:00:00 2001 From: Autumn Capasso Date: Wed, 11 Jan 2023 16:05:03 +0000 Subject: [PATCH 061/205] 8261351: Create implementation for NSAccessibilityRadioButton protocol Backport-of: 6badd22e664696fb7119b1cc9b89cf719edfb92f --- .../awt/a11y/CommonComponentAccessibility.m | 3 +- .../awt/a11y/RadiobuttonAccessibility.h | 34 +++++++++++++++ .../awt/a11y/RadiobuttonAccessibility.m | 41 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 3b87018c12a..93f843eb975 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -46,7 +46,7 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:6]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:7]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; @@ -54,6 +54,7 @@ + (void) initializeRolesMap { [rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"]; [rolesMap setObject:@"StaticTextAccessibility" forKey:@"hyperlink"]; [rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"]; + [rolesMap setObject:@"RadiobuttonAccessibility" forKey:@"radiobutton"]; } /* diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h new file mode 100644 index 00000000000..e384eefe64c --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "ButtonAccessibility.h" + +#import + +@interface RadiobuttonAccessibility : ButtonAccessibility { + +}; +- (id)accessibilityValue; +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m new file mode 100644 index 00000000000..f596d080b88 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "RadiobuttonAccessibility.h" +#import "JNIUtilities.h" +#import "ThreadUtilities.h" + +/* + * Implementation of the accessibility peer for the pushbutton role + */ +@implementation RadiobuttonAccessibility + +- (id) accessibilityValue +{ + AWT_ASSERT_APPKIT_THREAD; + return [self accessibilityValueAttribute]; +} + +@end From b3cf0cf9fcaa25f11f8b5fb8658ecb383d19fc17 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 13 Jan 2023 07:54:00 +0000 Subject: [PATCH 062/205] 8209023: fix 2 compiler tests to avoid JDK-8208690 Backport-of: 77204ca163676645df24b778e2053210658a15dc --- .../hotspot/jtreg/compiler/runtime/cr6891750/Test6891750.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/runtime/cr6891750/Test6891750.java b/test/hotspot/jtreg/compiler/runtime/cr6891750/Test6891750.java index 54c87f464d6..a3355c569f5 100644 --- a/test/hotspot/jtreg/compiler/runtime/cr6891750/Test6891750.java +++ b/test/hotspot/jtreg/compiler/runtime/cr6891750/Test6891750.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -25,7 +25,7 @@ * @test * @bug 6891750 * @summary deopt blob kills values in O5 - * @run main compiler.runtime.cr6891750.Test6891750 + * @run main/othervm compiler.runtime.cr6891750.Test6891750 */ package compiler.runtime.cr6891750; From 7bbb6ba0c8e32d13db3350778c4e5ab00abb020d Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sun, 15 Jan 2023 06:55:38 +0000 Subject: [PATCH 063/205] 8299789: Compilation of gtest causes build to fail if runtime libraries are in different dirs Backport-of: c8a8388aba3dc121bad04aaa123f6cd7525c3d38 --- make/hotspot/test/GtestImage.gmk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/make/hotspot/test/GtestImage.gmk b/make/hotspot/test/GtestImage.gmk index 756163c7ba8..596b978a73b 100644 --- a/make/hotspot/test/GtestImage.gmk +++ b/make/hotspot/test/GtestImage.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2020, 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 @@ -41,10 +41,22 @@ ifeq ($(OPENJDK_TARGET_OS), windows) $(foreach v, $(JVM_VARIANTS), \ $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCR_$v, \ DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ - FILES := $(MSVCR_DLL) $(VCRUNTIME_1_DLL) $(MSVCP_DLL), \ + FILES := $(MSVCR_DLL), \ FLATTEN := true, \ )) \ $(eval TARGETS += $$(COPY_GTEST_MSVCR_$v)) \ + $(eval $(call SetupCopyFiles, COPY_GTEST_VCRUNTIME_1_$v, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := $(VCRUNTIME_1_DLL), \ + FLATTEN := true, \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_VCRUNTIME_1_$v)) \ + $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCP_$v, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := $(MSVCP_DLL), \ + FLATTEN := true, \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_MSVCP_$v)) \ $(if $(call equals, $(COPY_DEBUG_SYMBOLS), true), \ $(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \ SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \ From 466edc09dfa5b9a02fa01389b561ec5b9b6448ee Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 17:37:10 +0000 Subject: [PATCH 064/205] 8214445: [test] java/net/URL/HandlerLoop has illegal reflective access Backport-of: c03797a5d010568f8bded1f6561c7a98b4f82414 --- test/jdk/java/net/URL/HandlerLoop.java | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test/jdk/java/net/URL/HandlerLoop.java b/test/jdk/java/net/URL/HandlerLoop.java index 4428c30d214..3249e24712f 100644 --- a/test/jdk/java/net/URL/HandlerLoop.java +++ b/test/jdk/java/net/URL/HandlerLoop.java @@ -21,16 +21,19 @@ * questions. */ -import java.io.*; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLStreamHandler; +import java.net.URLStreamHandlerFactory; + /* * @test * @bug 4135031 - * @summary Test boostrap problem when a URLStreamHandlerFactory is loaded + * @summary Test bootstrap problem when a URLStreamHandlerFactory is loaded * by the application class loader. - * + * @modules java.base/sun.net.www.protocol.file + * @run main HandlerLoop */ -import java.net.*; - public class HandlerLoop { public static void main(String args[]) throws Exception { @@ -57,13 +60,13 @@ public URLStreamHandler createURLStreamHandler(String protocol) { // shares the same stream handler factory. new Dummy(); try { - Class c = Class.forName(name); - return (URLStreamHandler)c.newInstance(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { + Class c = Class.forName(name); + return (URLStreamHandler)c.getDeclaredConstructor().newInstance(); + } catch (ClassNotFoundException | + IllegalAccessException | + InstantiationException | + NoSuchMethodException | + InvocationTargetException e) { e.printStackTrace(); } return null; From c20794cd454b27334967acea2da61b6915e3ef68 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 17:40:44 +0000 Subject: [PATCH 065/205] 8267038: Update IANA Language Subtag Registry to Version 2022-03-02 Backport-of: 19f4f229849e8c19ba20b6875b3c2d25c71e7142 --- .../data/lsrdata/language-subtag-registry.txt | 251 +++++++++++++++++- .../Locale/LanguageSubtagRegistryTest.java | 38 ++- 2 files changed, 279 insertions(+), 10 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index 3ce374c128a..cade190589c 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2021-05-11 +File-Date: 2022-03-02 %% Type: language Subtag: aa @@ -2146,9 +2146,16 @@ Added: 2009-07-29 Macrolanguage: ar %% Type: language +Subtag: ajs +Description: Algerian Jewish Sign Language +Added: 2022-02-25 +%% +Type: language Subtag: ajt Description: Judeo-Tunisian Arabic Added: 2009-07-29 +Deprecated: 2022-02-25 +Preferred-Value: aeb Macrolanguage: jrb %% Type: language @@ -5772,6 +5779,11 @@ Added: 2009-07-29 Deprecated: 2020-03-28 %% Type: language +Subtag: bpc +Description: Mbuk +Added: 2022-02-25 +%% +Type: language Subtag: bpd Description: Banda-Banda Added: 2009-07-29 @@ -6016,6 +6028,7 @@ Added: 2005-10-16 %% Type: language Subtag: brb +Description: Brao Description: Lave Added: 2009-07-29 %% @@ -8155,6 +8168,11 @@ Added: 2020-03-28 Macrolanguage: zh %% Type: language +Subtag: cnq +Description: Chung +Added: 2022-02-25 +%% +Type: language Subtag: cnr Description: Montenegrin Added: 2018-01-23 @@ -8757,6 +8775,8 @@ Subtag: cug Description: Chungmboko Description: Cung Added: 2009-07-29 +Deprecated: 2022-02-25 +Comments: see bpc, cnq %% Type: language Subtag: cuh @@ -10176,6 +10196,11 @@ Description: Tadaksahak Added: 2009-07-29 %% Type: language +Subtag: dsz +Description: Mardin Sign Language +Added: 2022-02-25 +%% +Type: language Subtag: dta Description: Daur Added: 2009-07-29 @@ -10602,6 +10627,11 @@ Description: Emilian Added: 2009-07-29 %% Type: language +Subtag: egm +Description: Benamanga +Added: 2022-02-25 +%% +Type: language Subtag: ego Description: Eggon Added: 2009-07-29 @@ -10913,7 +10943,7 @@ Added: 2009-07-29 %% Type: language Subtag: env -Description: Enwan (Edu State) +Description: Enwan (Edo State) Added: 2009-07-29 %% Type: language @@ -11329,6 +11359,7 @@ Added: 2009-07-29 Type: language Subtag: fit Description: Tornedalen Finnish +Description: Meänkieli Added: 2009-07-29 %% Type: language @@ -12838,6 +12869,11 @@ Description: Gavar Added: 2009-07-29 %% Type: language +Subtag: gov +Description: Goo +Added: 2022-02-25 +%% +Type: language Subtag: gow Description: Gorowa Added: 2009-07-29 @@ -14941,6 +14977,11 @@ Description: Marsian Added: 2009-07-29 %% Type: language +Subtag: imt +Description: Imotong +Added: 2022-02-25 +%% +Type: language Subtag: imy Description: Milyan Added: 2009-07-29 @@ -19458,6 +19499,8 @@ Type: language Subtag: lak Description: Laka (Nigeria) Added: 2009-07-29 +Deprecated: 2022-02-25 +Preferred-Value: ksp %% Type: language Subtag: lal @@ -19953,6 +19996,11 @@ Description: Opuuo Added: 2009-07-29 %% Type: language +Subtag: lgo +Description: Lango (South Sudan) +Added: 2022-02-25 +%% +Type: language Subtag: lgq Description: Logba Added: 2009-07-29 @@ -20552,6 +20600,8 @@ Type: language Subtag: lno Description: Lango (South Sudan) Added: 2009-07-29 +Deprecated: 2022-02-25 +Comments: see imt, lgo, lqr, oie %% Type: language Subtag: lns @@ -20724,6 +20774,11 @@ Description: Lopit Added: 2009-07-29 %% Type: language +Subtag: lqr +Description: Logir +Added: 2022-02-25 +%% +Type: language Subtag: lra Description: Rara Bakati' Added: 2009-07-29 @@ -20809,6 +20864,12 @@ Description: Langue des Signes Burundaise Added: 2021-02-20 %% Type: language +Subtag: lsc +Description: Albarradas Sign Language +Description: Lengua de señas Albarradas +Added: 2022-02-25 +%% +Type: language Subtag: lsd Description: Lishana Deni Added: 2009-07-29 @@ -20883,6 +20944,13 @@ Description: Sivia Sign Language Added: 2019-04-16 %% Type: language +Subtag: lsw +Description: Seychelles Sign Language +Description: Lalang Siny Seselwa +Description: Langue des Signes Seychelloise +Added: 2022-02-25 +%% +Type: language Subtag: lsy Description: Mauritian Sign Language Added: 2010-03-11 @@ -26779,6 +26847,11 @@ Description: Nawaru Added: 2009-07-29 %% Type: language +Subtag: nww +Description: Ndwewe +Added: 2022-02-25 +%% +Type: language Subtag: nwx Description: Middle Newar Added: 2009-07-29 @@ -27201,6 +27274,11 @@ Description: Oirata Added: 2009-07-29 %% Type: language +Subtag: oie +Description: Okolie +Added: 2022-02-25 +%% +Type: language Subtag: oin Description: Inebu One Added: 2009-07-29 @@ -28472,6 +28550,11 @@ Added: 2005-10-16 Scope: collection %% Type: language +Subtag: phj +Description: Pahari +Added: 2022-02-25 +%% +Type: language Subtag: phk Description: Phake Added: 2009-07-29 @@ -28572,6 +28655,7 @@ Type: language Subtag: pii Description: Pini Added: 2009-07-29 +Deprecated: 2022-02-25 %% Type: language Subtag: pij @@ -29419,6 +29503,7 @@ Added: 2009-07-29 %% Type: language Subtag: psc +Description: Iranian Sign Language Description: Persian Sign Language Added: 2009-07-29 %% @@ -29772,7 +29857,13 @@ Description: Pyen Added: 2009-07-29 %% Type: language +Subtag: pzh +Description: Pazeh +Added: 2022-02-25 +%% +Type: language Subtag: pzn +Description: Jejara Naga Description: Para Naga Added: 2009-07-29 %% @@ -30394,6 +30485,11 @@ Description: Riang (India) Added: 2009-07-29 %% Type: language +Subtag: rib +Description: Bribri Sign Language +Added: 2022-02-25 +%% +Type: language Subtag: rie Description: Rien Added: 2009-07-29 @@ -30627,6 +30723,11 @@ Added: 2009-07-29 Deprecated: 2016-05-30 %% Type: language +Subtag: rnb +Description: Brunca Sign Language +Added: 2022-02-25 +%% +Type: language Subtag: rnd Description: Ruund Added: 2009-07-29 @@ -30770,6 +30871,12 @@ Added: 2009-07-29 Deprecated: 2017-02-23 %% Type: language +Subtag: rsk +Description: Ruthenian +Description: Rusyn +Added: 2022-02-25 +%% +Type: language Subtag: rsl Description: Russian Sign Language Added: 2009-07-29 @@ -30780,6 +30887,11 @@ Description: Miriwoong Sign Language Added: 2016-05-30 %% Type: language +Subtag: rsn +Description: Rwandan Sign Language +Added: 2022-02-25 +%% +Type: language Subtag: rtc Description: Rungtu Chin Added: 2012-08-12 @@ -32276,6 +32388,8 @@ Type: language Subtag: smd Description: Sama Added: 2009-07-29 +Deprecated: 2022-02-25 +Preferred-Value: kmb %% Type: language Subtag: smf @@ -32382,6 +32496,8 @@ Type: language Subtag: snb Description: Sebuyau Added: 2009-07-29 +Deprecated: 2022-02-25 +Preferred-Value: iba %% Type: language Subtag: snc @@ -35199,6 +35315,11 @@ Description: Tojolabal Added: 2009-07-29 %% Type: language +Subtag: tok +Description: Toki Pona +Added: 2022-02-25 +%% +Type: language Subtag: tol Description: Tolowa Added: 2009-07-29 @@ -35541,6 +35662,8 @@ Added: 2009-07-29 %% Type: language Subtag: trv +Description: Sediq +Description: Seediq Description: Taroko Added: 2009-07-29 %% @@ -36432,6 +36555,11 @@ Description: Ughele Added: 2009-07-29 %% Type: language +Subtag: ugh +Description: Kubachi +Added: 2022-02-25 +%% +Type: language Subtag: ugn Description: Ugandan Sign Language Added: 2009-07-29 @@ -36742,6 +36870,11 @@ Deprecated: 2015-02-12 Preferred-Value: ema %% Type: language +Subtag: uon +Description: Kulon +Added: 2022-02-25 +%% +Type: language Subtag: upi Description: Umeda Added: 2009-07-29 @@ -36944,6 +37077,8 @@ Type: language Subtag: uun Description: Kulon-Pazeh Added: 2009-07-29 +Deprecated: 2022-02-25 +Comments: see pzh, uon %% Type: language Subtag: uur @@ -37714,6 +37849,11 @@ Description: Wadikali Added: 2013-09-10 %% Type: language +Subtag: wdt +Description: Wendat +Added: 2022-02-25 +%% +Type: language Subtag: wdu Description: Wadjigu Added: 2009-07-29 @@ -38348,6 +38488,7 @@ Type: language Subtag: wrd Description: Warduji Added: 2009-07-29 +Deprecated: 2022-02-25 %% Type: language Subtag: wrg @@ -38613,6 +38754,8 @@ Type: language Subtag: wya Description: Wyandot Added: 2009-07-29 +Deprecated: 2022-02-25 +Comments: see wdt, wyn %% Type: language Subtag: wyb @@ -38630,6 +38773,11 @@ Description: Wymysorys Added: 2009-07-29 %% Type: language +Subtag: wyn +Description: Wyandot +Added: 2022-02-25 +%% +Type: language Subtag: wyr Description: Wayoró Added: 2009-07-29 @@ -38936,6 +39084,11 @@ Description: Kwandu Added: 2017-02-23 %% Type: language +Subtag: xdq +Description: Kaitag +Added: 2022-02-25 +%% +Type: language Subtag: xdy Description: Malayic Dayak Added: 2009-07-29 @@ -39079,6 +39232,11 @@ Added: 2009-07-29 Macrolanguage: lah %% Type: language +Subtag: xhm +Description: Middle Khmer (1400 to 1850 CE) +Added: 2022-02-25 +%% +Type: language Subtag: xhr Description: Hernican Added: 2009-07-29 @@ -39215,6 +39373,7 @@ Added: 2009-07-29 %% Type: language Subtag: xkk +Description: Kachok Description: Kaco' Added: 2009-07-29 %% @@ -39469,6 +39628,7 @@ Macrolanguage: mg %% Type: language Subtag: xmx +Description: Salawati Description: Maden Added: 2009-07-29 %% @@ -41728,6 +41888,12 @@ Added: 2009-07-29 Macrolanguage: zap %% Type: language +Subtag: zcd +Description: Las Delicias Zapotec +Added: 2022-02-25 +Macrolanguage: zap +%% +Type: language Subtag: zch Description: Central Hongshuihe Zhuang Added: 2009-07-29 @@ -42700,6 +42866,13 @@ Prefix: ar Macrolanguage: ar %% Type: extlang +Subtag: ajs +Description: Algerian Jewish Sign Language +Added: 2022-02-25 +Preferred-Value: ajs +Prefix: sgn +%% +Type: extlang Subtag: apc Description: North Levantine Arabic Added: 2009-07-29 @@ -43104,6 +43277,13 @@ Preferred-Value: dsl Prefix: sgn %% Type: extlang +Subtag: dsz +Description: Mardin Sign Language +Added: 2022-02-25 +Preferred-Value: dsz +Prefix: sgn +%% +Type: extlang Subtag: dup Description: Duano Added: 2009-07-29 @@ -43538,6 +43718,14 @@ Preferred-Value: lsb Prefix: sgn %% Type: extlang +Subtag: lsc +Description: Albarradas Sign Language +Description: Lengua de señas Albarradas +Added: 2022-02-25 +Preferred-Value: lsc +Prefix: sgn +%% +Type: extlang Subtag: lsg Description: Lyons Sign Language Added: 2009-07-29 @@ -43589,6 +43777,15 @@ Preferred-Value: lsv Prefix: sgn %% Type: extlang +Subtag: lsw +Description: Seychelles Sign Language +Description: Lalang Siny Seselwa +Description: Langue des Signes Seychelloise +Added: 2022-02-25 +Preferred-Value: lsw +Prefix: sgn +%% +Type: extlang Subtag: lsy Description: Mauritian Sign Language Added: 2010-03-11 @@ -43880,6 +44077,7 @@ Prefix: sgn %% Type: extlang Subtag: psc +Description: Iranian Sign Language Description: Persian Sign Language Added: 2009-07-29 Preferred-Value: psc @@ -43944,6 +44142,13 @@ Preferred-Value: pys Prefix: sgn %% Type: extlang +Subtag: rib +Description: Bribri Sign Language +Added: 2022-02-25 +Preferred-Value: rib +Prefix: sgn +%% +Type: extlang Subtag: rms Description: Romanian Sign Language Added: 2009-07-29 @@ -43951,6 +44156,13 @@ Preferred-Value: rms Prefix: sgn %% Type: extlang +Subtag: rnb +Description: Brunca Sign Language +Added: 2022-02-25 +Preferred-Value: rnb +Prefix: sgn +%% +Type: extlang Subtag: rsi Description: Rennellese Sign Language Added: 2009-07-29 @@ -43973,6 +44185,13 @@ Preferred-Value: rsm Prefix: sgn %% Type: extlang +Subtag: rsn +Description: Rwandan Sign Language +Added: 2022-02-25 +Preferred-Value: rsn +Prefix: sgn +%% +Type: extlang Subtag: sdl Description: Saudi Arabian Sign Language Added: 2009-07-29 @@ -44793,6 +45012,11 @@ Description: Katakana Added: 2005-10-16 %% Type: script +Subtag: Kawi +Description: Kawi +Added: 2021-12-24 +%% +Type: script Subtag: Khar Description: Kharoshthi Added: 2005-10-16 @@ -45012,6 +45236,11 @@ Description: Burmese Added: 2005-10-16 %% Type: script +Subtag: Nagm +Description: Nag Mundari +Added: 2021-12-24 +%% +Type: script Subtag: Nand Description: Nandinagari Added: 2018-10-28 @@ -45290,6 +45519,11 @@ Description: Sundanese Added: 2006-07-21 %% Type: script +Subtag: Sunu +Description: Sunuwar +Added: 2021-12-24 +%% +Type: script Subtag: Sylo Description: Syloti Nagri Added: 2005-10-16 @@ -47357,6 +47591,12 @@ Added: 2010-10-23 Comments: Indicates that the content is transcribed according to X-SAMPA %% Type: variant +Subtag: gallo +Description: Gallo +Added: 2021-08-05 +Prefix: fr +%% +Type: variant Subtag: gascon Description: Gascon Added: 2018-04-22 @@ -47779,6 +48019,13 @@ Comments: Sutsilvan is one of the five traditional written standards or "idioms" of the Romansh language. %% Type: variant +Subtag: synnejyl +Description: Synnejysk +Description: South Jutish +Added: 2021-07-17 +Prefix: da +%% +Type: variant Subtag: tarask Description: Belarusian in Taraskievica orthography Added: 2007-04-27 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index baf86f9e9de..f13454536c1 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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,9 +24,9 @@ /* * @test * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 + * 8258795 8267038 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2021-05-11) with Locale and Locale.LanguageRange + * (LSR Revision: 2022-03-02) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ @@ -44,15 +44,20 @@ public class LanguageSubtagRegistryTest { static boolean err = false; private static final String ACCEPT_LANGUAGE = - "Accept-Language: aam, adp, aog, aue, bcg, bic, blg, bpp, cey, cnp, cqu, csp, csx, dif, dmw, ehs, ema," - + " en-gb-oed, gti, jks, kdz, koj, kru, kwq, kxe, kzk, lii, lmm, lsb, lsn, lsv, lvi, mtm," - + " ngv, nns, ola, oyb, pat, phr, pnd, pub, scv, snz, sqx, suj, szy, taj, tjj, tjp, tvx," + "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"; private static final List EXPECTED_RANGE_LIST = List.of( new LanguageRange("aam", 1.0), new LanguageRange("aas", 1.0), new LanguageRange("adp", 1.0), new LanguageRange("dz", 1.0), + new LanguageRange("aeb", 1.0), + new LanguageRange("ar-aeb", 1.0), + new LanguageRange("ajt", 1.0), + new LanguageRange("ajs", 1.0), + new LanguageRange("sgn-ajs", 1.0), new LanguageRange("aog", 1.0), new LanguageRange("myd", 1.0), new LanguageRange("aue", 1.0), @@ -61,8 +66,6 @@ public class LanguageSubtagRegistryTest { new LanguageRange("bgm", 1.0), new LanguageRange("bic", 1.0), new LanguageRange("bir", 1.0), - new LanguageRange("blg", 1.0), - new LanguageRange("iba", 1.0), new LanguageRange("bpp", 1.0), new LanguageRange("nxu", 1.0), new LanguageRange("cey", 1.0), @@ -78,6 +81,8 @@ public class LanguageSubtagRegistryTest { new LanguageRange("dit", 1.0), new LanguageRange("dmw", 1.0), new LanguageRange("xrq", 1.0), + new LanguageRange("dsz", 1.0), + new LanguageRange("sgn-dsz", 1.0), new LanguageRange("ehs", 1.0), new LanguageRange("sgn-ehs", 1.0), new LanguageRange("ema", 1.0), @@ -86,14 +91,21 @@ public class LanguageSubtagRegistryTest { new LanguageRange("en-gb-oxendict", 1.0), new LanguageRange("gti", 1.0), new LanguageRange("nyc", 1.0), + new LanguageRange("iba", 1.0), + new LanguageRange("snb", 1.0), + new LanguageRange("blg", 1.0), new LanguageRange("jks", 1.0), new LanguageRange("sgn-jks", 1.0), new LanguageRange("kdz", 1.0), new LanguageRange("ncp", 1.0), + new LanguageRange("kmb", 1.0), + new LanguageRange("smd", 1.0), new LanguageRange("koj", 1.0), new LanguageRange("kwv", 1.0), new LanguageRange("kru", 1.0), new LanguageRange("kxl", 1.0), + new LanguageRange("ksp", 1.0), + new LanguageRange("lak", 1.0), new LanguageRange("kwq", 1.0), new LanguageRange("yam", 1.0), new LanguageRange("kxe", 1.0), @@ -107,10 +119,14 @@ public class LanguageSubtagRegistryTest { new LanguageRange("rmx", 1.0), new LanguageRange("lsb", 1.0), new LanguageRange("sgn-lsb", 1.0), + new LanguageRange("lsc", 1.0), + new LanguageRange("sgn-lsc", 1.0), new LanguageRange("lsn", 1.0), new LanguageRange("sgn-lsn", 1.0), new LanguageRange("lsv", 1.0), new LanguageRange("sgn-lsv", 1.0), + new LanguageRange("lsw", 1.0), + new LanguageRange("sgn-lsw", 1.0), new LanguageRange("lvi", 1.0), new LanguageRange("mtm", 1.0), new LanguageRange("ymt", 1.0), @@ -131,6 +147,12 @@ public class LanguageSubtagRegistryTest { new LanguageRange("pnd", 1.0), new LanguageRange("pub", 1.0), new LanguageRange("puz", 1.0), + new LanguageRange("rib", 1.0), + new LanguageRange("sgn-rib", 1.0), + new LanguageRange("rnb", 1.0), + new LanguageRange("sgn-rnb", 1.0), + new LanguageRange("rsn", 1.0), + new LanguageRange("sgn-rsn", 1.0), new LanguageRange("scv", 1.0), new LanguageRange("zir", 1.0), new LanguageRange("snz", 1.0), From 6faa77c414eb99137c053a152cd16a1a7d9e0a7c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 17:47:15 +0000 Subject: [PATCH 066/205] 8285835: SIGSEGV in PhaseIdealLoop::build_loop_late_post_work Reviewed-by: phh Backport-of: 3e7f840859d9081fc6cf1086bda75fa5aa76a4e9 --- src/hotspot/share/opto/escape.cpp | 70 +++++++++++++--- src/hotspot/share/opto/escape.hpp | 8 ++ .../compiler/escapeAnalysis/TestBrokenEA.java | 82 +++++++++++++++++++ 3 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/escapeAnalysis/TestBrokenEA.java diff --git a/src/hotspot/share/opto/escape.cpp b/src/hotspot/share/opto/escape.cpp index 33af632a347..ba17d347cd1 100644 --- a/src/hotspot/share/opto/escape.cpp +++ b/src/hotspot/share/opto/escape.cpp @@ -242,7 +242,9 @@ bool ConnectionGraph::compute_escape() { // 3. Adjust scalar_replaceable state of nonescaping objects and push // scalar replaceable allocations on alloc_worklist for processing // in split_unique_types(). + GrowableArray jobj_worklist; int non_escaped_length = non_escaped_worklist.length(); + bool found_nsr_alloc = false; for (int next = 0; next < non_escaped_length; next++) { JavaObjectNode* ptn = non_escaped_worklist.at(next); bool noescape = (ptn->escape_state() == PointsToNode::NoEscape); @@ -256,11 +258,25 @@ bool ConnectionGraph::compute_escape() { if (noescape && ptn->scalar_replaceable()) { adjust_scalar_replaceable_state(ptn); if (ptn->scalar_replaceable()) { - alloc_worklist.append(ptn->ideal_node()); + jobj_worklist.push(ptn); + } else { + found_nsr_alloc = true; } } } + // Propagate NSR (Not Scalar Replaceable) state. + if (found_nsr_alloc) { + find_scalar_replaceable_allocs(jobj_worklist); + } + + for (int next = 0; next < jobj_worklist.length(); ++next) { + JavaObjectNode* jobj = jobj_worklist.at(next); + if (jobj->scalar_replaceable()) { + alloc_worklist.append(jobj->ideal_node()); + } + } + #ifdef ASSERT if (VerifyConnectionGraph) { // Verify that graph is complete - no new edges could be added or needed. @@ -1759,15 +1775,19 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { jobj->set_scalar_replaceable(false); return; } - // 2. An object is not scalar replaceable if the field into which it is - // stored has multiple bases one of which is null. - if (field->base_count() > 1) { - for (BaseIterator i(field); i.has_next(); i.next()) { - PointsToNode* base = i.get(); - if (base == null_obj) { - jobj->set_scalar_replaceable(false); - return; - } + for (BaseIterator i(field); i.has_next(); i.next()) { + PointsToNode* base = i.get(); + // 2. An object is not scalar replaceable if the field into which it is + // stored has multiple bases one of which is null. + if ((base == null_obj) && (field->base_count() > 1)) { + set_not_scalar_replaceable(jobj NOT_PRODUCT(COMMA "is stored into field with potentially null base")); + return; + } + // 2.5. An object is not scalar replaceable if the field into which it is + // stored has NSR base. + if (!base->scalar_replaceable()) { + set_not_scalar_replaceable(jobj NOT_PRODUCT(COMMA "is stored into field with NSR base")); + return; } } } @@ -1857,6 +1877,36 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { } } +// Propagate NSR (Not scalar replaceable) state. +void ConnectionGraph::find_scalar_replaceable_allocs(GrowableArray& jobj_worklist) { + int jobj_length = jobj_worklist.length(); + bool found_nsr_alloc = true; + while (found_nsr_alloc) { + found_nsr_alloc = false; + for (int next = 0; next < jobj_length; ++next) { + JavaObjectNode* jobj = jobj_worklist.at(next); + for (UseIterator i(jobj); (jobj->scalar_replaceable() && i.has_next()); i.next()) { + PointsToNode* use = i.get(); + if (use->is_Field()) { + FieldNode* field = use->as_Field(); + assert(field->is_oop() && field->scalar_replaceable(), "sanity"); + assert(field->offset() != Type::OffsetBot, "sanity"); + for (BaseIterator i(field); i.has_next(); i.next()) { + PointsToNode* base = i.get(); + // An object is not scalar replaceable if the field into which + // it is stored has NSR base. + if ((base != null_obj) && !base->scalar_replaceable()) { + set_not_scalar_replaceable(jobj NOT_PRODUCT(COMMA "is stored into field with NSR base")); + found_nsr_alloc = true; + break; + } + } + } + } + } + } +} + #ifdef ASSERT void ConnectionGraph::verify_connection_graph( GrowableArray& ptnodes_worklist, diff --git a/src/hotspot/share/opto/escape.hpp b/src/hotspot/share/opto/escape.hpp index 86b7aa61a8f..7bb7a728cca 100644 --- a/src/hotspot/share/opto/escape.hpp +++ b/src/hotspot/share/opto/escape.hpp @@ -456,6 +456,9 @@ class ConnectionGraph: public ResourceObj { // Adjust scalar_replaceable state after Connection Graph is built. void adjust_scalar_replaceable_state(JavaObjectNode* jobj); + // Propagate NSR (Not scalar replaceable) state. + void find_scalar_replaceable_allocs(GrowableArray& jobj_worklist); + // Optimize ideal graph. void optimize_ideal_graph(GrowableArray& ptr_cmp_worklist, GrowableArray& storestore_worklist); @@ -582,6 +585,11 @@ class ConnectionGraph: public ResourceObj { // Compute the escape information bool compute_escape(); + void set_not_scalar_replaceable(PointsToNode* ptn NOT_PRODUCT(COMMA const char* reason)) const { + ptn->set_scalar_replaceable(false); + } + + public: ConnectionGraph(Compile *C, PhaseIterGVN *igvn); diff --git a/test/hotspot/jtreg/compiler/escapeAnalysis/TestBrokenEA.java b/test/hotspot/jtreg/compiler/escapeAnalysis/TestBrokenEA.java new file mode 100644 index 00000000000..8216281afe5 --- /dev/null +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestBrokenEA.java @@ -0,0 +1,82 @@ +/* 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 8285835 + * @summary EA does not propagate NSR (not scalar replaceable) state. + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestBrokenEA + */ + +public class TestBrokenEA { + + public static void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + test1(true); + test1(false); + test2(true); + test2(false); + } + } + + private static void test1(boolean flag) { + A[] array = new A[1]; + if (flag) { + C c = new C(); + B b = new B(); + b.c = c; + A a = new A(); + a.b = b; + array[0] = a; + } + A a = array[0]; + if (a != null) { + a.b.c.f = 0x42; + } + } + + private static void test2(boolean flag) { + A a = null; + if (flag) { + C c = new C(); + B b = new B(); + b.c = c; + a = new A(); + a.b = b; + } + if (a != null) { + a.b.c.f = 0x42; + } + } + + private static class A { + public B b; + } + + private static class B { + public C c; + } + + private static class C { + public int f; + } +} From 84583683b2a700d022c30e676fbab1e66ccdabc6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 17:51:59 +0000 Subject: [PATCH 067/205] 8294378: URLPermission constructor exception when using tr locale Backport-of: ff2c987669523613f3e5dc19493a41f849f882f6 --- .../share/classes/java/net/HostPortrange.java | 3 +++ .../share/classes/java/net/URLPermission.java | 5 +++-- test/jdk/java/net/URLPermission/URLPermissionTest.java | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/net/HostPortrange.java b/src/java.base/share/classes/java/net/HostPortrange.java index ec602035f4d..7957e9f2e00 100644 --- a/src/java.base/share/classes/java/net/HostPortrange.java +++ b/src/java.base/share/classes/java/net/HostPortrange.java @@ -149,6 +149,9 @@ public int hashCode() { // regular domain name hoststr = toLowerCase(hoststr); } + } else { + // regular domain name + hoststr = toLowerCase(hoststr); } } hostname = hoststr; diff --git a/src/java.base/share/classes/java/net/URLPermission.java b/src/java.base/share/classes/java/net/URLPermission.java index 9b3a88cebd0..6f0e050ea4d 100644 --- a/src/java.base/share/classes/java/net/URLPermission.java +++ b/src/java.base/share/classes/java/net/URLPermission.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Collections; import java.security.Permission; +import java.util.Locale; /** * Represents permission to access a resource or set of resources defined by a @@ -444,7 +445,7 @@ private void parseURI(String url) { throw new IllegalArgumentException( "Invalid URL string: \"" + url + "\""); } - scheme = url.substring(0, delim).toLowerCase(); + scheme = url.substring(0, delim).toLowerCase(Locale.ROOT); this.ssp = url.substring(delim + 1); if (!ssp.startsWith("//")) { @@ -466,7 +467,7 @@ private void parseURI(String url) { auth = authpath.substring(0, delim); this.path = authpath.substring(delim); } - this.authority = new Authority(scheme, auth.toLowerCase()); + this.authority = new Authority(scheme, auth); } private String actions() { diff --git a/test/jdk/java/net/URLPermission/URLPermissionTest.java b/test/jdk/java/net/URLPermission/URLPermissionTest.java index d445da147c7..096e219e8f9 100644 --- a/test/jdk/java/net/URLPermission/URLPermissionTest.java +++ b/test/jdk/java/net/URLPermission/URLPermissionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -26,7 +26,9 @@ /** * @test - * @bug 8010464 8027570 8027687 8029354 8114860 8071660 8161291 + * @bug 8010464 8027570 8027687 8029354 8114860 8071660 8161291 8294378 + * @run main URLPermissionTest + * @run main/othervm -Duser.language=tr URLPermissionTest */ public class URLPermissionTest { @@ -385,7 +387,9 @@ static URLEqualityTest eqtest(String arg1, String arg2, boolean expected) { eqtest("http://michael@foo.com/bar","http://michael@foo.com/bar", true), eqtest("http://Michael@foo.com/bar","http://michael@goo.com/bar",false), eqtest("http://michael@foo.com/bar","http://george@foo.com/bar", true), - eqtest("http://@foo.com/bar","http://foo.com/bar", true) + eqtest("http://@foo.com/bar","http://foo.com/bar", true), + eqtest("http://www.IOU.com", "http://www.iou.com", true), + eqtest("HTTPI://www.IOU.com", "httpi://www.iou.com", true) }; static Test[] createTests = { From 71e89e121c318cd2627d2c1b46962b157483ab31 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 19:09:32 +0000 Subject: [PATCH 068/205] 8297569: URLPermission constructor throws IllegalArgumentException: Invalid characters in hostname after JDK-8294378 Backport-of: 2f47f83addd7f69db2c7070552a7ec67bd07d62e --- src/java.base/share/classes/java/net/URLPermission.java | 2 +- test/jdk/java/net/URLPermission/URLPermissionTest.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/net/URLPermission.java b/src/java.base/share/classes/java/net/URLPermission.java index 6f0e050ea4d..dfb04167b18 100644 --- a/src/java.base/share/classes/java/net/URLPermission.java +++ b/src/java.base/share/classes/java/net/URLPermission.java @@ -467,7 +467,7 @@ private void parseURI(String url) { auth = authpath.substring(0, delim); this.path = authpath.substring(delim); } - this.authority = new Authority(scheme, auth); + this.authority = new Authority(scheme, auth.toLowerCase(Locale.ROOT)); } private String actions() { diff --git a/test/jdk/java/net/URLPermission/URLPermissionTest.java b/test/jdk/java/net/URLPermission/URLPermissionTest.java index 096e219e8f9..6bc744dfa6a 100644 --- a/test/jdk/java/net/URLPermission/URLPermissionTest.java +++ b/test/jdk/java/net/URLPermission/URLPermissionTest.java @@ -395,7 +395,9 @@ static URLEqualityTest eqtest(String arg1, String arg2, boolean expected) { static Test[] createTests = { createtest("http://user@foo.com/a/b/c"), createtest("http://user:pass@foo.com/a/b/c"), - createtest("http://user:@foo.com/a/b/c") + createtest("http://user:@foo.com/a/b/c"), + createtest("http://foo_bar"), + createtest("http://foo_bar:12345") }; static boolean failed = false; From 9c684a103e3fa310f08b792f3efd8732d846dfaa Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jan 2023 19:22:16 +0000 Subject: [PATCH 069/205] 8294947: Use 64bit atomics in patch_verified_entry on x86_64 Reviewed-by: rrich Backport-of: d0fae43e89a73e9d73b074fa12276c43ba629278 --- src/hotspot/cpu/x86/nativeInst_x86.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hotspot/cpu/x86/nativeInst_x86.cpp b/src/hotspot/cpu/x86/nativeInst_x86.cpp index 76ce6ff9070..8ae8cedba34 100644 --- a/src/hotspot/cpu/x86/nativeInst_x86.cpp +++ b/src/hotspot/cpu/x86/nativeInst_x86.cpp @@ -544,12 +544,27 @@ void NativeJump::check_verified_entry_alignment(address entry, address verified_ // void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { // complete jump instruction (to be inserted) is in code_buffer; +#ifdef _LP64 + union { + jlong cb_long; + unsigned char code_buffer[8]; + } u; + + u.cb_long = *(jlong *)verified_entry; + + intptr_t disp = (intptr_t)dest - ((intptr_t)verified_entry + 1 + 4); + guarantee(disp == (intptr_t)(int32_t)disp, "must be 32-bit offset"); + + u.code_buffer[0] = instruction_code; + *(int32_t*)(u.code_buffer + 1) = (int32_t)disp; + + Atomic::store(u.cb_long, (jlong *) verified_entry); + ICache::invalidate_range(verified_entry, 8); + +#else unsigned char code_buffer[5]; code_buffer[0] = instruction_code; intptr_t disp = (intptr_t)dest - ((intptr_t)verified_entry + 1 + 4); -#ifdef AMD64 - guarantee(disp == (intptr_t)(int32_t)disp, "must be 32-bit offset"); -#endif // AMD64 *(int32_t*)(code_buffer + 1) = (int32_t)disp; check_verified_entry_alignment(entry, verified_entry); @@ -580,6 +595,7 @@ void NativeJump::patch_verified_entry(address entry, address verified_entry, add *(int32_t*)verified_entry = *(int32_t *)code_buffer; // Invalidate. Opteron requires a flush after every write. n_jump->wrote(0); +#endif // _LP64 } From b52d8ad54712270a7b99ac985931eb0d720a9695 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 17 Jan 2023 07:31:59 +0000 Subject: [PATCH 070/205] 8283717: vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001 failed due to SocketTimeoutException Backport-of: f9f439a19d11501cfa77db065051086ab794e9f4 --- .../vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java index 9de6f2c301f..213a7fb3c46 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, 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 @@ -151,6 +151,8 @@ public static int run(final String args[], final PrintStream out) { if (checkedRequest != null) { log.display("Disabling event request"); checkedRequest.disable(); + // need to resume all threads in case a stray ThreadStartEvent arrived + vm.resume(); } // force debuggee to quit From 6c3d4dff589f3c194e62af6bbdf1b3dfe81f5cd1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 17 Jan 2023 15:52:01 +0000 Subject: [PATCH 071/205] 8283719: java/util/logging/CheckZombieLockTest.java failing intermittently Backport-of: 74835f73893976c162ef5a441f0cfec16eb8706f --- .../util/logging/CheckZombieLockTest.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/jdk/java/util/logging/CheckZombieLockTest.java b/test/jdk/java/util/logging/CheckZombieLockTest.java index 16909532ceb..7c5b52008ae 100644 --- a/test/jdk/java/util/logging/CheckZombieLockTest.java +++ b/test/jdk/java/util/logging/CheckZombieLockTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -50,6 +50,8 @@ import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.LogRecord; +import static java.nio.file.StandardOpenOption.*; + public class CheckZombieLockTest { private static final String WRITABLE_DIR = "writable-lockfile-dir"; @@ -241,10 +243,9 @@ private static void testFileHandlerReuse(File writableDir) throws IOException { } if (supportsLocking) { - FileChannel fc = FileChannel.open(Paths.get(lock.getAbsolutePath()), - StandardOpenOption.CREATE_NEW, StandardOpenOption.APPEND, - StandardOpenOption.WRITE); - try { + handler2 = null; + try (FileChannel fc = FileChannel.open(lock.toPath(), CREATE_NEW, APPEND, WRITE)) { + if (fc.tryLock() != null) { System.out.println("locked: " + lock); handler2 = createFileHandler(writableDir); @@ -261,6 +262,7 @@ private static void testFileHandlerReuse(File writableDir) throws IOException { throw new RuntimeException("Failed to lock: " + lock); } } finally { + if (handler2 != null) handler2.close(); delete(lock); } } @@ -320,17 +322,12 @@ private static File setup() throws RuntimeException { // try to determine whether file locking is supported final String uniqueFileName = UUID.randomUUID().toString()+".lck"; - try { - FileChannel fc = FileChannel.open(Paths.get(writableDir.getAbsolutePath(), - uniqueFileName), - StandardOpenOption.CREATE_NEW, StandardOpenOption.APPEND, - StandardOpenOption.DELETE_ON_CLOSE); + try (FileChannel fc = FileChannel.open(Paths.get(writableDir.getAbsolutePath(), + uniqueFileName), CREATE_NEW, APPEND, DELETE_ON_CLOSE)) { try { fc.tryLock(); - } catch(IOException x) { + } catch (IOException x) { supportsLocking = false; - } finally { - fc.close(); } } catch (IOException t) { // should not happen From 8dd8122d0c2a6a30bc9b90beedc3f51a61f5fb9e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 17 Jan 2023 15:54:23 +0000 Subject: [PATCH 072/205] 8296924: C2: assert(is_valid_AArch64_address(dest.target())) failed: bad address Backport-of: abe532a89cbdd2b959789611cecbad7c94f6a870 --- src/hotspot/cpu/aarch64/aarch64.ad | 3 +- .../compiler/unsafe/TestBadBaseAddress.java | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/unsafe/TestBadBaseAddress.java diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index 3ccfc8ee08a..1e4ee33a9db 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -3114,7 +3114,8 @@ encode %{ __ mov_metadata(dst_reg, (Metadata*)con); } else { assert(rtype == relocInfo::none, "unexpected reloc type"); - if (con < (address)(uintptr_t)os::vm_page_size()) { + if (! __ is_valid_AArch64_address(con) || + con < (address)(uintptr_t)os::vm_page_size()) { __ mov(dst_reg, con); } else { uint64_t offset; diff --git a/test/hotspot/jtreg/compiler/unsafe/TestBadBaseAddress.java b/test/hotspot/jtreg/compiler/unsafe/TestBadBaseAddress.java new file mode 100644 index 00000000000..ebcf6d567cb --- /dev/null +++ b/test/hotspot/jtreg/compiler/unsafe/TestBadBaseAddress.java @@ -0,0 +1,57 @@ +/* + * 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 8296924 + * @summary Tests compilation of an unreachable unsafe access with a bad base address. + * @modules java.base/jdk.internal.misc:+open + * @run main/othervm -XX:CompileCommand=compileonly,TestBadBaseAddress::test -XX:-TieredCompilation -Xcomp TestBadBaseAddress + */ + +import java.lang.reflect.*; +import sun.misc.*; + +public class TestBadBaseAddress { + private static Unsafe unsafe; + + static { + try { + Field field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static void test(boolean b) { + if (b) { + unsafe.putLong(-1, 42); + } + } + + public static void main(String[] args) { + test(false); + } +} From 15cb63e0eaee99e8c61b5804fc3d8d8b57c34e4c Mon Sep 17 00:00:00 2001 From: Autumn Capasso Date: Tue, 17 Jan 2023 17:02:35 +0000 Subject: [PATCH 073/205] 8261350: Create implementation for NSAccessibilityCheckBox protocol peer Backport-of: 2b00367e1154feb2c05b84a11d62fb5750e46acf --- .../awt/a11y/CheckboxAccessibility.h | 32 +++++++++++++++ .../awt/a11y/CheckboxAccessibility.m | 41 +++++++++++++++++++ .../awt/a11y/CommonComponentAccessibility.m | 3 +- .../awt/a11y/RadiobuttonAccessibility.h | 2 - .../awt/a11y/RadiobuttonAccessibility.m | 2 +- 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.h new file mode 100644 index 00000000000..835567c01c1 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "ButtonAccessibility.h" + +@interface CheckboxAccessibility : ButtonAccessibility { + +}; +- (id)accessibilityValue; +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.m new file mode 100644 index 00000000000..c61d3a97a8a --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CheckboxAccessibility.m @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "CheckboxAccessibility.h" +#import "JNIUtilities.h" +#import "ThreadUtilities.h" + +/* + * Implementation of the accessibility peer for the checkbox role + */ +@implementation CheckboxAccessibility + +- (id) accessibilityValue +{ + AWT_ASSERT_APPKIT_THREAD; + return [self accessibilityValueAttribute]; +} + +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 93f843eb975..7be8ab4cffd 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -46,7 +46,7 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:7]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:8]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; @@ -55,6 +55,7 @@ + (void) initializeRolesMap { [rolesMap setObject:@"StaticTextAccessibility" forKey:@"hyperlink"]; [rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"]; [rolesMap setObject:@"RadiobuttonAccessibility" forKey:@"radiobutton"]; + [rolesMap setObject:@"CheckboxAccessibility" forKey:@"checkbox"]; } /* diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h index e384eefe64c..80835d810b4 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.h @@ -25,8 +25,6 @@ #import "ButtonAccessibility.h" -#import - @interface RadiobuttonAccessibility : ButtonAccessibility { }; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m index f596d080b88..79325551fa9 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/RadiobuttonAccessibility.m @@ -28,7 +28,7 @@ #import "ThreadUtilities.h" /* - * Implementation of the accessibility peer for the pushbutton role + * Implementation of the accessibility peer for the radiobutton role */ @implementation RadiobuttonAccessibility From edf4fb0a00b49141bd6c02d184901f93c2d09100 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Tue, 17 Jan 2023 17:25:46 +0000 Subject: [PATCH 074/205] 8295211: Fix autoconf 2.71 warning "AC_CHECK_HEADERS: you should use literals" Reviewed-by: phh Backport-of: c357b5908a091a77bc2b26d74a38785412b88a73 --- make/autoconf/lib-x11.m4 | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/make/autoconf/lib-x11.m4 b/make/autoconf/lib-x11.m4 index d862c029cad..6ba668ea752 100644 --- a/make/autoconf/lib-x11.m4 +++ b/make/autoconf/lib-x11.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -103,22 +103,28 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS" - HEADERS_TO_CHECK="X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h" - # There is no Xrandr extension on AIX if test "x$OPENJDK_TARGET_OS" != xaix; then - HEADERS_TO_CHECK="$HEADERS_TO_CHECK X11/extensions/Xrandr.h" + AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h X11/extensions/Xrandr.h], + [X11_HEADERS_OK=yes], + [X11_HEADERS_OK=no; break], + [ + # include + # include + ] + ) + else + # There is no Xrandr extension on AIX. Code is duplicated to avoid autoconf + # 2.71+ warning "AC_CHECK_HEADERS: you should use literals" + AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h], + [X11_HEADERS_OK=yes], + [X11_HEADERS_OK=no; break], + [ + # include + # include + ] + ) fi - # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10 - AC_CHECK_HEADERS([$HEADERS_TO_CHECK], - [X11_HEADERS_OK=yes], - [X11_HEADERS_OK=no; break], - [ - # include - # include - ] - ) - if test "x$X11_HEADERS_OK" = xno; then HELP_MSG_MISSING_DEPENDENCY([x11]) AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h Xrandr.h XTest.h Intrinsic.h). $HELP_MSG]) From 014c5ae90a306221fdb8bf67f93e6a1970457e22 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 18 Jan 2023 08:16:03 +0000 Subject: [PATCH 075/205] 8297480: GetPrimitiveArrayCritical in imageioJPEG misses result - NULL check Backport-of: 2f8a5c2eca0dc3dad08b7b2c33394ac214907008 --- src/java.desktop/share/native/libjavajpeg/imageioJPEG.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c b/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c index 453bb1f3235..4ebd565fe35 100644 --- a/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c +++ b/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c @@ -713,6 +713,7 @@ static int setQTables(JNIEnv *env, CHECK_NULL_RETURN(table, 0); qdata = (*env)->GetObjectField(env, table, JPEGQTable_tableID); qdataBody = (*env)->GetPrimitiveArrayCritical(env, qdata, NULL); + CHECK_NULL_RETURN(qdataBody, 0); if (cinfo->is_decompressor) { decomp = (j_decompress_ptr) cinfo; From 465b4f2e5842a4b36c342ceaed8e473c2bb2760a Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 18 Jan 2023 08:17:10 +0000 Subject: [PATCH 076/205] 8298093: improve cleanup and error handling of awt_parseColorModel in awt_parseImage.c Backport-of: 98fa48c330941efe6588a907b383802a11ed0e6b --- .../native/libawt/awt/image/awt_parseImage.c | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c b/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c index 4b6b24183be..c8d1464f8aa 100644 --- a/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c +++ b/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -454,6 +454,7 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, int i; static jobject s_jdefCM = NULL; + cmP->nBits = NULL; if (JNU_IsNull(env, jcmodel)) { JNU_ThrowNullPointerException(env, "null ColorModel object"); @@ -485,7 +486,6 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, return -1; } - cmP->nBits = NULL; if (SAFE_TO_ALLOC_2(cmP->numComponents, sizeof(jint))) { cmP->nBits = (jint *)malloc(cmP->numComponents * sizeof(jint)); } @@ -508,7 +508,9 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, cmP->csType = (*env)->GetIntField(env, cmP->jcmodel, g_CMcsTypeID); cmP->cmType = getColorModelType(env, jcmodel); - JNU_CHECK_EXCEPTION_RETURN(env, -1); + if ((*env)->ExceptionCheck(env)) { + goto cleanup; + } cmP->isDefaultCM = FALSE; cmP->isDefaultCompatCM = FALSE; @@ -530,14 +532,21 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, if (s_jdefCM == NULL) { jobject defCM; jclass jcm = (*env)->FindClass(env, "java/awt/image/ColorModel"); - CHECK_NULL_RETURN(jcm, -1); + if (jcm == NULL) { + goto cleanup; + } defCM = (*env)->CallStaticObjectMethod(env, jcm, g_CMgetRGBdefaultMID, NULL); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionClear(env); + JNU_ThrowNullPointerException(env, "Unable to find default CM"); + goto cleanup; + } s_jdefCM = (*env)->NewGlobalRef(env, defCM); if (defCM == NULL || s_jdefCM == NULL) { (*env)->ExceptionClear(env); JNU_ThrowNullPointerException(env, "Unable to find default CM"); - return -1; + goto cleanup; } } cmP->isDefaultCM = ((*env)->IsSameObject(env, s_jdefCM, jcmodel)); @@ -549,12 +558,12 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, if (cmP->csType != java_awt_color_ColorSpace_TYPE_RGB || !cmP->is_sRGB) { - return -1; + goto cleanup; } for (i = 0; i < cmP->numComponents; i++) { if (cmP->nBits[i] != 8) { - return -1; + goto cleanup; } } } @@ -572,7 +581,7 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, cmP->jrgb, NULL); if (rgb == NULL) { - return -1; + goto cleanup; } for (i=0; i < cmP->mapSize; i++) { if ((rgb[i]&0xff000000) == 0) { @@ -590,6 +599,10 @@ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, } return 1; + +cleanup: + free(cmP->nBits); + return -1; } void awt_freeParsedRaster(RasterS_t *rasterP, int freeRasterP) { From c1dfd3ee8f7a9b9c24cb5a6b5cf7c3b58ed5db4a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Jan 2023 11:08:52 +0000 Subject: [PATCH 077/205] 8300424: [11u] Chunk lost in backport of 8297569 Reviewed-by: sgehwolf --- src/java.base/share/classes/java/net/HostPortrange.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/java.base/share/classes/java/net/HostPortrange.java b/src/java.base/share/classes/java/net/HostPortrange.java index 7957e9f2e00..ec602035f4d 100644 --- a/src/java.base/share/classes/java/net/HostPortrange.java +++ b/src/java.base/share/classes/java/net/HostPortrange.java @@ -149,9 +149,6 @@ public int hashCode() { // regular domain name hoststr = toLowerCase(hoststr); } - } else { - // regular domain name - hoststr = toLowerCase(hoststr); } } hostname = hoststr; From 972ff6fb644e66ea8a0be1c466457e90debeab12 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Jan 2023 13:58:37 +0000 Subject: [PATCH 078/205] 8280896: java/nio/file/Files/probeContentType/Basic.java fails on Windows 11 Backport-of: f9137cb7b79f86e96247e7b4bc4abb03857afe75 --- test/jdk/java/nio/file/Files/probeContentType/Basic.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/nio/file/Files/probeContentType/Basic.java b/test/jdk/java/nio/file/Files/probeContentType/Basic.java index 8bfa55f12d8..a94e94abb8d 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, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -162,7 +162,7 @@ public static void main(String[] args) throws IOException { 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")), + 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")), From 01b213899cb8124860441fa26c9652b4a4bff896 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Jan 2023 14:06:59 +0000 Subject: [PATCH 079/205] 8297088: Update LCMS to 2.14 Reviewed-by: mbaesken Backport-of: f2c3f352bbe7222d7a43fa26f091372ecef20a68 --- src/java.desktop/share/legal/lcms.md | 112 +++- .../share/native/liblcms/UPDATING.txt | 23 + .../share/native/liblcms/cmsalpha.c | 20 +- .../share/native/liblcms/cmscam02.c | 2 +- .../share/native/liblcms/cmscgats.c | 331 +++++++--- .../share/native/liblcms/cmscnvrt.c | 6 +- .../share/native/liblcms/cmserr.c | 51 +- .../share/native/liblcms/cmsgamma.c | 81 ++- .../share/native/liblcms/cmsgmt.c | 99 ++- .../share/native/liblcms/cmshalf.c | 4 +- .../share/native/liblcms/cmsintrp.c | 46 +- .../share/native/liblcms/cmsio0.c | 217 +++++-- .../share/native/liblcms/cmsio1.c | 13 +- .../share/native/liblcms/cmslut.c | 9 +- .../share/native/liblcms/cmsmd5.c | 2 +- .../share/native/liblcms/cmsmtrx.c | 2 +- .../share/native/liblcms/cmsnamed.c | 12 +- .../share/native/liblcms/cmsopt.c | 32 +- .../share/native/liblcms/cmspack.c | 606 +++++++++++++++--- .../share/native/liblcms/cmspcs.c | 16 +- .../share/native/liblcms/cmsplugin.c | 186 ++++-- .../share/native/liblcms/cmsps2.c | 6 +- .../share/native/liblcms/cmssamp.c | 10 +- src/java.desktop/share/native/liblcms/cmssm.c | 2 +- .../share/native/liblcms/cmstypes.c | 406 ++++++++---- .../share/native/liblcms/cmsvirt.c | 35 +- .../share/native/liblcms/cmswtpnt.c | 10 +- .../share/native/liblcms/cmsxform.c | 94 ++- src/java.desktop/share/native/liblcms/lcms2.h | 54 +- .../share/native/liblcms/lcms2_internal.h | 80 ++- .../share/native/liblcms/lcms2_plugin.h | 26 +- 31 files changed, 2002 insertions(+), 591 deletions(-) create mode 100644 src/java.desktop/share/native/liblcms/UPDATING.txt diff --git a/src/java.desktop/share/legal/lcms.md b/src/java.desktop/share/legal/lcms.md index 1977a6b1597..1576edb8db6 100644 --- a/src/java.desktop/share/legal/lcms.md +++ b/src/java.desktop/share/legal/lcms.md @@ -1,27 +1,107 @@ -## Little Color Management System (LCMS) v2.12 +## Little Color Management System (LCMS) v2.14 ### LCMS License
 
-Little Color Management System
-Copyright (c) 1998-2020 Marti Maria Saguer
+README.1ST file information
+
+LittleCMS core is released under MIT License
+
+---------------------------------
+
+Little CMS
+Copyright (c) 1998-2022 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:
+liblcms/cmssm.c
+
+Copyright 2001, softSurfer (www.softsurfer.com)
+
+This code may be freely used and modified for any purpose
+providing that this copyright notice is included with it.
+SoftSurfer makes no warranty for this code, and cannot be held
+liable for any real or imagined damage resulting from its use.
+Users of this code must verify correctness for their application.
+
 
 
+ +### AUTHORS File Information +``` + +Main Author +------------ +Marti Maria + + +Contributors +------------ +Bob Friesenhahn +Kai-Uwe Behrmann +Stuart Nixon +Jordi Vilar +Richard Hughes +Auke Nauta +Chris Evans (Google) +Lorenzo Ridolfi +Robin Watts (Artifex) +Shawn Pedersen +Andrew Brygin +Samuli Suominen +Florian Hˆch +Aurelien Jarno +Claudiu Cebuc +Michael Vhrel (Artifex) +Michal Cihar +Daniel Kaneider +Mateusz Jurczyk (Google) +Paul Miller +SÈbastien LÈon +Christian Schmitz +XhmikosR +Stanislav Brabec (SuSe) +Leonhard Gruenschloss (Google) +Patrick Noffke +Christopher James Halse Rogers +John Hein +Thomas Weber (Debian) +Mark Allen +Noel Carboni +Sergei Trofimovic +Philipp Knechtges + +Special Thanks +-------------- +Artifex software +AlienSkin software +Jan Morovic +Jos Vernon (WebSupergoo) +Harald Schneider (Maxon) +Christian Albrecht +Dimitrios Anastassakis +Lemke Software +Tim Zaman + + +``` diff --git a/src/java.desktop/share/native/liblcms/UPDATING.txt b/src/java.desktop/share/native/liblcms/UPDATING.txt new file mode 100644 index 00000000000..7c68243c65d --- /dev/null +++ b/src/java.desktop/share/native/liblcms/UPDATING.txt @@ -0,0 +1,23 @@ +# Tips and tasks when updating LittleCMS sources to a newer version. + +Download and unzip latest release from https://sourceforge.net/projects/lcms/files/ +Replace files in src/java.desktop/share/native/liblcms with files from unzipped src and include folders +Replace is important because the lcms sources here are just the subset needed by JDK. +This is deliberate, so when updating be sure to import only the same files. +If a file has been removed from upstream you will notice it during the copy. +It should then be removed from the JDK sources. +If a new file is needed then the build will fail. Manually copy that in. + +Some re-editing of these updated files will be needed. +Use "expand" and "sed" to remove tabs and trailing white space from the imported files. +Re-apply the GPL headers used by the JDK. If done correctly these should then not +show up in the PR diff. + +Update src/java.desktop/share/legal/lcms.md per the current license/copyrights/attributions etc. + +Build on all platforms. +If there are compiler warnings causing build failures, update the disabled warnings in +make/modules/java.desktop/lib/Awt2dLibraries.gmk +Run all automated client tests on all platforms. +Also run J2Ddemo and pay particular attention to the "color" tab. +Visually verify the color transforms against the same with the current/previous JDK \ No newline at end of file diff --git a/src/java.desktop/share/native/liblcms/cmsalpha.c b/src/java.desktop/share/native/liblcms/cmsalpha.c index 49ff22df764..c6a37e79727 100644 --- a/src/java.desktop/share/native/liblcms/cmsalpha.c +++ b/src/java.desktop/share/native/liblcms/cmsalpha.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -220,21 +220,21 @@ static void fromFLTto8(void* dst, const void* src) { cmsFloat32Number n = *(cmsFloat32Number*)src; - *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f); + *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0); } static void fromFLTto16(void* dst, const void* src) { cmsFloat32Number n = *(cmsFloat32Number*)src; - *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f); + *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0); } static void fromFLTto16SE(void* dst, const void* src) { cmsFloat32Number n = *(cmsFloat32Number*)src; - cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f); + cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0); *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i); } @@ -272,7 +272,7 @@ void fromHLFto8(void* dst, const void* src) { #ifndef CMS_NO_HALF_SUPPORT cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src); - *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f); + *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0); #else cmsUNUSED_PARAMETER(dst); cmsUNUSED_PARAMETER(src); @@ -285,7 +285,7 @@ void fromHLFto16(void* dst, const void* src) { #ifndef CMS_NO_HALF_SUPPORT cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src); - *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f); + *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0); #else cmsUNUSED_PARAMETER(dst); cmsUNUSED_PARAMETER(src); @@ -297,7 +297,7 @@ void fromHLFto16SE(void* dst, const void* src) { #ifndef CMS_NO_HALF_SUPPORT cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src); - cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f); + cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0); *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i); #else cmsUNUSED_PARAMETER(dst); @@ -443,9 +443,9 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format, cmsUInt32Number channelSize = trueBytesSize(Format); cmsUInt32Number pixelSize = channelSize * total_chans; - // Sanity check - if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS) - return; + // Sanity check + if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS) + return; memset(channels, 0, sizeof(channels)); diff --git a/src/java.desktop/share/native/liblcms/cmscam02.c b/src/java.desktop/share/native/liblcms/cmscam02.c index ba902e06709..23f12419676 100644 --- a/src/java.desktop/share/native/liblcms/cmscam02.c +++ b/src/java.desktop/share/native/liblcms/cmscam02.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), diff --git a/src/java.desktop/share/native/liblcms/cmscgats.c b/src/java.desktop/share/native/liblcms/cmscgats.c index 07109b1e449..61d5533e540 100644 --- a/src/java.desktop/share/native/liblcms/cmscgats.c +++ b/src/java.desktop/share/native/liblcms/cmscgats.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -162,9 +162,18 @@ typedef struct _FileContext { FILE* Stream; // File stream or NULL if holded in memory } FILECTX; -// This struct hold all information about an open IT8 handler. +//Very simple string typedef struct { + struct struct_it8* it8; + cmsInt32Number max; + cmsInt32Number len; + char* begin; + } string; + + +// This struct hold all information about an open IT8 handler. +typedef struct struct_it8 { cmsUInt32Number TablesCount; // How many tables in this stream cmsUInt32Number nTable; // The actual table @@ -182,8 +191,8 @@ typedef struct { cmsInt32Number inum; // integer value cmsFloat64Number dnum; // real value - char id[MAXID]; // identifier - char str[MAXSTR]; // string + string* id; // identifier + string* str; // string // Allowed keywords & datasets. They have visibility on whole stream KEYVALUE* ValidKeywords; @@ -268,7 +277,7 @@ static PROPERTY PredefinedProperties[] = { {"MATERIAL", WRITE_STRINGIFY}, // Identifies the material on which the target was produced using a code // uniquely identifying th e material. This is intend ed to be used for IT8.7 - // physical targets only (i.e . IT8.7/1 a nd IT8.7/2). + // physical targets only (i.e . IT8.7/1 and IT8.7/2). {"INSTRUMENTATION", WRITE_STRINGIFY}, // Used to report the specific instrumentation used (manufacturer and // model number) to generate the data reported. This data will often @@ -383,6 +392,65 @@ static const char* PredefinedSampleID[] = { //Forward declaration of some internal functions static void* AllocChunk(cmsIT8* it8, cmsUInt32Number size); +static +string* StringAlloc(cmsIT8* it8, int max) +{ + string* s = (string*) AllocChunk(it8, sizeof(string)); + if (s == NULL) return NULL; + + s->it8 = it8; + s->max = max; + s->len = 0; + s->begin = (char*) AllocChunk(it8, s->max); + + return s; +} + +static +void StringClear(string* s) +{ + s->len = 0; +} + +static +void StringAppend(string* s, char c) +{ + if (s->len + 1 >= s->max) + { + char* new_ptr; + + s->max *= 10; + new_ptr = (char*) AllocChunk(s->it8, s->max); + if (new_ptr != NULL && s->begin != NULL) + memcpy(new_ptr, s->begin, s->len); + + s->begin = new_ptr; + } + + if (s->begin != NULL) + { + s->begin[s->len++] = c; + s->begin[s->len] = 0; + } +} + +static +char* StringPtr(string* s) +{ + return s->begin; +} + +static +void StringCat(string* s, const char* c) +{ + while (*c) + { + StringAppend(s, *c); + c++; + } +} + + // Checks whatever c is a separator static cmsBool isseparator(int c) @@ -708,14 +776,44 @@ cmsFloat64Number ParseFloatNumber(const char *Buffer) } +// Reads a string, special case to avoid infinite resursion on .include +static +void InStringSymbol(cmsIT8* it8) +{ + while (isseparator(it8->ch)) + NextCh(it8); + + if (it8->ch == '\'' || it8->ch == '\"') + { + int sng; + + sng = it8->ch; + StringClear(it8->str); + + NextCh(it8); + + while (it8->ch != sng) { + + if (it8->ch == '\n' || it8->ch == '\r' || it8->ch == 0) break; + else { + StringAppend(it8->str, (char)it8->ch); + NextCh(it8); + } + } + + it8->sy = SSTRING; + NextCh(it8); + } + else + SynError(it8, "String expected"); + +} + // Reads next symbol static void InSymbol(cmsIT8* it8) { - CMSREGISTER char *idptr; - CMSREGISTER int k; SYMBOL key; - int sng; do { @@ -724,21 +822,18 @@ void InSymbol(cmsIT8* it8) if (isfirstidchar(it8->ch)) { // Identifier - k = 0; - idptr = it8->id; + StringClear(it8->id); do { - if (++k < MAXID) *idptr++ = (char) it8->ch; + StringAppend(it8->id, (char) it8->ch); NextCh(it8); } while (isidchar(it8->ch)); - *idptr = '\0'; - - key = BinSrchKey(it8->id); + key = BinSrchKey(StringPtr(it8->id)); if (key == SUNDEFINED) it8->sy = SIDENT; else it8->sy = key; @@ -773,6 +868,7 @@ void InSymbol(cmsIT8* it8) if ((cmsFloat64Number) it8->inum * 16.0 + (cmsFloat64Number) j > (cmsFloat64Number)+2147483647.0) { SynError(it8, "Invalid hexadecimal number"); + it8->sy = SEOF; return; } @@ -794,6 +890,7 @@ void InSymbol(cmsIT8* it8) if ((cmsFloat64Number) it8->inum * 2.0 + j > (cmsFloat64Number)+2147483647.0) { SynError(it8, "Invalid binary number"); + it8->sy = SEOF; return; } @@ -834,26 +931,27 @@ void InSymbol(cmsIT8* it8) if (isidchar(it8 ->ch)) { + char buffer[127]; + if (it8 ->sy == SINUM) { - snprintf(it8->id, 127, "%d", it8->inum); + snprintf(buffer, sizeof(buffer), "%d", it8->inum); } else { - snprintf(it8->id, 127, it8 ->DoubleFormatter, it8->dnum); + snprintf(buffer, sizeof(buffer), it8 ->DoubleFormatter, it8->dnum); } - k = (int) strlen(it8 ->id); - idptr = it8 ->id + k; + StringCat(it8->id, buffer); + do { - if (++k < MAXID) *idptr++ = (char) it8->ch; + StringAppend(it8->id, (char) it8->ch); NextCh(it8); } while (isidchar(it8->ch)); - *idptr = '\0'; it8->sy = SIDENT; } return; @@ -862,12 +960,8 @@ void InSymbol(cmsIT8* it8) else switch ((int) it8->ch) { - // EOF marker -- ignore it - case '\x1a': - NextCh(it8); - break; - // Eof stream markers + case '\x1a': case 0: case -1: it8->sy = SEOF; @@ -901,29 +995,13 @@ void InSymbol(cmsIT8* it8) // String. case '\'': case '\"': - idptr = it8->str; - sng = it8->ch; - k = 0; - NextCh(it8); - - while (k < (MAXSTR-1) && it8->ch != sng) { - - if (it8->ch == '\n'|| it8->ch == '\r') k = MAXSTR+1; - else { - *idptr++ = (char) it8->ch; - NextCh(it8); - k++; - } - } - - it8->sy = SSTRING; - *idptr = '\0'; - NextCh(it8); + InStringSymbol(it8); break; default: SynError(it8, "Unrecognized character: 0x%x", it8 ->ch); + it8->sy = SEOF; return; } @@ -938,24 +1016,33 @@ void InSymbol(cmsIT8* it8) if(it8 -> IncludeSP >= (MAXINCLUDE-1)) { SynError(it8, "Too many recursion levels"); + it8->sy = SEOF; return; } - InSymbol(it8); - if (!Check(it8, SSTRING, "Filename expected")) return; + InStringSymbol(it8); + if (!Check(it8, SSTRING, "Filename expected")) + { + it8->sy = SEOF; + return; + } FileNest = it8 -> FileStack[it8 -> IncludeSP + 1]; if(FileNest == NULL) { FileNest = it8 ->FileStack[it8 -> IncludeSP + 1] = (FILECTX*)AllocChunk(it8, sizeof(FILECTX)); - //if(FileNest == NULL) - // TODO: how to manage out-of-memory conditions? + if (FileNest == NULL) { + SynError(it8, "Out of memory"); + it8->sy = SEOF; + return; + } } - if (BuildAbsolutePath(it8->str, + if (BuildAbsolutePath(StringPtr(it8->str), it8->FileStack[it8->IncludeSP]->FileName, FileNest->FileName, cmsMAX_PATH-1) == FALSE) { SynError(it8, "File path too long"); + it8->sy = SEOF; return; } @@ -963,6 +1050,7 @@ void InSymbol(cmsIT8* it8) if (FileNest->Stream == NULL) { SynError(it8, "File %s not found", FileNest->FileName); + it8->sy = SEOF; return; } it8->IncludeSP++; @@ -1013,12 +1101,12 @@ cmsBool GetVal(cmsIT8* it8, char* Buffer, cmsUInt32Number max, const char* Error case SEOLN: // Empty value Buffer[0]=0; break; - case SIDENT: strncpy(Buffer, it8->id, max); + case SIDENT: strncpy(Buffer, StringPtr(it8->id), max); Buffer[max-1]=0; break; case SINUM: snprintf(Buffer, max, "%d", it8 -> inum); break; case SDNUM: snprintf(Buffer, max, it8->DoubleFormatter, it8 -> dnum); break; - case SSTRING: strncpy(Buffer, it8->str, max); + case SSTRING: strncpy(Buffer, StringPtr(it8->str), max); Buffer[max-1] = 0; break; @@ -1123,9 +1211,12 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size) it8 ->Allocator.BlockSize = size; it8 ->Allocator.Used = 0; - it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize); + it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize); } + if (it8->Allocator.Block == NULL) + return NULL; + ptr = it8 ->Allocator.Block + it8 ->Allocator.Used; it8 ->Allocator.Used += size; @@ -1143,7 +1234,7 @@ char *AllocString(cmsIT8* it8, const char* str) ptr = (char *) AllocChunk(it8, Size); - if (ptr) strncpy (ptr, str, Size-1); + if (ptr) memcpy(ptr, str, Size-1); return ptr; } @@ -1342,6 +1433,9 @@ cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID) it8->IncludeSP = 0; it8 -> lineno = 1; + it8->id = StringAlloc(it8, MAXSTR); + it8->str = StringAlloc(it8, MAXSTR); + strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT); cmsIT8SetSheetType((cmsHANDLE) it8, "CGATS.17"); @@ -1463,28 +1557,45 @@ const char* CMSEXPORT cmsIT8GetPropertyMulti(cmsHANDLE hIT8, const char* Key, co // ----------------------------------------------------------------- Datasets +// A safe atoi that returns 0 when NULL input is given +static +cmsInt32Number satoi(const char* b) +{ + int n; + + if (b == NULL) return 0; + + n = atoi(b); + if (n > 0x7fffffffL) return 0x7fffffffL; + if (n < -0x7ffffffeL) return -0x7ffffffeL; + + return (cmsInt32Number)n; +} + static -void AllocateDataFormat(cmsIT8* it8) +cmsBool AllocateDataFormat(cmsIT8* it8) { TABLE* t = GetTable(it8); - if (t -> DataFormat) return; // Already allocated + if (t -> DataFormat) return TRUE; // Already allocated - t -> nSamples = (int) cmsIT8GetPropertyDbl(it8, "NUMBER_OF_FIELDS"); + t -> nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS")); if (t -> nSamples <= 0) { SynError(it8, "AllocateDataFormat: Unknown NUMBER_OF_FIELDS"); - t -> nSamples = 10; + return FALSE; } t -> DataFormat = (char**) AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * sizeof(char *)); if (t->DataFormat == NULL) { SynError(it8, "AllocateDataFormat: Unable to allocate dataFormat array"); + return FALSE; } + return TRUE; } static @@ -1503,8 +1614,11 @@ cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label) { TABLE* t = GetTable(it8); - if (!t->DataFormat) - AllocateDataFormat(it8); + if (!t->DataFormat) { + + if (!AllocateDataFormat(it8)) + return FALSE; + } if (n > t -> nSamples) { SynError(it8, "More than NUMBER_OF_FIELDS fields."); @@ -1513,6 +1627,7 @@ cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label) if (t->DataFormat) { t->DataFormat[n] = AllocString(it8, label); + if (t->DataFormat[n] == NULL) return FALSE; } return TRUE; @@ -1525,20 +1640,31 @@ cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE h, int n, const char *Sample) return SetDataFormat(it8, n, Sample); } -// A safe atoi that returns 0 when NULL input is given +// Convert to binary static -cmsInt32Number satoi(const char* b) +const char* satob(const char* v) { - if (b == NULL) return 0; - return atoi(b); + cmsUInt32Number x; + static char buf[33]; + char *s = buf + 33; + + if (v == NULL) return "0"; + + x = atoi(v); + *--s = 0; + if (!x) *--s = '0'; + for (; x; x /= 2) *--s = '0' + x%2; + + return s; } + static -void AllocateDataSet(cmsIT8* it8) +cmsBool AllocateDataSet(cmsIT8* it8) { TABLE* t = GetTable(it8); - if (t -> Data) return; // Already allocated + if (t -> Data) return TRUE; // Already allocated t-> nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS")); t-> nPatches = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS")); @@ -1546,6 +1672,7 @@ void AllocateDataSet(cmsIT8* it8) if (t -> nSamples < 0 || t->nSamples > 0x7ffe || t->nPatches < 0 || t->nPatches > 0x7ffe) { SynError(it8, "AllocateDataSet: too much data"); + return FALSE; } else { // Some dumb analizers warns of possible overflow here, just take a look couple of lines above. @@ -1553,9 +1680,11 @@ void AllocateDataSet(cmsIT8* it8) if (t->Data == NULL) { SynError(it8, "AllocateDataSet: Unable to allocate data array"); + return FALSE; } } + return TRUE; } static @@ -1577,8 +1706,9 @@ cmsBool SetData(cmsIT8* it8, int nSet, int nField, const char *Val) { TABLE* t = GetTable(it8); - if (!t->Data) - AllocateDataSet(it8); + if (!t->Data) { + if (!AllocateDataSet(it8)) return FALSE; + } if (!t->Data) return FALSE; @@ -1718,7 +1848,7 @@ void WriteHeader(cmsIT8* it8, SAVESTREAM* fp) break; case WRITE_BINARY: - Writef(fp, "\t0x%B", satoi(p ->Value)); + Writef(fp, "\t0b%s", satob(p ->Value)); break; case WRITE_PAIR: @@ -1888,7 +2018,7 @@ cmsBool DataFormatSection(cmsIT8* it8) return SynError(it8, "Sample type expected"); } - if (!SetDataFormat(it8, iField, it8->id)) return FALSE; + if (!SetDataFormat(it8, iField, StringPtr(it8->id))) return FALSE; iField++; InSymbol(it8); @@ -1921,8 +2051,9 @@ cmsBool DataSection (cmsIT8* it8) InSymbol(it8); // Eats "BEGIN_DATA" CheckEOLN(it8); - if (!t->Data) - AllocateDataSet(it8); + if (!t->Data) { + if (!AllocateDataSet(it8)) return FALSE; + } while (it8->sy != SEND_DATA && it8->sy != SEOF) { @@ -1934,11 +2065,28 @@ cmsBool DataSection (cmsIT8* it8) if (it8->sy != SEND_DATA && it8->sy != SEOF) { + switch (it8->sy) + { + + // To keep very long data + case SIDENT: + if (!SetData(it8, iSet, iField, StringPtr(it8->id))) + return FALSE; + break; + + case SSTRING: + if (!SetData(it8, iSet, iField, StringPtr(it8->str))) + return FALSE; + break; + + default: + if (!GetVal(it8, Buffer, 255, "Sample data expected")) return FALSE; if (!SetData(it8, iSet, iField, Buffer)) return FALSE; + } iField++; @@ -1994,7 +2142,7 @@ cmsBool HeaderSection(cmsIT8* it8) case SIDENT: - strncpy(VarName, it8->id, MAXID - 1); + strncpy(VarName, StringPtr(it8->id), MAXID - 1); VarName[MAXID - 1] = 0; if (!IsAvailableOnList(it8->ValidKeywords, VarName, NULL, &Key)) { @@ -2138,7 +2286,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet) // If a newline is found, then this is a type string if (it8 ->ch == '\n' || it8->ch == '\r') { - cmsIT8SetSheetType(it8, it8 ->id); + cmsIT8SetSheetType(it8, StringPtr(it8 ->id)); InSymbol(it8); } else @@ -2150,7 +2298,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet) else // Validate quoted strings if (it8 ->sy == SSTRING) { - cmsIT8SetSheetType(it8, it8 ->str); + cmsIT8SetSheetType(it8, StringPtr(it8 ->str)); InSymbol(it8); } } @@ -2452,15 +2600,18 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyN } - Props = (char **) AllocChunk(it8, sizeof(char *) * n); + 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; - } + // 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; } @@ -2492,12 +2643,14 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cP Props = (const char **) AllocChunk(it8, sizeof(char *) * n); + if (Props != NULL) { - // Pass#2 - Fill pointers - n = 0; - for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) { - if(tmp->Subkey != NULL) - Props[n++] = p ->Subkey; + // Pass#2 - Fill pointers + n = 0; + for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) { + if (tmp->Subkey != NULL) + Props[n++] = p->Subkey; + } } *SubpropertyNames = Props; @@ -2673,8 +2826,12 @@ cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch, const char* if (t-> nPatches == 0) { - AllocateDataFormat(it8); - AllocateDataSet(it8); + if (!AllocateDataFormat(it8)) + return FALSE; + + if (!AllocateDataSet(it8)) + return FALSE; + CookPointers(it8); } diff --git a/src/java.desktop/share/native/liblcms/cmscnvrt.c b/src/java.desktop/share/native/liblcms/cmscnvrt.c index 4bee13d6491..535a9e12d7e 100644 --- a/src/java.desktop/share/native/liblcms/cmscnvrt.c +++ b/src/java.desktop/share/native/liblcms/cmscnvrt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -415,7 +415,7 @@ cmsBool ComputeConversion(cmsUInt32Number i, if (BPC) { - cmsCIEXYZ BlackPointIn, BlackPointOut; + cmsCIEXYZ BlackPointIn = { 0, 0, 0}, BlackPointOut = { 0, 0, 0 }; cmsDetectBlackPoint(&BlackPointIn, hProfiles[i-1], Intent, 0); cmsDetectDestinationBlackPoint(&BlackPointOut, hProfiles[i], Intent, 0); @@ -659,7 +659,7 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID, ColorSpaceOut == cmsSigRgbData || ColorSpaceOut == cmsSigCmykData) { - cmsStage* clip = _cmsStageClipNegatives(Result->ContextID, cmsChannelsOf(ColorSpaceOut)); + cmsStage* clip = _cmsStageClipNegatives(Result->ContextID, cmsChannelsOfColorSpace(ColorSpaceOut)); if (clip == NULL) goto Error; if (!cmsPipelineInsertStage(Result, cmsAT_END, clip)) diff --git a/src/java.desktop/share/native/liblcms/cmserr.c b/src/java.desktop/share/native/liblcms/cmserr.c index 999bc493d21..772a0a169e5 100644 --- a/src/java.desktop/share/native/liblcms/cmserr.c +++ b/src/java.desktop/share/native/liblcms/cmserr.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -108,7 +108,7 @@ long int CMSEXPORT cmsfilelength(FILE* f) // User may override this behaviour by using a memory plug-in, which basically replaces // the default memory management functions. In this case, no check is performed and it -// is up to the plug-in writter to keep in the safe side. There are only three functions +// is up to the plug-in writer to keep in the safe side. There are only three functions // required to be implemented: malloc, realloc and free, although the user may want to // replace the optional mallocZero, calloc and dup as well. @@ -337,7 +337,7 @@ void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Numbe // Sub allocation takes care of many pointers of small size. The memory allocated in // this way have be freed at once. Next function allocates a single chunk for linked list -// I prefer this method over realloc due to the big inpact on xput realloc may have if +// I prefer this method over realloc due to the big impact on xput realloc may have if // memory is being swapped to disk. This approach is safer (although that may not be true on all platforms) static _cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32Number Initial) @@ -642,7 +642,6 @@ cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Data) if (Plugin ->CreateMutexPtr == NULL || Plugin ->DestroyMutexPtr == NULL || Plugin ->LockMutexPtr == NULL || Plugin ->UnlockMutexPtr == NULL) return FALSE; - ctx->CreateMutexPtr = Plugin->CreateMutexPtr; ctx->DestroyMutexPtr = Plugin ->DestroyMutexPtr; ctx ->LockMutexPtr = Plugin ->LockMutexPtr; @@ -690,3 +689,47 @@ void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx) ptr ->UnlockMutexPtr(ContextID, mtx); } } + +// The global Context0 storage for parallelization plug-in + _cmsParallelizationPluginChunkType _cmsParallelizationPluginChunk = { 0 }; + +// Allocate parallelization container. +void _cmsAllocParallelizationPluginChunk(struct _cmsContext_struct* ctx, + const struct _cmsContext_struct* src) +{ + if (src != NULL) { + void* from = src->chunks[ParallelizationPlugin]; + ctx->chunks[ParallelizationPlugin] = _cmsSubAllocDup(ctx->MemPool, from, sizeof(_cmsParallelizationPluginChunkType)); + } + else { + _cmsParallelizationPluginChunkType ParallelizationPluginChunk = { 0 }; + ctx->chunks[ParallelizationPlugin] = _cmsSubAllocDup(ctx->MemPool, &ParallelizationPluginChunk, sizeof(_cmsParallelizationPluginChunkType)); + } +} + +// Register parallel processing +cmsBool _cmsRegisterParallelizationPlugin(cmsContext ContextID, cmsPluginBase* Data) +{ + cmsPluginParalellization* Plugin = (cmsPluginParalellization*)Data; + _cmsParallelizationPluginChunkType* ctx = (_cmsParallelizationPluginChunkType*)_cmsContextGetClientChunk(ContextID, ParallelizationPlugin); + + if (Data == NULL) { + + // No parallelization routines + ctx->MaxWorkers = 0; + ctx->WorkerFlags = 0; + ctx->SchedulerFn = NULL; + return TRUE; + } + + // callback is required + if (Plugin->SchedulerFn == NULL) return FALSE; + + ctx->MaxWorkers = Plugin->MaxWorkers; + ctx->WorkerFlags = Plugin->WorkerFlags; + ctx->SchedulerFn = Plugin->SchedulerFn; + + // All is ok + return TRUE; +} + diff --git a/src/java.desktop/share/native/liblcms/cmsgamma.c b/src/java.desktop/share/native/liblcms/cmsgamma.c index f266f2e05a6..b5fd47a8ed1 100644 --- a/src/java.desktop/share/native/liblcms/cmsgamma.c +++ b/src/java.desktop/share/native/liblcms/cmsgamma.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -236,7 +236,7 @@ _cmsParametricCurvesCollection *GetParametricCurveByType(cmsContext ContextID, i } // Low level allocate, which takes care of memory details. nEntries may be zero, and in this case -// no optimation curve is computed. nSegments may also be zero in the inverse case, where only the +// no optimization curve is computed. nSegments may also be zero in the inverse case, where only the // optimization curve is given. Both features simultaneously is an error static cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEntries, @@ -456,8 +456,8 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu // IEC 61966-3 - // Y = (aX + b)^Gamma | X <= -b/a - // Y = c | else + // Y = (aX + b)^Gamma + c | X <= -b/a + // Y = c | else case 3: { if (fabs(Params[1]) < MATRIX_DET_TOLERANCE) @@ -491,7 +491,8 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu // X=-b/a | (Y= disc) { + if (R >= disc) { + + if (fabs(Params[0]) < MATRIX_DET_TOLERANCE || + fabs(Params[1]) < MATRIX_DET_TOLERANCE) + Val = 0; + + else Val = (pow(R, 1.0 / Params[0]) - Params[2]) / Params[1]; - } - else { + } + else { + + if (fabs(Params[3]) < MATRIX_DET_TOLERANCE) + Val = 0; + else Val = R / Params[3]; - } } + } break; @@ -584,26 +588,29 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu // X=(Y-f)/c | else case -5: { - if (fabs(Params[1]) < MATRIX_DET_TOLERANCE || - fabs(Params[3]) < MATRIX_DET_TOLERANCE) - { - Val = 0; - } - else - { - disc = Params[3] * Params[4] + Params[6]; - if (R >= disc) { + disc = Params[3] * Params[4] + Params[6]; + if (R >= disc) { + + e = R - Params[5]; + if (e < 0) + Val = 0; + else + { + if (fabs(Params[0]) < MATRIX_DET_TOLERANCE || + fabs(Params[1]) < MATRIX_DET_TOLERANCE) - e = R - Params[5]; - if (e < 0) Val = 0; else Val = (pow(e, 1.0 / Params[0]) - Params[2]) / Params[1]; } - else { + } + else { + if (fabs(Params[3]) < MATRIX_DET_TOLERANCE) + Val = 0; + else Val = (R - Params[6]) / Params[3]; - } } + } break; @@ -624,7 +631,8 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu // ((Y - c) ^1/Gamma - b) / a case -6: { - if (fabs(Params[1]) < MATRIX_DET_TOLERANCE) + if (fabs(Params[0]) < MATRIX_DET_TOLERANCE || + fabs(Params[1]) < MATRIX_DET_TOLERANCE) { Val = 0; } @@ -1496,6 +1504,9 @@ cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Num } } + // We need enough valid samples + if (n <= 1) return -1.0; + // Take a look on SD to see if gamma isn't exponential at all Std = sqrt((n * sum2 - sum * sum) / (n*(n-1))); diff --git a/src/java.desktop/share/native/liblcms/cmsgmt.c b/src/java.desktop/share/native/liblcms/cmsgmt.c index 34c9a6c1bf6..60a01aa5088 100644 --- a/src/java.desktop/share/native/liblcms/cmsgmt.c +++ b/src/java.desktop/share/native/liblcms/cmsgmt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2021 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"), @@ -228,15 +228,15 @@ typedef struct { cmsHTRANSFORM hInput; // From whatever input color space. 16 bits to DBL cmsHTRANSFORM hForward, hReverse; // Transforms going from Lab to colorant and back - cmsFloat64Number Thereshold; // The thereshold after which is considered out of gamut + cmsFloat64Number Threshold; // The threshold after which is considered out of gamut } GAMUTCHAIN; // This sampler does compute gamut boundaries by comparing original -// values with a transform going back and forth. Values above ERR_THERESHOLD +// values with a transform going back and forth. Values above ERR_THRESHOLD // of maximum are considered out of gamut. -#define ERR_THERESHOLD 5 +#define ERR_THRESHOLD 5 static @@ -275,17 +275,17 @@ int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Nu // if dE1 is small and dE2 is small, value is likely to be in gamut - if (dE1 < t->Thereshold && dE2 < t->Thereshold) + if (dE1 < t->Threshold && dE2 < t->Threshold) Out[0] = 0; else { // if dE1 is small and dE2 is big, undefined. Assume in gamut - if (dE1 < t->Thereshold && dE2 > t->Thereshold) + if (dE1 < t->Threshold && dE2 > t->Threshold) Out[0] = 0; else // dE1 is big and dE2 is small, clearly out of gamut - if (dE1 > t->Thereshold && dE2 < t->Thereshold) - Out[0] = (cmsUInt16Number) _cmsQuickFloor((dE1 - t->Thereshold) + .5); + if (dE1 > t->Threshold && dE2 < t->Threshold) + Out[0] = (cmsUInt16Number) _cmsQuickFloor((dE1 - t->Threshold) + .5); else { // dE1 is big and dE2 is also big, could be due to perceptual mapping @@ -295,8 +295,8 @@ int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Nu else ErrorRatio = dE1 / dE2; - if (ErrorRatio > t->Thereshold) - Out[0] = (cmsUInt16Number) _cmsQuickFloor((ErrorRatio - t->Thereshold) + .5); + if (ErrorRatio > t->Threshold) + Out[0] = (cmsUInt16Number) _cmsQuickFloor((ErrorRatio - t->Threshold) + .5); else Out[0] = 0; } @@ -326,7 +326,8 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID, cmsStage* CLUT; cmsUInt32Number dwFormat; GAMUTCHAIN Chain; - cmsUInt32Number nChannels, nGridpoints; + cmsUInt32Number nGridpoints; + cmsInt32Number nChannels; cmsColorSpaceSignature ColorSpace; cmsUInt32Number i; cmsHPROFILE ProfileList[256]; @@ -352,10 +353,10 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID, if (cmsIsMatrixShaper(hGamut)) { - Chain.Thereshold = 1.0; + Chain.Threshold = 1.0; } else { - Chain.Thereshold = ERR_THERESHOLD; + Chain.Threshold = ERR_THRESHOLD; } @@ -375,8 +376,7 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID, ColorSpace = cmsGetColorSpace(hGamut); - - nChannels = cmsChannelsOf(ColorSpace); + nChannels = cmsChannelsOfColorSpace(ColorSpace); nGridpoints = _cmsReasonableGridpointsByColorspace(ColorSpace, cmsFLAGS_HIGHRESPRECALC); dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2)); @@ -501,6 +501,9 @@ cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile) // Create a fake formatter for result dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4, TRUE); + // Unsupported color space? + if (dwFormatter == 0) return 0; + bp.nOutputChans = T_CHANNELS(dwFormatter); bp.MaxTAC = 0; // Initial TAC is 0 @@ -617,3 +620,69 @@ cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab, return TRUE; } + +// Detect whatever a given ICC profile works in linear (gamma 1.0) space +// 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. +// For gamma close to 1.0, RGB is linear. On profiles not supported, -1 is returned. + +cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFloat64Number threshold) +{ + cmsContext ContextID; + cmsHPROFILE hXYZ; + cmsHTRANSFORM xform; + cmsToneCurve* Y_curve; + cmsUInt16Number rgb[256][3]; + cmsCIEXYZ XYZ[256]; + cmsFloat32Number Y_normalized[256]; + cmsFloat64Number gamma; + cmsProfileClassSignature cl; + int i; + + if (cmsGetColorSpace(hProfile) != cmsSigRgbData) + return -1; + + cl = cmsGetDeviceClass(hProfile); + if (cl != cmsSigInputClass && cl != cmsSigDisplayClass && + cl != cmsSigOutputClass && cl != cmsSigColorSpaceClass) + return -1; + + ContextID = cmsGetProfileContextID(hProfile); + hXYZ = cmsCreateXYZProfileTHR(ContextID); + if (hXYZ == NULL) + return -1; + xform = cmsCreateTransformTHR(ContextID, hProfile, TYPE_RGB_16, hXYZ, TYPE_XYZ_DBL, + INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE); + + if (xform == NULL) { // If not RGB or forward direction is not supported, regret with the previous error + + cmsCloseProfile(hXYZ); + return -1; + } + + for (i = 0; i < 256; i++) { + rgb[i][0] = rgb[i][1] = rgb[i][2] = FROM_8_TO_16(i); + } + + cmsDoTransform(xform, rgb, XYZ, 256); + + cmsDeleteTransform(xform); + cmsCloseProfile(hXYZ); + + for (i = 0; i < 256; i++) { + Y_normalized[i] = (cmsFloat32Number) XYZ[i].Y; + } + + Y_curve = cmsBuildTabulatedToneCurveFloat(ContextID, 256, Y_normalized); + if (Y_curve == NULL) + return -1; + + gamma = cmsEstimateGamma(Y_curve, threshold); + + cmsFreeToneCurve(Y_curve); + + return gamma; +} + diff --git a/src/java.desktop/share/native/liblcms/cmshalf.c b/src/java.desktop/share/native/liblcms/cmshalf.c index f2e28af400e..eb1d4aa6ea1 100644 --- a/src/java.desktop/share/native/liblcms/cmshalf.c +++ b/src/java.desktop/share/native/liblcms/cmshalf.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -406,7 +406,7 @@ static const cmsUInt32Number Mantissa[2048] = { 0x387fc000, 0x387fe000 }; -static cmsUInt16Number Offset[64] = { +static const cmsUInt16Number Offset[64] = { 0x0000, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, diff --git a/src/java.desktop/share/native/liblcms/cmsintrp.c b/src/java.desktop/share/native/liblcms/cmsintrp.c index 8f2d0130e82..7fe74feafd0 100644 --- a/src/java.desktop/share/native/liblcms/cmsintrp.c +++ b/src/java.desktop/share/native/liblcms/cmsintrp.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -229,8 +229,8 @@ void LinLerp1D(CMSREGISTER const cmsUInt16Number Value[], int val3; const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table; - // if last value... - if (Value[0] == 0xffff) { + // if last value or just one point + if (Value[0] == 0xffff || p->Domain[0] == 0) { Output[0] = LutTable[p -> Domain[0]]; } @@ -269,7 +269,7 @@ void LinLerp1Dfloat(const cmsFloat32Number Value[], val2 = fclamp(Value[0]); // if last value... - if (val2 == 1.0) { + if (val2 == 1.0 || p->Domain[0] == 0) { Output[0] = LutTable[p -> Domain[0]]; } else @@ -303,20 +303,34 @@ void Eval1Input(CMSREGISTER const cmsUInt16Number Input[], cmsUInt32Number OutChan; const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table; - v = Input[0] * p16 -> Domain[0]; - fk = _cmsToFixedDomain(v); - k0 = FIXED_TO_INT(fk); - rk = (cmsUInt16Number) FIXED_REST_TO_INT(fk); + // if last value... + if (Input[0] == 0xffff || p16->Domain[0] == 0) { + + cmsUInt32Number y0 = p16->Domain[0] * p16->opta[0]; + + for (OutChan = 0; OutChan < p16->nOutputs; OutChan++) { + Output[OutChan] = LutTable[y0 + OutChan]; + } + } + else + { + + v = Input[0] * p16->Domain[0]; + fk = _cmsToFixedDomain(v); + + k0 = FIXED_TO_INT(fk); + rk = (cmsUInt16Number)FIXED_REST_TO_INT(fk); - k1 = k0 + (Input[0] != 0xFFFFU ? 1 : 0); + k1 = k0 + (Input[0] != 0xFFFFU ? 1 : 0); - K0 = p16 -> opta[0] * k0; - K1 = p16 -> opta[0] * k1; + K0 = p16->opta[0] * k0; + K1 = p16->opta[0] * k1; - for (OutChan=0; OutChan < p16->nOutputs; OutChan++) { + for (OutChan = 0; OutChan < p16->nOutputs; OutChan++) { - Output[OutChan] = LinearInterp(rk, LutTable[K0+OutChan], LutTable[K1+OutChan]); + Output[OutChan] = LinearInterp(rk, LutTable[K0 + OutChan], LutTable[K1 + OutChan]); + } } } @@ -337,12 +351,12 @@ void Eval1InputFloat(const cmsFloat32Number Value[], val2 = fclamp(Value[0]); // if last value... - if (val2 == 1.0) { + if (val2 == 1.0 || p->Domain[0] == 0) { - y0 = LutTable[p->Domain[0]]; + cmsUInt32Number start = p->Domain[0] * p->opta[0]; for (OutChan = 0; OutChan < p->nOutputs; OutChan++) { - Output[OutChan] = y0; + Output[OutChan] = LutTable[start + OutChan]; } } else diff --git a/src/java.desktop/share/native/liblcms/cmsio0.c b/src/java.desktop/share/native/liblcms/cmsio0.c index 70be6a6ad14..75785355901 100644 --- a/src/java.desktop/share/native/liblcms/cmsio0.c +++ b/src/java.desktop/share/native/liblcms/cmsio0.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -404,6 +404,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha cmsIOHANDLER* iohandler = NULL; FILE* fm = NULL; cmsInt32Number fileLen; + char mode[4] = { 0,0,0,0 }; _cmsAssert(FileName != NULL); _cmsAssert(AccessMode != NULL); @@ -411,16 +412,49 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER)); if (iohandler == NULL) return NULL; - switch (*AccessMode) { + // Validate access mode + while (*AccessMode) { + + switch (*AccessMode) + { + case 'r': + case 'w': + + if (mode[0] == 0) { + mode[0] = *AccessMode; + mode[1] = 'b'; + } + else { + _cmsFree(ContextID, iohandler); + cmsSignalError(ContextID, cmsERROR_FILE, "Access mode already specified '%c'", *AccessMode); + return NULL; + } + break; + + // Close on exec. Not all runtime supports that. Up to the caller to decide. + case 'e': + mode[2] = 'e'; + break; + + default: + _cmsFree(ContextID, iohandler); + cmsSignalError(ContextID, cmsERROR_FILE, "Wrong access mode '%c'", *AccessMode); + return NULL; + } + + AccessMode++; + } + + switch (mode[0]) { case 'r': - fm = fopen(FileName, "rb"); + fm = fopen(FileName, mode); if (fm == NULL) { _cmsFree(ContextID, iohandler); cmsSignalError(ContextID, cmsERROR_FILE, "File '%s' not found", FileName); return NULL; } - fileLen = cmsfilelength(fm); + fileLen = (cmsInt32Number)cmsfilelength(fm); if (fileLen < 0) { fclose(fm); @@ -428,12 +462,11 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of file '%s'", FileName); return NULL; } - iohandler -> ReportedSize = (cmsUInt32Number) fileLen; break; case 'w': - fm = fopen(FileName, "wb"); + fm = fopen(FileName, mode); if (fm == NULL) { _cmsFree(ContextID, iohandler); cmsSignalError(ContextID, cmsERROR_FILE, "Couldn't create '%s'", FileName); @@ -443,8 +476,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha break; default: - _cmsFree(ContextID, iohandler); - cmsSignalError(ContextID, cmsERROR_FILE, "Unknown access mode '%c'", *AccessMode); + _cmsFree(ContextID, iohandler); // Would never reach return NULL; } @@ -471,7 +503,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* S cmsIOHANDLER* iohandler = NULL; cmsInt32Number fileSize; - fileSize = cmsfilelength(Stream); + fileSize = (cmsInt32Number)cmsfilelength(Stream); if (fileSize < 0) { cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of stream"); @@ -508,16 +540,15 @@ cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io) cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile) { - _cmsICCPROFILE* Icc = (_cmsICCPROFILE*)hProfile; + _cmsICCPROFILE* Icc = (_cmsICCPROFILE*)hProfile; - if (Icc == NULL) return NULL; - return Icc->IOhandler; + if (Icc == NULL) return NULL; + return Icc->IOhandler; } // Creates an empty structure holding all required parameters cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID) { - time_t now = time(NULL); _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) _cmsMallocZero(ContextID, sizeof(_cmsICCPROFILE)); if (Icc == NULL) return NULL; @@ -529,14 +560,22 @@ cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID) // Set default version Icc ->Version = 0x02100000; + // Set default device class + Icc->DeviceClass = cmsSigDisplayClass; + // Set creation date/time - memmove(&Icc ->Created, gmtime(&now), sizeof(Icc ->Created)); + if (!_cmsGetTime(&Icc->Created)) + goto Error; // Create a mutex if the user provided proper plugin. NULL otherwise Icc ->UsrMutex = _cmsCreateMutex(ContextID); // Return the handle return (cmsHPROFILE) Icc; + +Error: + _cmsFree(ContextID, Icc); + return NULL; } cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile) @@ -682,6 +721,27 @@ cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig) return _cmsSearchTag(Icc, sig, FALSE) >= 0; } + + +// Checks for link compatibility +static +cmsBool CompatibleTypes(const cmsTagDescriptor* desc1, const cmsTagDescriptor* desc2) +{ + cmsUInt32Number i; + + if (desc1 == NULL || desc2 == NULL) return FALSE; + + if (desc1->nSupportedTypes != desc2->nSupportedTypes) return FALSE; + if (desc1->ElemCount != desc2->ElemCount) return FALSE; + + for (i = 0; i < desc1->nSupportedTypes; i++) + { + if (desc1->SupportedTypes[i] != desc2->SupportedTypes[i]) return FALSE; + } + + return TRUE; +} + // Enforces that the profile version is per. spec. // Operates on the big endian bytes from the profile. // Called before converting to platform endianness. @@ -707,6 +767,29 @@ cmsUInt32Number _validatedVersion(cmsUInt32Number DWord) return DWord; } +// Check device class +static +cmsBool validDeviceClass(cmsProfileClassSignature cl) +{ + if ((int)cl == 0) return TRUE; // We allow zero because older lcms versions defaulted to that. + + switch (cl) + { + case cmsSigInputClass: + case cmsSigDisplayClass: + case cmsSigOutputClass: + case cmsSigLinkClass: + case cmsSigAbstractClass: + case cmsSigColorSpaceClass: + case cmsSigNamedColorClass: + return TRUE; + + default: + return FALSE; + } + +} + // Read profile header and validate it cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc) { @@ -743,6 +826,16 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc) _cmsAdjustEndianess64(&Icc -> attributes, &Header.attributes); Icc -> Version = _cmsAdjustEndianess32(_validatedVersion(Header.version)); + if (Icc->Version > 0x5000000) { + cmsSignalError(Icc->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported profile version '0x%x'", Icc->Version); + return FALSE; + } + + if (!validDeviceClass(Icc->DeviceClass)) { + cmsSignalError(Icc->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported device class '0x%x'", Icc->DeviceClass); + return FALSE; + } + // Get size as reported in header HeaderSize = _cmsAdjustEndianess32(Header.size); @@ -776,6 +869,7 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc) if (!_cmsReadUInt32Number(io, &Tag.size)) return FALSE; // Perform some sanity check. Offset + size should fall inside file. + if (Tag.size == 0 || Tag.offset == 0) continue; if (Tag.offset + Tag.size > HeaderSize || Tag.offset + Tag.size < Tag.offset) continue; @@ -790,7 +884,12 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc) if ((Icc ->TagOffsets[j] == Tag.offset) && (Icc ->TagSizes[j] == Tag.size)) { - Icc ->TagLinked[Icc ->TagCount] = Icc ->TagNames[j]; + // Check types. + if (CompatibleTypes(_cmsGetTagDescriptor(Icc->ContextID, Icc->TagNames[j]), + _cmsGetTagDescriptor(Icc->ContextID, Tag.sig))) { + + Icc->TagLinked[Icc->TagCount] = Icc->TagNames[j]; + } } } @@ -798,6 +897,19 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc) Icc ->TagCount++; } + + for (i = 0; i < Icc->TagCount; i++) { + for (j = 0; j < Icc->TagCount; j++) { + + // Tags cannot be duplicate + if ((i != j) && (Icc->TagNames[i] == Icc->TagNames[j])) { + cmsSignalError(Icc->ContextID, cmsERROR_RANGE, "Duplicate tag found"); + return FALSE; + } + + } + } + return TRUE; } @@ -1459,7 +1571,25 @@ cmsBool CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUIn return rc; } +// Free one tag contents +static +void freeOneTag(_cmsICCPROFILE* Icc, cmsUInt32Number i) +{ + if (Icc->TagPtrs[i]) { + + cmsTagTypeHandler* TypeHandler = Icc->TagTypeHandlers[i]; + if (TypeHandler != NULL) { + cmsTagTypeHandler LocalTypeHandler = *TypeHandler; + + LocalTypeHandler.ContextID = Icc->ContextID; + LocalTypeHandler.ICCVersion = Icc->Version; + LocalTypeHandler.FreePtr(&LocalTypeHandler, Icc->TagPtrs[i]); + } + else + _cmsFree(Icc->ContextID, Icc->TagPtrs[i]); + } +} // Closes a profile freeing any involved resources cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile) @@ -1479,20 +1609,7 @@ cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile) for (i=0; i < Icc -> TagCount; i++) { - if (Icc -> TagPtrs[i]) { - - cmsTagTypeHandler* TypeHandler = Icc ->TagTypeHandlers[i]; - - if (TypeHandler != NULL) { - cmsTagTypeHandler LocalTypeHandler = *TypeHandler; - - LocalTypeHandler.ContextID = Icc ->ContextID; // As an additional parameters - LocalTypeHandler.ICCVersion = Icc ->Version; - LocalTypeHandler.FreePtr(&LocalTypeHandler, Icc -> TagPtrs[i]); - } - else - _cmsFree(Icc ->ContextID, Icc ->TagPtrs[i]); - } + freeOneTag(Icc, i); } if (Icc ->IOhandler != NULL) { @@ -1544,8 +1661,12 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig) if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return NULL; n = _cmsSearchTag(Icc, sig, TRUE); - if (n < 0) goto Error; // Not found, return NULL - + if (n < 0) + { + // Not found, return NULL + _cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex); + return NULL; + } // If the element is already in memory, return the pointer if (Icc -> TagPtrs[n]) { @@ -1573,6 +1694,12 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig) if (TagSize < 8) goto Error; + if (io == NULL) { // This is a built-in profile that has been manipulated, abort early + + cmsSignalError(Icc->ContextID, cmsERROR_CORRUPTION_DETECTED, "Corrupted built-in profile."); + goto Error; + } + // Seek to its location if (!io -> Seek(io, Offset)) goto Error; @@ -1640,8 +1767,12 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig) return Icc -> TagPtrs[n]; - // Return error and unlock tha data + // Return error and unlock the data Error: + + freeOneTag(Icc, n); + Icc->TagPtrs[n] = NULL; + _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex); return NULL; } @@ -1780,11 +1911,9 @@ cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const v } -// Read and write raw data. The only way those function would work and keep consistence with normal read and write -// is to do an additional step of serialization. That means, readRaw would issue a normal read and then convert the obtained -// data to raw bytes by using the "write" serialization logic. And vice-versa. I know this may end in situations where -// raw data written does not exactly correspond with the raw data proposed to cmsWriteRaw data, but this approach allows -// to write a tag as raw data and the read it as handled. +// Read and write raw data. Read/Write Raw/cooked pairs try to maintain consistency within the pair. Some sequences +// raw/cooked would work, but at a cost. Data "cooked" may be converted to "raw" by using the "write" serialization logic. +// In general it is better to avoid mixing pairs. cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* data, cmsUInt32Number BufferSize) { @@ -1798,24 +1927,29 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si cmsUInt32Number rc; cmsUInt32Number Offset, TagSize; + // Sanity check + if (data != NULL && BufferSize == 0) return 0; + if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0; // Search for given tag in ICC profile directory + i = _cmsSearchTag(Icc, sig, TRUE); if (i < 0) goto Error; // Not found, // It is already read? if (Icc -> TagPtrs[i] == NULL) { - // No yet, get original position + // Not yet, get original position Offset = Icc ->TagOffsets[i]; TagSize = Icc ->TagSizes[i]; // read the data directly, don't keep copy + if (data != NULL) { if (BufferSize < TagSize) - TagSize = BufferSize; + goto Error; if (!Icc ->IOhandler ->Seek(Icc ->IOhandler, Offset)) goto Error; if (!Icc ->IOhandler ->Read(Icc ->IOhandler, data, 1, TagSize)) goto Error; @@ -1830,13 +1964,14 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si // The data has been already read, or written. But wait!, maybe the user chose to save as // raw data. In this case, return the raw data directly + if (Icc ->TagSaveAsRaw[i]) { if (data != NULL) { TagSize = Icc ->TagSizes[i]; if (BufferSize < TagSize) - TagSize = BufferSize; + goto Error; memmove(data, Icc ->TagPtrs[i], TagSize); @@ -1849,7 +1984,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si } // Already read, or previously set by cmsWriteTag(). We need to serialize that - // data to raw in order to maintain consistency. + // data to raw to get something that makes sense _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex); Object = cmsReadTag(hProfile, sig); diff --git a/src/java.desktop/share/native/liblcms/cmsio1.c b/src/java.desktop/share/native/liblcms/cmsio1.c index 23f32108a81..85d9f6788b5 100644 --- a/src/java.desktop/share/native/liblcms/cmsio1.c +++ b/src/java.desktop/share/native/liblcms/cmsio1.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -289,7 +289,7 @@ cmsPipeline* BuildRGBInputMatrixShaper(cmsHPROFILE hProfile) -// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded +// Read the DToAX tag, adjusting the encoding of Lab or XYZ if needed static cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) { @@ -351,10 +351,8 @@ cmsPipeline* CMSEXPORT _cmsReadInputLUT(cmsHPROFILE hProfile, cmsUInt32Number In if (nc == NULL) return NULL; Lut = cmsPipelineAlloc(ContextID, 0, 0); - if (Lut == NULL) { - cmsFreeNamedColorList(nc); + if (Lut == NULL) return NULL; - } if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, TRUE)) || !cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID))) { @@ -565,7 +563,7 @@ void ChangeInterpolationToTrilinear(cmsPipeline* Lut) } -// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded +// Read the DToAX tag, adjusting the encoding of Lab or XYZ if needed static cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) { @@ -690,7 +688,7 @@ cmsPipeline* CMSEXPORT _cmsReadOutputLUT(cmsHPROFILE hProfile, cmsUInt32Number I // --------------------------------------------------------------------------------------------------------------- -// Read the AToD0 tag, adjusting the encoding of Lab or XYZ if neded +// Read the AToD0 tag, adjusting the encoding of Lab or XYZ if needed static cmsPipeline* _cmsReadFloatDevicelinkTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) { @@ -769,7 +767,6 @@ cmsPipeline* CMSEXPORT _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, cmsUInt32Numb return Lut; Error: cmsPipelineFree(Lut); - cmsFreeNamedColorList(nc); return NULL; } diff --git a/src/java.desktop/share/native/liblcms/cmslut.c b/src/java.desktop/share/native/liblcms/cmslut.c index 6eb803fe558..457ab6ecf5c 100644 --- a/src/java.desktop/share/native/liblcms/cmslut.c +++ b/src/java.desktop/share/native/liblcms/cmslut.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -496,7 +496,7 @@ cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b) for (rv = 1; b > 0; b--) { dim = Dims[b-1]; - if (dim == 0) return 0; // Error + if (dim <= 1) return 0; // Error rv *= dim; @@ -1255,6 +1255,11 @@ void* CMSEXPORT cmsStageData(const cmsStage* mpe) return mpe -> Data; } +cmsContext CMSEXPORT cmsGetStageContextID(const cmsStage* mpe) +{ + return mpe -> ContextID; +} + cmsStage* CMSEXPORT cmsStageNext(const cmsStage* mpe) { return mpe -> Next; diff --git a/src/java.desktop/share/native/liblcms/cmsmd5.c b/src/java.desktop/share/native/liblcms/cmsmd5.c index 2c37b34ea15..ea97c0d8774 100644 --- a/src/java.desktop/share/native/liblcms/cmsmd5.c +++ b/src/java.desktop/share/native/liblcms/cmsmd5.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), diff --git a/src/java.desktop/share/native/liblcms/cmsmtrx.c b/src/java.desktop/share/native/liblcms/cmsmtrx.c index 6bf18e0b798..9bbe82871f5 100644 --- a/src/java.desktop/share/native/liblcms/cmsmtrx.c +++ b/src/java.desktop/share/native/liblcms/cmsmtrx.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), diff --git a/src/java.desktop/share/native/liblcms/cmsnamed.c b/src/java.desktop/share/native/liblcms/cmsnamed.c index 95a3b5ef8e1..c710ba39372 100644 --- a/src/java.desktop/share/native/liblcms/cmsnamed.c +++ b/src/java.desktop/share/native/liblcms/cmsnamed.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -233,7 +233,7 @@ void strFrom16(char str[3], cmsUInt16Number n) } // Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61) -// In the case the user explicitely sets an empty string, we force a \0 +// 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); @@ -571,8 +571,12 @@ cmsBool GrowNamedColorList(cmsNAMEDCOLORLIST* v) // Allocate a list for n elements cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUInt32Number n, cmsUInt32Number ColorantCount, const char* Prefix, const char* Suffix) { - cmsNAMEDCOLORLIST* v = (cmsNAMEDCOLORLIST*) _cmsMallocZero(ContextID, sizeof(cmsNAMEDCOLORLIST)); + cmsNAMEDCOLORLIST* v; + if (ColorantCount > cmsMAXCHANNELS) + return NULL; + + v = (cmsNAMEDCOLORLIST*)_cmsMallocZero(ContextID, sizeof(cmsNAMEDCOLORLIST)); if (v == NULL) return NULL; v ->List = NULL; @@ -670,7 +674,7 @@ cmsUInt32Number CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* NamedColor return NamedColorList ->nColors; } -// Info aboout a given color +// Info about a given color cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor, char* Name, char* Prefix, diff --git a/src/java.desktop/share/native/liblcms/cmsopt.c b/src/java.desktop/share/native/liblcms/cmsopt.c index e83b2e0be6d..e32f73b86ee 100644 --- a/src/java.desktop/share/native/liblcms/cmsopt.c +++ b/src/java.desktop/share/native/liblcms/cmsopt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -676,7 +676,6 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3 { cmsPipeline* Src = NULL; cmsPipeline* Dest = NULL; - cmsStage* mpe; cmsStage* CLUT; cmsStage *KeepPreLin = NULL, *KeepPostLin = NULL; cmsUInt32Number nGridPoints; @@ -698,7 +697,7 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3 if (ColorSpace == (cmsColorSpaceSignature)0 || OutputColorSpace == (cmsColorSpaceSignature)0) return FALSE; - nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags); + nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags); // For empty LUTs, 2 points are enough if (cmsPipelineStageCount(*Lut) == 0) @@ -706,13 +705,6 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3 Src = *Lut; - // Named color pipelines cannot be optimized either - for (mpe = cmsPipelineGetPtrToFirstStage(Src); - mpe != NULL; - mpe = cmsStageNext(mpe)) { - if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE; - } - // Allocate an empty LUT Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels); if (!Dest) return FALSE; @@ -1080,7 +1072,6 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte cmsStage* OptimizedCLUTmpe; cmsColorSpaceSignature ColorSpace, OutputColorSpace; cmsStage* OptimizedPrelinMpe; - cmsStage* mpe; cmsToneCurve** OptimizedPrelinCurves; _cmsStageCLutData* OptimizedPrelinCLUT; @@ -1102,13 +1093,6 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte OriginalLut = *Lut; - // Named color pipelines cannot be optimized either - for (mpe = cmsPipelineGetPtrToFirstStage(OriginalLut); - mpe != NULL; - mpe = cmsStageNext(mpe)) { - if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE; - } - ColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*InputFormat)); OutputColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*OutputFormat)); @@ -1562,10 +1546,10 @@ void* DupMatShaper(cmsContext ContextID, const void* Data) } -// A fast matrix-shaper evaluator for 8 bits. This is a bit ticky since I'm using 1.14 signed fixed point +// A fast matrix-shaper evaluator for 8 bits. This is a bit tricky since I'm using 1.14 signed fixed point // to accomplish some performance. Actually it takes 256x3 16 bits tables and 16385 x 3 tables of 8 bits, // in total about 50K, and the performance boost is huge! -static +static CMS_NO_SANITIZE void MatShaperEval16(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER const void* D) @@ -1947,6 +1931,7 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID, _cmsOptimizationPluginChunkType* ctx = ( _cmsOptimizationPluginChunkType*) _cmsContextGetClientChunk(ContextID, OptimizationPlugin); _cmsOptimizationCollection* Opts; cmsBool AnySuccess = FALSE; + cmsStage* mpe; // A CLUT is being asked, so force this specific optimization if (*dwFlags & cmsFLAGS_FORCE_CLUT) { @@ -1961,6 +1946,13 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID, return TRUE; } + // Named color pipelines cannot be optimized + for (mpe = cmsPipelineGetPtrToFirstStage(*PtrLut); + mpe != NULL; + mpe = cmsStageNext(mpe)) { + if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE; + } + // Try to get rid of identities and trivial conversions. AnySuccess = PreOptimize(*PtrLut); diff --git a/src/java.desktop/share/native/liblcms/cmspack.c b/src/java.desktop/share/native/liblcms/cmspack.c index 0ec3edab5d5..e90e45656fc 100644 --- a/src/java.desktop/share/native/liblcms/cmspack.c +++ b/src/java.desktop/share/native/liblcms/cmspack.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -108,6 +108,7 @@ typedef struct { #define ANYSWAP DOSWAP_SH(1) #define ANYSWAPFIRST SWAPFIRST_SH(1) #define ANYFLAVOR FLAVOR_SH(1) +#define ANYPREMUL PREMUL_SH(1) // Suppress waning about info never being used @@ -131,20 +132,40 @@ cmsUInt8Number* UnrollChunkyBytes(CMSREGISTER _cmsTRANSFORM* info, cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat); cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat); cmsUInt32Number Extra = T_EXTRA(info -> InputFormat); + cmsUInt32Number Premul = T_PREMUL(info->InputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; - cmsUInt16Number v; + cmsUInt32Number v; cmsUInt32Number i; + cmsUInt32Number alpha_factor = 1; if (ExtraFirst) { + + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0])); + accum += Extra; } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[nChan])); + } for (i=0; i < nChan; i++) { + cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; v = FROM_8_TO_16(*accum); v = Reverse ? REVERSE_FLAVOR_16(v) : v; - wIn[index] = v; + + if (Premul && alpha_factor > 0) + { + v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor); + if (v > 0xffff) v = 0xffff; + } + + wIn[index] = (cmsUInt16Number) v; accum++; } @@ -166,6 +187,7 @@ cmsUInt8Number* UnrollChunkyBytes(CMSREGISTER _cmsTRANSFORM* info, } + // Extra channels are just ignored because come in the next planes static cmsUInt8Number* UnrollPlanarBytes(CMSREGISTER _cmsTRANSFORM* info, @@ -178,24 +200,47 @@ cmsUInt8Number* UnrollPlanarBytes(CMSREGISTER _cmsTRANSFORM* info, cmsUInt32Number SwapFirst = T_SWAPFIRST(info ->InputFormat); cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat); cmsUInt32Number i; + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number Extra = T_EXTRA(info->InputFormat); + cmsUInt32Number Premul = T_PREMUL(info->InputFormat); cmsUInt8Number* Init = accum; + cmsUInt32Number alpha_factor = 1; - if (DoSwap ^ SwapFirst) { - accum += T_EXTRA(info -> InputFormat) * Stride; + if (ExtraFirst) { + + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0])); + + + accum += Extra * Stride; + } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[(nChan) * Stride])); } for (i=0; i < nChan; i++) { cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; - cmsUInt16Number v = FROM_8_TO_16(*accum); + cmsUInt32Number v = FROM_8_TO_16(*accum); - wIn[index] = Reverse ? REVERSE_FLAVOR_16(v) : v; + v = Reverse ? REVERSE_FLAVOR_16(v) : v; + + if (Premul && alpha_factor > 0) + { + v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor); + if (v > 0xffff) v = 0xffff; + } + + wIn[index] = (cmsUInt16Number) v; accum += Stride; } return (Init + 1); } + // Special cases, provided for performance static cmsUInt8Number* Unroll4Bytes(CMSREGISTER _cmsTRANSFORM* info, @@ -546,6 +591,58 @@ cmsUInt8Number* UnrollAnyWords(CMSREGISTER _cmsTRANSFORM* info, cmsUNUSED_PARAMETER(Stride); } + +static +cmsUInt8Number* UnrollAnyWordsPremul(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wIn[], + CMSREGISTER cmsUInt8Number* accum, + CMSREGISTER cmsUInt32Number Stride) +{ + cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat); + cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number i; + + cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[nChan - 1]); + cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha)); + + if (ExtraFirst) { + accum += sizeof(cmsUInt16Number); + } + + for (i=0; i < nChan; i++) { + + cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; + cmsUInt32Number v = *(cmsUInt16Number*) accum; + + if (SwapEndian) + v = CHANGE_ENDIAN(v); + + if (alpha_factor > 0) { + + v = (v << 16) / alpha_factor; + if (v > 0xffff) v = 0xffff; + } + + wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v); + + accum += sizeof(cmsUInt16Number); + } + + if (!ExtraFirst) { + accum += sizeof(cmsUInt16Number); + } + + return accum; + + cmsUNUSED_PARAMETER(Stride); +} + + + static cmsUInt8Number* UnrollPlanarWords(CMSREGISTER _cmsTRANSFORM* info, CMSREGISTER cmsUInt16Number wIn[], @@ -579,6 +676,49 @@ cmsUInt8Number* UnrollPlanarWords(CMSREGISTER _cmsTRANSFORM* info, return (Init + sizeof(cmsUInt16Number)); } +static +cmsUInt8Number* UnrollPlanarWordsPremul(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wIn[], + CMSREGISTER cmsUInt8Number* accum, + CMSREGISTER cmsUInt32Number Stride) +{ + cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat); + cmsUInt32Number DoSwap= T_DOSWAP(info ->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat); + cmsUInt32Number Reverse= T_FLAVOR(info ->InputFormat); + cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat); + cmsUInt32Number i; + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt8Number* Init = accum; + + cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[(nChan - 1) * Stride]); + cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha)); + + if (ExtraFirst) { + accum += Stride; + } + + for (i=0; i < nChan; i++) { + + cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; + cmsUInt32Number v = (cmsUInt32Number) *(cmsUInt16Number*) accum; + + if (SwapEndian) + v = CHANGE_ENDIAN(v); + + if (alpha_factor > 0) { + + v = (v << 16) / alpha_factor; + if (v > 0xffff) v = 0xffff; + } + + wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v); + + accum += Stride; + } + + return (Init + sizeof(cmsUInt16Number)); +} static cmsUInt8Number* Unroll4Words(CMSREGISTER _cmsTRANSFORM* info, @@ -1116,6 +1256,110 @@ cmsUInt8Number* UnrollDouble1Chan(CMSREGISTER _cmsTRANSFORM* info, //------------------------------------------------------------------------------------------------------------------- +// For anything going from cmsUInt8Number +static +cmsUInt8Number* Unroll8ToFloat(_cmsTRANSFORM* info, + cmsFloat32Number wIn[], + cmsUInt8Number* accum, + cmsUInt32Number Stride) +{ + + cmsUInt32Number nChan = T_CHANNELS(info->InputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat); + cmsUInt32Number Extra = T_EXTRA(info->InputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number Planar = T_PLANAR(info->InputFormat); + cmsFloat32Number v; + cmsUInt32Number i, start = 0; + + Stride /= PixelSize(info->InputFormat); + + if (ExtraFirst) + start = Extra; + + for (i = 0; i < nChan; i++) { + + cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; + + if (Planar) + v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[(i + start) * Stride]; + else + v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[i + start]; + + v /= 255.0F; + + wIn[index] = Reverse ? 1 - v : v; + } + + + if (Extra == 0 && SwapFirst) { + cmsFloat32Number tmp = wIn[0]; + + memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number)); + wIn[nChan - 1] = tmp; + } + + if (T_PLANAR(info->InputFormat)) + return accum + sizeof(cmsUInt8Number); + else + return accum + (nChan + Extra) * sizeof(cmsUInt8Number); +} + + +// For anything going from cmsUInt16Number +static +cmsUInt8Number* Unroll16ToFloat(_cmsTRANSFORM* info, + cmsFloat32Number wIn[], + cmsUInt8Number* accum, + cmsUInt32Number Stride) +{ + + cmsUInt32Number nChan = T_CHANNELS(info->InputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat); + cmsUInt32Number Extra = T_EXTRA(info->InputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number Planar = T_PLANAR(info->InputFormat); + cmsFloat32Number v; + cmsUInt32Number i, start = 0; + + Stride /= PixelSize(info->InputFormat); + + if (ExtraFirst) + start = Extra; + + for (i = 0; i < nChan; i++) { + + cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; + + if (Planar) + v = (cmsFloat32Number)((cmsUInt16Number*)accum)[(i + start) * Stride]; + else + v = (cmsFloat32Number)((cmsUInt16Number*)accum)[i + start]; + + v /= 65535.0F; + + wIn[index] = Reverse ? 1 - v : v; + } + + + if (Extra == 0 && SwapFirst) { + cmsFloat32Number tmp = wIn[0]; + + memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number)); + wIn[nChan - 1] = tmp; + } + + if (T_PLANAR(info->InputFormat)) + return accum + sizeof(cmsUInt16Number); + else + return accum + (nChan + Extra) * sizeof(cmsUInt16Number); +} + + // For anything going from cmsFloat32Number static cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info, @@ -1124,19 +1368,30 @@ cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info, cmsUInt32Number Stride) { - cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat); - cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat); - cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat); - cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat); - cmsUInt32Number Extra = T_EXTRA(info -> InputFormat); + cmsUInt32Number nChan = T_CHANNELS(info->InputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat); + cmsUInt32Number Extra = T_EXTRA(info->InputFormat); cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; - cmsUInt32Number Planar = T_PLANAR(info -> InputFormat); + cmsUInt32Number Planar = T_PLANAR(info->InputFormat); + cmsUInt32Number Premul = T_PREMUL(info->InputFormat); cmsFloat32Number v; cmsUInt32Number i, start = 0; - cmsFloat32Number maximum = IsInkSpace(info ->InputFormat) ? 100.0F : 1.0F; + cmsFloat32Number maximum = IsInkSpace(info->InputFormat) ? 100.0F : 1.0F; + cmsFloat32Number alpha_factor = 1.0f; + cmsFloat32Number* ptr = (cmsFloat32Number*)accum; Stride /= PixelSize(info->InputFormat); + if (Premul && Extra) + { + if (Planar) + alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan * Stride]) / maximum; + else + alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum; + } + if (ExtraFirst) start = Extra; @@ -1145,9 +1400,12 @@ cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info, cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; if (Planar) - v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[(i + start) * Stride]; + v = ptr[(i + start) * Stride]; else - v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[i + start]; + v = ptr[i + start]; + + if (Premul && alpha_factor > 0) + v /= alpha_factor; v /= maximum; @@ -1177,19 +1435,30 @@ cmsUInt8Number* UnrollDoublesToFloat(_cmsTRANSFORM* info, cmsUInt32Number Stride) { - cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat); - cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat); - cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat); - cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat); - cmsUInt32Number Extra = T_EXTRA(info -> InputFormat); + cmsUInt32Number nChan = T_CHANNELS(info->InputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat); + cmsUInt32Number Extra = T_EXTRA(info->InputFormat); cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; - cmsUInt32Number Planar = T_PLANAR(info -> InputFormat); + cmsUInt32Number Planar = T_PLANAR(info->InputFormat); + cmsUInt32Number Premul = T_PREMUL(info->InputFormat); cmsFloat64Number v; cmsUInt32Number i, start = 0; cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 100.0 : 1.0; + cmsFloat64Number alpha_factor = 1.0; + cmsFloat64Number* ptr = (cmsFloat64Number*)accum; Stride /= PixelSize(info->InputFormat); + if (Premul && Extra) + { + if (Planar) + alpha_factor = (ExtraFirst ? ptr[0] : ptr[(nChan) * Stride]) / maximum; + else + alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum; + } + if (ExtraFirst) start = Extra; @@ -1202,6 +1471,10 @@ cmsUInt8Number* UnrollDoublesToFloat(_cmsTRANSFORM* info, else v = (cmsFloat64Number) ((cmsFloat64Number*) accum)[i + start]; + + if (Premul && alpha_factor > 0) + v /= alpha_factor; + v /= maximum; wIn[index] = (cmsFloat32Number) (Reverse ? 1.0 - v : v); @@ -1283,8 +1556,6 @@ cmsUInt8Number* UnrollLabFloatToFloat(_cmsTRANSFORM* info, } } - - // 1.15 fixed point, that means maximum value is MAX_ENCODEABLE_XYZ (0xFFFF) static cmsUInt8Number* UnrollXYZDoubleToFloat(_cmsTRANSFORM* info, @@ -1345,44 +1616,132 @@ cmsUInt8Number* UnrollXYZFloatToFloat(_cmsTRANSFORM* info, } +cmsINLINE void lab4toFloat(cmsFloat32Number wIn[], cmsUInt16Number lab4[3]) +{ + cmsFloat32Number L = (cmsFloat32Number) lab4[0] / 655.35F; + cmsFloat32Number a = ((cmsFloat32Number) lab4[1] / 257.0F) - 128.0F; + cmsFloat32Number b = ((cmsFloat32Number) lab4[2] / 257.0F) - 128.0F; + + wIn[0] = (L / 100.0F); // from 0..100 to 0..1 + wIn[1] = ((a + 128.0F) / 255.0F); // form -128..+127 to 0..1 + wIn[2] = ((b + 128.0F) / 255.0F); + +} + +static +cmsUInt8Number* UnrollLabV2_8ToFloat(_cmsTRANSFORM* info, + cmsFloat32Number wIn[], + cmsUInt8Number* accum, + cmsUInt32Number Stride) +{ + cmsUInt16Number lab4[3]; + + lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L + lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a + lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b + + lab4toFloat(wIn, lab4); + + return accum; + + cmsUNUSED_PARAMETER(info); + cmsUNUSED_PARAMETER(Stride); +} + +static +cmsUInt8Number* UnrollALabV2_8ToFloat(_cmsTRANSFORM* info, + cmsFloat32Number wIn[], + cmsUInt8Number* accum, + cmsUInt32Number Stride) +{ + cmsUInt16Number lab4[3]; + + accum++; // A + lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L + lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a + lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b + + lab4toFloat(wIn, lab4); + + return accum; + + cmsUNUSED_PARAMETER(info); + cmsUNUSED_PARAMETER(Stride); +} + +static +cmsUInt8Number* UnrollLabV2_16ToFloat(_cmsTRANSFORM* info, + cmsFloat32Number wIn[], + cmsUInt8Number* accum, + cmsUInt32Number Stride) +{ + cmsUInt16Number lab4[3]; + + lab4[0] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // L + lab4[1] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // a + lab4[2] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // b + + lab4toFloat(wIn, lab4); + + return accum; + + cmsUNUSED_PARAMETER(info); + cmsUNUSED_PARAMETER(Stride); +} + // Packing routines ----------------------------------------------------------------------------------------------------------- // Generic chunky for byte - static -cmsUInt8Number* PackAnyBytes(CMSREGISTER _cmsTRANSFORM* info, - CMSREGISTER cmsUInt16Number wOut[], - CMSREGISTER cmsUInt8Number* output, - CMSREGISTER cmsUInt32Number Stride) +cmsUInt8Number* PackChunkyBytes(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wOut[], + CMSREGISTER cmsUInt8Number* output, + CMSREGISTER 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 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 Premul = T_PREMUL(info->OutputFormat); cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; cmsUInt8Number* swap1; - cmsUInt8Number v = 0; + cmsUInt16Number v = 0; cmsUInt32Number i; + cmsUInt32Number alpha_factor = 0; swap1 = output; if (ExtraFirst) { + + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0])); + output += Extra; } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan])); + } for (i=0; i < nChan; i++) { cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; - v = FROM_16_TO_8(wOut[index]); + v = wOut[index]; if (Reverse) - v = REVERSE_FLAVOR_8(v); + v = REVERSE_FLAVOR_16(v); + + if (Premul && alpha_factor != 0) + { + v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); + } - *output++ = v; + *output++ = FROM_16_TO_8(v); } if (!ExtraFirst) { @@ -1392,39 +1751,47 @@ cmsUInt8Number* PackAnyBytes(CMSREGISTER _cmsTRANSFORM* info, if (Extra == 0 && SwapFirst) { memmove(swap1 + 1, swap1, nChan-1); - *swap1 = v; + *swap1 = FROM_16_TO_8(v); } - return output; cmsUNUSED_PARAMETER(Stride); } - - static -cmsUInt8Number* PackAnyWords(CMSREGISTER _cmsTRANSFORM* info, - CMSREGISTER cmsUInt16Number wOut[], - CMSREGISTER cmsUInt8Number* output, - CMSREGISTER cmsUInt32Number Stride) +cmsUInt8Number* PackChunkyWords(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wOut[], + CMSREGISTER cmsUInt8Number* output, + CMSREGISTER cmsUInt32Number Stride) { - cmsUInt32Number nChan = T_CHANNELS(info -> OutputFormat); - cmsUInt32Number SwapEndian = T_ENDIAN16(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 nChan = T_CHANNELS(info->OutputFormat); + cmsUInt32Number SwapEndian = T_ENDIAN16(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 Premul = T_PREMUL(info->OutputFormat); cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; cmsUInt16Number* swap1; cmsUInt16Number v = 0; cmsUInt32Number i; + cmsUInt32Number alpha_factor = 0; swap1 = (cmsUInt16Number*) output; if (ExtraFirst) { + + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(*(cmsUInt16Number*) output); + output += Extra * sizeof(cmsUInt16Number); } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[nChan]); + } for (i=0; i < nChan; i++) { @@ -1438,6 +1805,11 @@ cmsUInt8Number* PackAnyWords(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); + if (Premul && alpha_factor != 0) + { + v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); + } + *(cmsUInt16Number*) output = v; output += sizeof(cmsUInt16Number); @@ -1453,38 +1825,60 @@ cmsUInt8Number* PackAnyWords(CMSREGISTER _cmsTRANSFORM* info, *swap1 = v; } - return output; cmsUNUSED_PARAMETER(Stride); } + static cmsUInt8Number* PackPlanarBytes(CMSREGISTER _cmsTRANSFORM* info, CMSREGISTER cmsUInt16Number wOut[], CMSREGISTER cmsUInt8Number* output, CMSREGISTER cmsUInt32Number Stride) { - cmsUInt32Number nChan = T_CHANNELS(info -> OutputFormat); - cmsUInt32Number DoSwap = T_DOSWAP(info ->OutputFormat); - cmsUInt32Number SwapFirst = T_SWAPFIRST(info ->OutputFormat); - cmsUInt32Number Reverse = T_FLAVOR(info ->OutputFormat); + cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat); + cmsUInt32Number Extra = T_EXTRA(info->OutputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number Premul = T_PREMUL(info->OutputFormat); cmsUInt32Number i; cmsUInt8Number* Init = output; + cmsUInt32Number alpha_factor = 0; + + + if (ExtraFirst) { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0])); - if (DoSwap ^ SwapFirst) { - output += T_EXTRA(info -> OutputFormat) * Stride; + output += Extra * Stride; + } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan * Stride])); } for (i=0; i < nChan; i++) { cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i; - cmsUInt8Number v = FROM_16_TO_8(wOut[index]); + cmsUInt16Number v = wOut[index]; + + if (Reverse) + v = REVERSE_FLAVOR_16(v); + + if (Premul && alpha_factor != 0) + { + v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); + } + + *(cmsUInt8Number*)output = FROM_16_TO_8(v); - *(cmsUInt8Number*) output = (cmsUInt8Number) (Reverse ? REVERSE_FLAVOR_8(v) : v); output += Stride; } @@ -1500,16 +1894,30 @@ cmsUInt8Number* PackPlanarWords(CMSREGISTER _cmsTRANSFORM* info, CMSREGISTER cmsUInt8Number* output, CMSREGISTER cmsUInt32Number Stride) { - cmsUInt32Number nChan = T_CHANNELS(info -> OutputFormat); - cmsUInt32Number DoSwap = T_DOSWAP(info ->OutputFormat); - cmsUInt32Number Reverse = T_FLAVOR(info ->OutputFormat); - cmsUInt32Number SwapEndian = T_ENDIAN16(info -> OutputFormat); + cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat); + cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat); + cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat); + cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat); + cmsUInt32Number Extra = T_EXTRA(info->OutputFormat); + cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; + cmsUInt32Number Premul = T_PREMUL(info->OutputFormat); + cmsUInt32Number SwapEndian = T_ENDIAN16(info->OutputFormat); cmsUInt32Number i; cmsUInt8Number* Init = output; cmsUInt16Number v; + cmsUInt32Number alpha_factor = 0; - if (DoSwap) { - output += T_EXTRA(info -> OutputFormat) * Stride; + if (ExtraFirst) { + + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[0]); + + output += Extra * Stride; + } + else + { + if (Premul && Extra) + alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*)output)[nChan * Stride]); } for (i=0; i < nChan; i++) { @@ -1524,6 +1932,11 @@ cmsUInt8Number* PackPlanarWords(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); + if (Premul && alpha_factor != 0) + { + v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); + } + *(cmsUInt16Number*) output = v; output += Stride; } @@ -2670,10 +3083,6 @@ cmsUInt8Number* PackDoublesFromFloat(_cmsTRANSFORM* info, } - - - - static cmsUInt8Number* PackLabFloatFromFloat(_cmsTRANSFORM* Info, cmsFloat32Number wOut[], @@ -3058,10 +3467,10 @@ static const cmsFormatters16 InputFormatters16[] = { { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll4BytesSwap}, { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4BytesSwapSwapFirst}, - { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST| + { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYPREMUL| ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarBytes}, - { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP| + { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYPREMUL| ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollChunkyBytes}, { CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Unroll1Word}, @@ -3083,6 +3492,10 @@ static const cmsFormatters16 InputFormatters16[] = { { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarWords}, { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollAnyWords}, + + { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollPlanarWordsPremul}, + { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollAnyWordsPremul} + }; @@ -3098,13 +3511,23 @@ static const cmsFormattersFloat InputFormattersFloat[] = { { TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, UnrollXYZFloatToFloat}, { FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| - ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat}, + ANYPREMUL|ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat}, { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| - ANYCHANNELS|ANYSPACE, UnrollDoublesToFloat}, + ANYCHANNELS|ANYSPACE|ANYPREMUL, UnrollDoublesToFloat}, + + { TYPE_LabV2_8, 0, UnrollLabV2_8ToFloat }, + { TYPE_ALabV2_8, 0, UnrollALabV2_8ToFloat }, + { TYPE_LabV2_16, 0, UnrollLabV2_16ToFloat }, + + { BYTES_SH(1), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| + ANYCHANNELS|ANYSPACE, Unroll8ToFloat}, + + { BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| + ANYCHANNELS|ANYSPACE, Unroll16ToFloat}, #ifndef CMS_NO_HALF_SUPPORT { FLOAT_SH(1)|BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| - ANYCHANNELS|ANYSPACE, UnrollHalfToFloat}, + ANYCHANNELS|ANYSPACE, UnrollHalfToFloat}, #endif }; @@ -3198,16 +3621,20 @@ static const cmsFormatters16 OutputFormatters16[] = { ANYSPACE, Pack3BytesAndSkip1SwapSwapFirst}, { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|EXTRA_SH(1), ANYSPACE, Pack3BytesAndSkip1Swap}, { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack3BytesSwap}, - { CHANNELS_SH(6)|BYTES_SH(1), ANYSPACE, Pack6Bytes}, - { CHANNELS_SH(6)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack6BytesSwap}, { CHANNELS_SH(4)|BYTES_SH(1), ANYSPACE, Pack4Bytes}, { CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Pack4BytesReverse}, { CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapFirst}, { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack4BytesSwap}, { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapSwapFirst}, + { CHANNELS_SH(6)|BYTES_SH(1), ANYSPACE, Pack6Bytes}, + { CHANNELS_SH(6)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack6BytesSwap}, + + { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS| + ANYSPACE|ANYPREMUL, PackChunkyBytes}, + + { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA| + ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarBytes}, - { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackAnyBytes}, - { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarBytes}, { CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Pack1Word}, { CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(1), ANYSPACE, Pack1WordSkip1}, @@ -3232,8 +3659,10 @@ static const cmsFormatters16 OutputFormatters16[] = { { CHANNELS_SH(6)|BYTES_SH(2), ANYSPACE, Pack6Words}, { CHANNELS_SH(6)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack6WordsSwap}, - { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYENDIAN|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarWords}, - { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackAnyWords} + { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN| + ANYEXTRA|ANYCHANNELS|ANYSPACE|ANYPREMUL, PackChunkyWords}, + { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYENDIAN|ANYSWAP|ANYEXTRA| + ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarWords} }; @@ -3405,6 +3834,11 @@ cmsFormatter CMSEXPORT _cmsGetFormatter(cmsContext ContextID, _cmsFormattersPluginChunkType* ctx = ( _cmsFormattersPluginChunkType*) _cmsContextGetClientChunk(ContextID, FormattersPlugin); cmsFormattersFactoryList* f; + if (T_CHANNELS(Type) == 0) { + static const cmsFormatter nullFormatter = { 0 }; + return nullFormatter; + } + for (f =ctx->FactoryList; f != NULL; f = f ->Next) { cmsFormatter fn = f ->Factory(Type, Dir, dwFlags); @@ -3439,9 +3873,12 @@ cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfil cmsColorSpaceSignature ColorSpace = cmsGetColorSpace(hProfile); cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace); - cmsUInt32Number nOutputChans = cmsChannelsOf(ColorSpace); + cmsInt32Number nOutputChans = cmsChannelsOfColorSpace(ColorSpace); cmsUInt32Number Float = lIsFloat ? 1U : 0; + // Unsupported color space? + if (nOutputChans < 0) return 0; + // Create a fake formatter for result return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans); } @@ -3456,6 +3893,9 @@ cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsU cmsUInt32Number nOutputChans = cmsChannelsOf(ColorSpace); cmsUInt32Number Float = lIsFloat ? 1U : 0; + // Unsupported color space? + if (nOutputChans < 0) return 0; + // Create a fake formatter for result return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans); } diff --git a/src/java.desktop/share/native/liblcms/cmspcs.c b/src/java.desktop/share/native/liblcms/cmspcs.c index 6c628ed5e46..f17c74b4b2d 100644 --- a/src/java.desktop/share/native/liblcms/cmspcs.c +++ b/src/java.desktop/share/native/liblcms/cmspcs.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -903,7 +903,7 @@ int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace) } -cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace) +cmsInt32Number CMSEXPORT cmsChannelsOfColorSpace(cmsColorSpaceSignature ColorSpace) { switch (ColorSpace) { @@ -964,6 +964,16 @@ cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace) case cmsSigMCHFData: case cmsSig15colorData: return 15; - default: return 3; + default: return -1; } } + +/** +* DEPRECATED: Provided for compatibility only +*/ +cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace) +{ + int n = cmsChannelsOfColorSpace(ColorSpace); + if (n < 0) return 3; + return (cmsUInt32Number)n; +} \ No newline at end of file diff --git a/src/java.desktop/share/native/liblcms/cmsplugin.c b/src/java.desktop/share/native/liblcms/cmsplugin.c index 037e6cbcdf1..87c74390bdb 100644 --- a/src/java.desktop/share/native/liblcms/cmsplugin.c +++ b/src/java.desktop/share/native/liblcms/cmsplugin.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -197,17 +197,20 @@ cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n) cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n) { - cmsUInt32Number tmp; + union typeConverter { + cmsUInt32Number integer; + cmsFloat32Number floating_point; + } tmp; _cmsAssert(io != NULL); - if (io->Read(io, &tmp, sizeof(cmsUInt32Number), 1) != 1) + if (io->Read(io, &tmp.integer, sizeof(cmsUInt32Number), 1) != 1) return FALSE; if (n != NULL) { - tmp = _cmsAdjustEndianess32(tmp); - *n = *(cmsFloat32Number*)(void*)&tmp; + tmp.integer = _cmsAdjustEndianess32(tmp.integer); + *n = tmp.floating_point; // Safeguard which covers against absurd values if (*n > 1E+20 || *n < -1E+20) return FALSE; @@ -334,13 +337,14 @@ cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n) cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n) { - cmsUInt32Number tmp; - - _cmsAssert(io != NULL); - - tmp = *(cmsUInt32Number*) (void*) &n; - tmp = _cmsAdjustEndianess32(tmp); - if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1) + union typeConverter { + cmsUInt32Number integer; + cmsFloat32Number floating_point; + } tmp; + + tmp.floating_point = n; + tmp.integer = _cmsAdjustEndianess32(tmp.integer); + if (io -> Write(io, sizeof(cmsUInt32Number), &tmp.integer) != 1) return FALSE; return TRUE; @@ -650,6 +654,10 @@ cmsBool CMSEXPORT cmsPluginTHR(cmsContext id, void* Plug_in) if (!_cmsRegisterMutexPlugin(id, Plugin)) return FALSE; break; + case cmsPluginParalellizationSig: + if (!_cmsRegisterParallelizationPlugin(id, Plugin)) return FALSE; + break; + default: cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized plugin type '%X'", Plugin -> Type); return FALSE; @@ -672,24 +680,25 @@ void CMSEXPORT cmsUnregisterPlugins(void) // pointers structure. All global vars are referenced here. static struct _cmsContext_struct globalContext = { - NULL, // Not in the linked list - NULL, // No suballocator + NULL, // Not in the linked list + NULL, // No suballocator { - NULL, // UserPtr, - &_cmsLogErrorChunk, // Logger, - &_cmsAlarmCodesChunk, // AlarmCodes, - &_cmsAdaptationStateChunk, // AdaptationState, - &_cmsMemPluginChunk, // MemPlugin, - &_cmsInterpPluginChunk, // InterpPlugin, - &_cmsCurvesPluginChunk, // CurvesPlugin, - &_cmsFormattersPluginChunk, // FormattersPlugin, - &_cmsTagTypePluginChunk, // TagTypePlugin, - &_cmsTagPluginChunk, // TagPlugin, - &_cmsIntentsPluginChunk, // IntentPlugin, - &_cmsMPETypePluginChunk, // MPEPlugin, - &_cmsOptimizationPluginChunk, // OptimizationPlugin, - &_cmsTransformPluginChunk, // TransformPlugin, - &_cmsMutexPluginChunk // MutexPlugin + NULL, // UserPtr, + &_cmsLogErrorChunk, // Logger, + &_cmsAlarmCodesChunk, // AlarmCodes, + &_cmsAdaptationStateChunk, // AdaptationState, + &_cmsMemPluginChunk, // MemPlugin, + &_cmsInterpPluginChunk, // InterpPlugin, + &_cmsCurvesPluginChunk, // CurvesPlugin, + &_cmsFormattersPluginChunk, // FormattersPlugin, + &_cmsTagTypePluginChunk, // TagTypePlugin, + &_cmsTagPluginChunk, // TagPlugin, + &_cmsIntentsPluginChunk, // IntentPlugin, + &_cmsMPETypePluginChunk, // MPEPlugin, + &_cmsOptimizationPluginChunk, // OptimizationPlugin, + &_cmsTransformPluginChunk, // TransformPlugin, + &_cmsMutexPluginChunk, // MutexPlugin, + &_cmsParallelizationPluginChunk // ParallelizationPlugin }, { NULL, NULL, NULL, NULL, NULL, NULL } // The default memory allocator is not used for context 0 @@ -700,17 +709,65 @@ static struct _cmsContext_struct globalContext = { static _cmsMutex _cmsContextPoolHeadMutex = CMS_MUTEX_INITIALIZER; static struct _cmsContext_struct* _cmsContextPoolHead = NULL; + +// Make sure context is initialized (needed on windows) +static +cmsBool InitContextMutex(void) +{ + // See the comments regarding locking in lcms2_internal.h + // for an explanation of why we need the following code. +#ifndef CMS_NO_PTHREADS +#ifdef CMS_IS_WINDOWS_ +#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT + + static cmsBool already_initialized = FALSE; + + if (!already_initialized) + { + static HANDLE _cmsWindowsInitMutex = NULL; + static volatile HANDLE* mutex = &_cmsWindowsInitMutex; + + if (*mutex == NULL) + { + HANDLE p = CreateMutex(NULL, FALSE, NULL); + if (p && InterlockedCompareExchangePointer((void**)mutex, (void*)p, NULL) != NULL) + CloseHandle(p); + } + if (*mutex == NULL || WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED) + { + cmsSignalError(0, cmsERROR_INTERNAL, "Mutex lock failed"); + return FALSE; + } + if (((void**)&_cmsContextPoolHeadMutex)[0] == NULL) + InitializeCriticalSection(&_cmsContextPoolHeadMutex); + if (*mutex == NULL || !ReleaseMutex(*mutex)) + { + cmsSignalError(0, cmsERROR_INTERNAL, "Mutex unlock failed"); + return FALSE; + } + already_initialized = TRUE; + } +#endif +#endif +#endif + + return TRUE; +} + + + // Internal, get associated pointer, with guessing. Never returns NULL. struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID) { struct _cmsContext_struct* id = (struct _cmsContext_struct*) ContextID; struct _cmsContext_struct* ctx; - // On 0, use global settings if (id == NULL) return &globalContext; + InitContextMutex(); + // Search _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); @@ -768,6 +825,8 @@ void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc) // identify which plug-in to unregister. void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID) { + struct _cmsContext_struct* ctx = _cmsGetContext(ContextID); + _cmsRegisterMemHandlerPlugin(ContextID, NULL); _cmsRegisterInterpPlugin(ContextID, NULL); _cmsRegisterTagTypePlugin(ContextID, NULL); @@ -779,6 +838,11 @@ void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID) _cmsRegisterOptimizationPlugin(ContextID, NULL); _cmsRegisterTransformPlugin(ContextID, NULL); _cmsRegisterMutexPlugin(ContextID, NULL); + _cmsRegisterParallelizationPlugin(ContextID, NULL); + + if (ctx->MemPool != NULL) + _cmsSubAllocDestroy(ctx->MemPool); + ctx->MemPool = NULL; } @@ -813,31 +877,7 @@ cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData) struct _cmsContext_struct* ctx; struct _cmsContext_struct fakeContext; - // See the comments regarding locking in lcms2_internal.h - // for an explanation of why we need the following code. -#ifndef CMS_NO_PTHREADS -#ifdef CMS_IS_WINDOWS_ -#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT - { - static HANDLE _cmsWindowsInitMutex = NULL; - static volatile HANDLE* mutex = &_cmsWindowsInitMutex; - - if (*mutex == NULL) - { - HANDLE p = CreateMutex(NULL, FALSE, NULL); - if (p && InterlockedCompareExchangePointer((void **)mutex, (void*)p, NULL) != NULL) - CloseHandle(p); - } - if (*mutex == NULL || WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED) - return NULL; - if (((void **)&_cmsContextPoolHeadMutex)[0] == NULL) - InitializeCriticalSection(&_cmsContextPoolHeadMutex); - if (*mutex == NULL || !ReleaseMutex(*mutex)) - return NULL; - } -#endif -#endif -#endif + if (!InitContextMutex()) return NULL; _cmsInstallAllocFunctions(_cmsFindMemoryPlugin(Plugin), &fakeContext.DefaultMemoryManager); @@ -886,6 +926,7 @@ cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData) _cmsAllocOptimizationPluginChunk(ctx, NULL); _cmsAllocTransformPluginChunk(ctx, NULL); _cmsAllocMutexPluginChunk(ctx, NULL); + _cmsAllocParallelizationPluginChunk(ctx, NULL); // Setup the plug-ins if (!cmsPluginTHR(ctx, Plugin)) { @@ -913,6 +954,8 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData) if (ctx == NULL) return NULL; // Something very wrong happened + if (!InitContextMutex()) return NULL; + // Setup default memory allocators memcpy(&ctx->DefaultMemoryManager, &src->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager)); @@ -947,6 +990,7 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData) _cmsAllocOptimizationPluginChunk(ctx, src); _cmsAllocTransformPluginChunk(ctx, src); _cmsAllocMutexPluginChunk(ctx, src); + _cmsAllocParallelizationPluginChunk(ctx, src); // Make sure no one failed for (i=Logger; i < MemoryClientMax; i++) { @@ -972,6 +1016,9 @@ void CMSEXPORT cmsDeleteContext(cmsContext ContextID) struct _cmsContext_struct fakeContext; struct _cmsContext_struct* prev; + + InitContextMutex(); + memcpy(&fakeContext.DefaultMemoryManager, &ctx->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager)); fakeContext.chunks[UserPtr] = ctx ->chunks[UserPtr]; @@ -1018,3 +1065,32 @@ void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID) } +// Use context mutex to provide thread-safe time +cmsBool _cmsGetTime(struct tm* ptr_time) +{ + struct tm* t; +#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) + struct tm tm; +#endif + + time_t now = time(NULL); + +#ifdef HAVE_GMTIME_R + t = gmtime_r(&now, &tm); +#elif defined(HAVE_GMTIME_S) + t = gmtime_s(&tm, &now) == 0 ? &tm : NULL; +#else + if (!InitContextMutex()) return FALSE; + + _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); + t = gmtime(&now); + _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); +#endif + + if (t == NULL) + return FALSE; + else { + *ptr_time = *t; + return TRUE; + } +} diff --git a/src/java.desktop/share/native/liblcms/cmsps2.c b/src/java.desktop/share/native/liblcms/cmsps2.c index e5274540064..c0816347d24 100644 --- a/src/java.desktop/share/native/liblcms/cmsps2.c +++ b/src/java.desktop/share/native/liblcms/cmsps2.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -504,7 +504,7 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table, const char* name) _cmsIOPrintf(m, "/lcms2gammatable ["); for (i=0; i < Table->nEntries; i++) { - if (i % 10 == 0) + if (i % 10 == 0) _cmsIOPrintf(m, "\n "); _cmsIOPrintf(m, "%d ", Table->Table16[i]); } @@ -583,7 +583,7 @@ void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[], const cha } else { snprintf(buffer, sizeof(buffer), "%s%d", nameprefix, (int) i); - buffer[sizeof(buffer)-1] = '\0'; + buffer[sizeof(buffer)-1] = '\0'; Emit1Gamma(m, g[i], buffer); } } diff --git a/src/java.desktop/share/native/liblcms/cmssamp.c b/src/java.desktop/share/native/liblcms/cmssamp.c index d3836420b3f..cf4a13968d1 100644 --- a/src/java.desktop/share/native/liblcms/cmssamp.c +++ b/src/java.desktop/share/native/liblcms/cmssamp.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -155,6 +155,7 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput, // Force it to be neutral, clip to max. L* of 50 Lab.a = Lab.b = 0; if (Lab.L > 50) Lab.L = 50; + if (Lab.L < 0) Lab.L = 0; // Free the resources cmsDeleteTransform(xform); @@ -351,6 +352,7 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[] if (fabs(a) < 1.0E-10) { + if (fabs(b) < 1.0E-10) return 0; return cmsmin(0, cmsmax(50, -c/b )); } else { @@ -361,7 +363,11 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[] } else { - double rt = (-b + sqrt(d)) / (2.0 * a); + double rt; + + if (fabs(a) < 1.0E-10) return 0; + + rt = (-b + sqrt(d)) / (2.0 * a); return cmsmax(0, cmsmin(50, rt)); } diff --git a/src/java.desktop/share/native/liblcms/cmssm.c b/src/java.desktop/share/native/liblcms/cmssm.c index 3d898d2c82a..4300d164df6 100644 --- a/src/java.desktop/share/native/liblcms/cmssm.c +++ b/src/java.desktop/share/native/liblcms/cmssm.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), diff --git a/src/java.desktop/share/native/liblcms/cmstypes.c b/src/java.desktop/share/native/liblcms/cmstypes.c index 006f98b084d..898b5e8ffd6 100644 --- a/src/java.desktop/share/native/liblcms/cmstypes.c +++ b/src/java.desktop/share/native/liblcms/cmstypes.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -163,15 +163,62 @@ cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t* return TRUE; } +// Try to promote correctly to wchar_t when 32 bits +cmsINLINE cmsBool is_surrogate(cmsUInt32Number uc) { return (uc - 0xd800u) < 2048u; } +cmsINLINE cmsBool is_high_surrogate(cmsUInt32Number uc) { return (uc & 0xfffffc00) == 0xd800; } +cmsINLINE cmsBool is_low_surrogate(cmsUInt32Number uc) { return (uc & 0xfffffc00) == 0xdc00; } + +cmsINLINE cmsUInt32Number surrogate_to_utf32(cmsUInt32Number high, cmsUInt32Number low) +{ + return (high << 10) + low - 0x35fdc00; +} + +cmsINLINE cmsBool convert_utf16_to_utf32(cmsIOHANDLER* io, cmsInt32Number n, wchar_t* output) +{ + cmsUInt16Number uc; + + while (n > 0) + { + if (!_cmsReadUInt16Number(io, &uc)) return FALSE; + n--; + + if (!is_surrogate(uc)) + { + *output++ = (wchar_t)uc; + } + else { + + cmsUInt16Number low; + + if (!_cmsReadUInt16Number(io, &low)) return FALSE; + n--; + + if (is_high_surrogate(uc) && is_low_surrogate(low)) + *output++ = (wchar_t)surrogate_to_utf32(uc, low); + else + return FALSE; // Corrupted string, just ignore + } + } + + return TRUE; +} + + // Auxiliary to read an array of wchar_t static cmsBool _cmsReadWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, wchar_t* Array) { cmsUInt32Number i; cmsUInt16Number tmp; + cmsBool is32 = sizeof(wchar_t) > sizeof(cmsUInt16Number); _cmsAssert(io != NULL); + if (is32 && Array != NULL) + { + return convert_utf16_to_utf32(io, n, Array); + } + for (i=0; i < n; i++) { if (Array != NULL) { @@ -1336,7 +1383,7 @@ void Type_ParametricCurve_Free(struct _cms_typehandler_struct* self, void* Ptr) // // All the dateTimeNumber values in a profile shall be in Coordinated Universal Time // (UTC, also known as GMT or ZULU Time). Profile writers are required to convert local -// time to UTC when setting these values. Programmes that display these values may show +// time to UTC when setting these values. Programs that display these values may show // the dateTimeNumber as UTC, show the equivalent local time (at current locale), or // display both UTC and local versions of the dateTimeNumber. @@ -1532,7 +1579,10 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU Block = (wchar_t*) _cmsMalloc(self ->ContextID, SizeOfTag); if (Block == NULL) goto Error; NumOfWchar = SizeOfTag / sizeof(wchar_t); - if (!_cmsReadWCharArray(io, NumOfWchar, Block)) goto Error; + if (!_cmsReadWCharArray(io, NumOfWchar, Block)) { + _cmsFree(self->ContextID, Block); + goto Error; + } } mlu ->MemPool = Block; @@ -1775,7 +1825,7 @@ cmsUInt32Number uipow(cmsUInt32Number n, cmsUInt32Number a, cmsUInt32Number b) // That will create a MPE LUT with Matrix, pre tables, CLUT and post tables. -// 8 bit lut may be scaled easely to v4 PCS, but we need also to properly adjust +// 8 bit lut may be scaled easily to v4 PCS, but we need also to properly adjust // PCS on BToAxx tags and AtoB if abstract. We need to fix input direction. static @@ -1882,7 +1932,7 @@ void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms static cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { - cmsUInt32Number j, nTabSize, i, n; + cmsUInt32Number j, nTabSize, i; cmsUInt8Number val; cmsPipeline* NewLUT = (cmsPipeline*) Ptr; cmsStage* mpe; @@ -1917,28 +1967,34 @@ cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, // That should be all if (mpe != NULL) { - cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8"); + cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8"); return FALSE; } if (clut == NULL) clutPoints = 0; - else - clutPoints = clut->Params->nSamples[0]; + else { + // Lut8 only allows same CLUT points in all dimensions + clutPoints = clut->Params->nSamples[0]; + for (i = 1; i < cmsPipelineInputChannels(NewLUT); i++) { + if (clut->Params->nSamples[i] != clutPoints) { + cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16"); + return FALSE; + } + } + } - if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->InputChannels)) return FALSE; - if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->OutputChannels)) return FALSE; + if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineInputChannels(NewLUT))) return FALSE; + if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineOutputChannels(NewLUT))) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding - n = NewLUT->InputChannels * NewLUT->OutputChannels; - if (MatMPE != NULL) { - for (i = 0; i < 9; i++) - { - if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; - } + for (i = 0; i < 9; i++) + { + if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; + } } else { @@ -2056,10 +2112,10 @@ cmsBool Write16bitTables(cmsContext ContextID, cmsIOHANDLER* io, _cmsStageToneCu _cmsAssert(Tables != NULL); - nEntries = Tables->TheCurves[0]->nEntries; - for (i=0; i < Tables ->nCurves; i++) { + nEntries = Tables->TheCurves[i]->nEntries; + for (j=0; j < nEntries; j++) { val = Tables->TheCurves[i]->Table16[j]; @@ -2202,7 +2258,7 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, // That should be all if (mpe != NULL) { - cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16"); + cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16"); return FALSE; } @@ -2211,8 +2267,16 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, if (clut == NULL) clutPoints = 0; - else - clutPoints = clut->Params->nSamples[0]; + else { + // Lut16 only allows same CLUT points in all dimensions + clutPoints = clut->Params->nSamples[0]; + for (i = 1; i < InputChannels; i++) { + if (clut->Params->nSamples[i] != clutPoints) { + cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16"); + return FALSE; + } + } + } if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE; @@ -2221,10 +2285,10 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, if (MatMPE != NULL) { - for (i = 0; i < 9; i++) - { - if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; - } + for (i = 0; i < 9; i++) + { + if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; + } } else { @@ -2570,31 +2634,31 @@ void* Type_LUTA2B_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, c static cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe) { - cmsUInt32Number i, n; + cmsUInt32Number i, n; _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data; - n = mpe->InputChannels * mpe->OutputChannels; + n = mpe->InputChannels * mpe->OutputChannels; - // Write the Matrix - for (i = 0; i < n; i++) - { - if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE; - } + // Write the Matrix + for (i = 0; i < n; i++) + { + if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE; + } - if (m->Offset != NULL) { + if (m->Offset != NULL) { - for (i = 0; i < mpe->OutputChannels; i++) - { - if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE; - } + for (i = 0; i < mpe->OutputChannels; i++) + { + if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE; } - else { - for (i = 0; i < mpe->OutputChannels; i++) - { - if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; - } + } + else { + for (i = 0; i < mpe->OutputChannels; i++) + { + if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; } + } return TRUE; @@ -3125,7 +3189,6 @@ void Type_ColorantTable_Free(struct _cms_typehandler_struct* self, void* Ptr) static void *Type_NamedColor_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { - cmsUInt32Number vendorFlag; // Bottom 16 bits for ICC use cmsUInt32Number count; // Count of named colors cmsUInt32Number nDeviceCoords; // Num of device coordinates @@ -3197,8 +3260,8 @@ cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER if (!_cmsWriteUInt32Number(io, nColors)) return FALSE; if (!_cmsWriteUInt32Number(io, NamedColorList ->ColorantCount)) return FALSE; - strncpy(prefix, (const char*) NamedColorList->Prefix, 32); - strncpy(suffix, (const char*) NamedColorList->Suffix, 32); + memcpy(prefix, (const char*) NamedColorList->Prefix, sizeof(prefix)); + memcpy(suffix, (const char*) NamedColorList->Suffix, sizeof(suffix)); suffix[32] = prefix[32] = 0; @@ -3211,6 +3274,10 @@ cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER cmsUInt16Number Colorant[cmsMAXCHANNELS]; char Root[cmsMAX_PATH]; + memset(Root, 0, sizeof(Root)); + memset(PCS, 0, sizeof(PCS)); + memset(Colorant, 0, sizeof(Colorant)); + if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0; Root[32] = 0; if (!io ->Write(io, 32 , Root)) return FALSE; @@ -3451,7 +3518,6 @@ void *Type_ProfileSequenceId_Read(struct _cms_typehandler_struct* self, cmsIOHAN // Get table count if (!_cmsReadUInt32Number(io, &Count)) return NULL; - SizeOfTag -= sizeof(cmsUInt32Number); // Allocate an empty structure OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count); @@ -3469,6 +3535,7 @@ void *Type_ProfileSequenceId_Read(struct _cms_typehandler_struct* self, cmsIOHAN *nItems = 1; return OutSeq; + cmsUNUSED_PARAMETER(SizeOfTag); } @@ -3544,47 +3611,68 @@ void *Type_UcrBg_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cm { cmsUcrBg* n = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg)); cmsUInt32Number CountUcr, CountBg; + cmsInt32Number SignedSizeOfTag = (cmsInt32Number)SizeOfTag; char* ASCIIString; *nItems = 0; if (n == NULL) return NULL; // First curve is Under color removal + + if (SignedSizeOfTag < (cmsInt32Number) sizeof(cmsUInt32Number)) return NULL; if (!_cmsReadUInt32Number(io, &CountUcr)) return NULL; - if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; - SizeOfTag -= sizeof(cmsUInt32Number); + SignedSizeOfTag -= sizeof(cmsUInt32Number); n ->Ucr = cmsBuildTabulatedToneCurve16(self ->ContextID, CountUcr, NULL); - if (n ->Ucr == NULL) return NULL; + if (n ->Ucr == NULL) goto error; - if (!_cmsReadUInt16Array(io, CountUcr, n ->Ucr->Table16)) return NULL; - if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; - SizeOfTag -= CountUcr * sizeof(cmsUInt16Number); + if (SignedSizeOfTag < (cmsInt32Number)(CountUcr * sizeof(cmsUInt16Number))) goto error; + if (!_cmsReadUInt16Array(io, CountUcr, n ->Ucr->Table16)) goto error; + + SignedSizeOfTag -= CountUcr * sizeof(cmsUInt16Number); // Second curve is Black generation - if (!_cmsReadUInt32Number(io, &CountBg)) return NULL; - if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; - SizeOfTag -= sizeof(cmsUInt32Number); + + if (SignedSizeOfTag < (cmsInt32Number)sizeof(cmsUInt32Number)) goto error; + if (!_cmsReadUInt32Number(io, &CountBg)) goto error; + SignedSizeOfTag -= sizeof(cmsUInt32Number); n ->Bg = cmsBuildTabulatedToneCurve16(self ->ContextID, CountBg, NULL); - if (n ->Bg == NULL) return NULL; - if (!_cmsReadUInt16Array(io, CountBg, n ->Bg->Table16)) return NULL; - if (SizeOfTag < CountBg * sizeof(cmsUInt16Number)) return NULL; - SizeOfTag -= CountBg * sizeof(cmsUInt16Number); - if (SizeOfTag == UINT_MAX) return NULL; + if (n ->Bg == NULL) goto error; + + if (SignedSizeOfTag < (cmsInt32Number) (CountBg * sizeof(cmsUInt16Number))) goto error; + if (!_cmsReadUInt16Array(io, CountBg, n ->Bg->Table16)) goto error; + SignedSizeOfTag -= CountBg * sizeof(cmsUInt16Number); + + if (SignedSizeOfTag < 0 || SignedSizeOfTag > 32000) goto error; // Now comes the text. The length is specified by the tag size n ->Desc = cmsMLUalloc(self ->ContextID, 1); - if (n ->Desc == NULL) return NULL; + if (n ->Desc == NULL) goto error; - ASCIIString = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1); - if (io ->Read(io, ASCIIString, sizeof(char), SizeOfTag) != SizeOfTag) return NULL; - ASCIIString[SizeOfTag] = 0; + ASCIIString = (char*) _cmsMalloc(self ->ContextID, SignedSizeOfTag + 1); + if (io->Read(io, ASCIIString, sizeof(char), SignedSizeOfTag) != (cmsUInt32Number)SignedSizeOfTag) + { + _cmsFree(self->ContextID, ASCIIString); + goto error; + } + + ASCIIString[SignedSizeOfTag] = 0; cmsMLUsetASCII(n ->Desc, cmsNoLanguage, cmsNoCountry, ASCIIString); _cmsFree(self ->ContextID, ASCIIString); *nItems = 1; return (void*) n; + +error: + + if (n->Ucr) cmsFreeToneCurve(n->Ucr); + if (n->Bg) cmsFreeToneCurve(n->Bg); + if (n->Desc) cmsMLUfree(n->Desc); + _cmsFree(self->ContextID, n); + *nItems = 0; + return NULL; + } static @@ -3665,7 +3753,7 @@ country varies for each element: // Auxiliary, read an string specified as count + string static -cmsBool ReadCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section) +cmsBool ReadCountAndString(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section) { cmsUInt32Number Count; char* Text; @@ -3695,7 +3783,7 @@ cmsBool ReadCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* i } static -cmsBool WriteCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, const char* Section) +cmsBool WriteCountAndString(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, const char* Section) { cmsUInt32Number TextSize; char* Text; @@ -3719,11 +3807,11 @@ void *Type_CrdInfo_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu = cmsMLUalloc(self ->ContextID, 5); *nItems = 0; - if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "nm")) goto Error; - if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#0")) goto Error; - if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#1")) goto Error; - if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#2")) goto Error; - if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#3")) goto Error; + if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "nm")) goto Error; + if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#0")) goto Error; + if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#1")) goto Error; + if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#2")) goto Error; + if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#3")) goto Error; *nItems = 1; return (void*) mlu; @@ -3740,11 +3828,11 @@ cmsBool Type_CrdInfo_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* cmsMLU* mlu = (cmsMLU*) Ptr; - if (!WriteCountAndSting(self, io, mlu, "nm")) goto Error; - if (!WriteCountAndSting(self, io, mlu, "#0")) goto Error; - if (!WriteCountAndSting(self, io, mlu, "#1")) goto Error; - if (!WriteCountAndSting(self, io, mlu, "#2")) goto Error; - if (!WriteCountAndSting(self, io, mlu, "#3")) goto Error; + if (!WriteCountAndString(self, io, mlu, "nm")) goto Error; + if (!WriteCountAndString(self, io, mlu, "#0")) goto Error; + if (!WriteCountAndString(self, io, mlu, "#1")) goto Error; + if (!WriteCountAndString(self, io, mlu, "#2")) goto Error; + if (!WriteCountAndString(self, io, mlu, "#3")) goto Error; return TRUE; @@ -3998,41 +4086,44 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND switch (ElementSig) { - case cmsSigFormulaCurveSeg: { + case cmsSigFormulaCurveSeg: { - cmsUInt16Number Type; - cmsUInt32Number ParamsByType[] = {4, 5, 5 }; + cmsUInt16Number Type; + cmsUInt32Number ParamsByType[] = { 4, 5, 5 }; - if (!_cmsReadUInt16Number(io, &Type)) goto Error; - if (!_cmsReadUInt16Number(io, NULL)) goto Error; + if (!_cmsReadUInt16Number(io, &Type)) goto Error; + if (!_cmsReadUInt16Number(io, NULL)) goto Error; - Segments[i].Type = Type + 6; - if (Type > 2) goto Error; + Segments[i].Type = Type + 6; + if (Type > 2) goto Error; - for (j=0; j < ParamsByType[Type]; j++) { + for (j = 0; j < ParamsByType[Type]; j++) { - cmsFloat32Number f; - if (!_cmsReadFloat32Number(io, &f)) goto Error; - Segments[i].Params[j] = f; - } - } - break; + cmsFloat32Number f; + if (!_cmsReadFloat32Number(io, &f)) goto Error; + Segments[i].Params[j] = f; + } + } + break; - case cmsSigSampledCurveSeg: { - cmsUInt32Number Count; + case cmsSigSampledCurveSeg: { + cmsUInt32Number Count; - if (!_cmsReadUInt32Number(io, &Count)) goto Error; + if (!_cmsReadUInt32Number(io, &Count)) goto Error; - Segments[i].nGridPoints = Count; - Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number)); - if (Segments[i].SampledPoints == NULL) goto Error; + // The first point is implicit in the last stage, we allocate an extra note to be populated latter on + Count++; + Segments[i].nGridPoints = Count; + Segments[i].SampledPoints = (cmsFloat32Number*)_cmsCalloc(self->ContextID, Count, sizeof(cmsFloat32Number)); + if (Segments[i].SampledPoints == NULL) goto Error; - for (j=0; j < Count; j++) { - if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j])) goto Error; - } - } - break; + Segments[i].SampledPoints[0] = 0; + for (j = 1; j < Count; j++) { + if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j])) goto Error; + } + } + break; default: { @@ -4052,6 +4143,17 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints); } _cmsFree(self ->ContextID, Segments); + + // Explore for missing implicit points + for (i = 0; i < nSegments; i++) { + + // If sampled curve, fix it + if (Curve->Segments[i].Type == 0) { + + Curve->Segments[i].SampledPoints[0] = cmsEvalToneCurveFloat(Curve, Curve->Segments[i].x0); + } + } + return Curve; Error: @@ -4146,12 +4248,12 @@ cmsBool WriteSegmentedCurve(cmsIOHANDLER* io, cmsToneCurve* g) if (ActualSeg -> Type == 0) { - // This is a sampled curve + // This is a sampled curve. First point is implicit in the ICC format, but not in our representation if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) cmsSigSampledCurveSeg)) goto Error; if (!_cmsWriteUInt32Number(io, 0)) goto Error; - if (!_cmsWriteUInt32Number(io, ActualSeg -> nGridPoints)) goto Error; + if (!_cmsWriteUInt32Number(io, ActualSeg -> nGridPoints - 1)) goto Error; - for (j=0; j < g ->Segments[i].nGridPoints; j++) { + for (j=1; j < g ->Segments[i].nGridPoints; j++) { if (!_cmsWriteFloat32Number(io, ActualSeg -> SampledPoints[j])) goto Error; } @@ -4528,7 +4630,7 @@ void *Type_MPE_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU -// This one is a liitle bit more complex, so we don't use position tables this time. +// This one is a little bit more complex, so we don't use position tables this time. static cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { @@ -4960,7 +5062,7 @@ cmsBool ReadOneElem(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, cmsUIn if (!_cmsReadUInt32Number(io, &e->Offsets[i])) return FALSE; if (!_cmsReadUInt32Number(io, &e ->Sizes[i])) return FALSE; - // An offset of zero has special meaning and shal be preserved + // An offset of zero has special meaning and shall be preserved if (e ->Offsets[i] > 0) e ->Offsets[i] += BaseOffset; return TRUE; @@ -4968,27 +5070,41 @@ cmsBool ReadOneElem(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, cmsUIn static -cmsBool ReadOffsetArray(cmsIOHANDLER* io, _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length, cmsUInt32Number BaseOffset) +cmsBool ReadOffsetArray(cmsIOHANDLER* io, _cmsDICarray* a, + cmsUInt32Number Count, cmsUInt32Number Length, cmsUInt32Number BaseOffset, + cmsInt32Number* SignedSizeOfTagPtr) { cmsUInt32Number i; + cmsInt32Number SignedSizeOfTag = *SignedSizeOfTagPtr; // Read column arrays for (i=0; i < Count; i++) { + if (SignedSizeOfTag < 4 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE; + SignedSizeOfTag -= 4 * sizeof(cmsUInt32Number); + if (!ReadOneElem(io, &a -> Name, i, BaseOffset)) return FALSE; if (!ReadOneElem(io, &a -> Value, i, BaseOffset)) return FALSE; if (Length > 16) { + if (SignedSizeOfTag < 2 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE; + SignedSizeOfTag -= 2 * sizeof(cmsUInt32Number); + if (!ReadOneElem(io, &a ->DisplayName, i, BaseOffset)) return FALSE; } if (Length > 24) { + if (SignedSizeOfTag < 2 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE; + SignedSizeOfTag -= 2 * (cmsInt32Number) sizeof(cmsUInt32Number); + if (!ReadOneElem(io, & a -> DisplayValue, i, BaseOffset)) return FALSE; } } + + *SignedSizeOfTagPtr = SignedSizeOfTag; return TRUE; } @@ -5136,26 +5252,31 @@ cmsBool WriteOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, _c static void *Type_Dictionary_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { - cmsHANDLE hDict; + cmsHANDLE hDict = NULL; cmsUInt32Number i, Count, Length; cmsUInt32Number BaseOffset; _cmsDICarray a; wchar_t *NameWCS = NULL, *ValueWCS = NULL; cmsMLU *DisplayNameMLU = NULL, *DisplayValueMLU=NULL; cmsBool rc; + cmsInt32Number SignedSizeOfTag = (cmsInt32Number)SizeOfTag; *nItems = 0; + memset(&a, 0, sizeof(a)); // Get actual position as a basis for element offsets BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase); // Get name-value record count + SignedSizeOfTag -= sizeof(cmsUInt32Number); + if (SignedSizeOfTag < 0) goto Error; if (!_cmsReadUInt32Number(io, &Count)) return NULL; - SizeOfTag -= sizeof(cmsUInt32Number); // Get rec length + SignedSizeOfTag -= sizeof(cmsUInt32Number); + if (SignedSizeOfTag < 0) goto Error; if (!_cmsReadUInt32Number(io, &Length)) return NULL; - SizeOfTag -= sizeof(cmsUInt32Number); + // Check for valid lengths if (Length != 16 && Length != 24 && Length != 32) { @@ -5171,7 +5292,7 @@ void *Type_Dictionary_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* i if (!AllocArray(self -> ContextID, &a, Count, Length)) goto Error; // Read column arrays - if (!ReadOffsetArray(io, &a, Count, Length, BaseOffset)) goto Error; + if (!ReadOffsetArray(io, &a, Count, Length, BaseOffset, &SignedSizeOfTag)) goto Error; // Seek to each element and read it for (i=0; i < Count; i++) { @@ -5211,7 +5332,7 @@ void *Type_Dictionary_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* i Error: FreeArray(&a); - cmsDictFree(hDict); + if (hDict != NULL) cmsDictFree(hDict); return NULL; } @@ -5309,6 +5430,64 @@ void Type_Dictionary_Free(struct _cms_typehandler_struct* self, void* Ptr) cmsUNUSED_PARAMETER(self); } +// cicp VideoSignalType + +static +void* Type_VideoSignal_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) +{ + cmsVideoSignalType* cicp = NULL; + + if (SizeOfTag != 8) return NULL; + + if (!_cmsReadUInt32Number(io, NULL)) return NULL; + + cicp = (cmsVideoSignalType*)_cmsCalloc(self->ContextID, 1, sizeof(cmsVideoSignalType)); + if (cicp == NULL) return NULL; + + if (!_cmsReadUInt8Number(io, &cicp->ColourPrimaries)) goto Error; + if (!_cmsReadUInt8Number(io, &cicp->TransferCharacteristics)) goto Error; + if (!_cmsReadUInt8Number(io, &cicp->MatrixCoefficients)) goto Error; + if (!_cmsReadUInt8Number(io, &cicp->VideoFullRangeFlag)) goto Error; + + // Success + *nItems = 1; + return cicp; + +Error: + if (cicp != NULL) _cmsFree(self->ContextID, cicp); + return NULL; +} + +static +cmsBool Type_VideoSignal_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) +{ + cmsVideoSignalType* cicp = (cmsVideoSignalType*)Ptr; + + if (!_cmsWriteUInt32Number(io, 0)) return FALSE; + if (!_cmsWriteUInt8Number(io, cicp->ColourPrimaries)) return FALSE; + if (!_cmsWriteUInt8Number(io, cicp->TransferCharacteristics)) return FALSE; + if (!_cmsWriteUInt8Number(io, cicp->MatrixCoefficients)) return FALSE; + if (!_cmsWriteUInt8Number(io, cicp->VideoFullRangeFlag)) return FALSE; + + return TRUE; + + cmsUNUSED_PARAMETER(self); + cmsUNUSED_PARAMETER(nItems); +} + +void* Type_VideoSignal_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n) +{ + return _cmsDupMem(self->ContextID, Ptr, sizeof(cmsVideoSignalType)); + + cmsUNUSED_PARAMETER(n); +} + + +static +void Type_VideoSignal_Free(struct _cms_typehandler_struct* self, void* Ptr) +{ + _cmsFree(self->ContextID, Ptr); +} // ******************************************************************************** // Type support main routines @@ -5348,6 +5527,7 @@ static const _cmsTagTypeLinkedList SupportedTagTypes[] = { {TYPE_HANDLER(cmsMonacoBrokenCurveType, Curve), (_cmsTagTypeLinkedList*) &SupportedTagTypes[28] }, {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 } }; @@ -5542,6 +5722,8 @@ static _cmsTagLinkedList SupportedTags[] = { { cmsSigProfileSequenceIdTag, { 1, 1, { cmsSigProfileSequenceIdType}, NULL }, &SupportedTags[62]}, { cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, &SupportedTags[63]}, + { cmsSigcicpTag, { 1, 1, { cmsSigcicpType}, NULL }, &SupportedTags[64]}, + { cmsSigArgyllArtsTag, { 9, 1, { cmsSigS15Fixed16ArrayType}, NULL}, NULL} }; diff --git a/src/java.desktop/share/native/liblcms/cmsvirt.c b/src/java.desktop/share/native/liblcms/cmsvirt.c index c185b347efb..6d15f1fde13 100644 --- a/src/java.desktop/share/native/liblcms/cmsvirt.c +++ b/src/java.desktop/share/native/liblcms/cmsvirt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -143,7 +143,7 @@ cmsHPROFILE CMSEXPORT cmsCreateRGBProfileTHR(cmsContext ContextID, if (!hICC) // can't allocate return NULL; - cmsSetProfileVersion(hICC, 4.3); + cmsSetProfileVersion(hICC, 4.4); cmsSetDeviceClass(hICC, cmsSigDisplayClass); cmsSetColorSpace(hICC, cmsSigRgbData); @@ -264,7 +264,7 @@ cmsHPROFILE CMSEXPORT cmsCreateGrayProfileTHR(cmsContext ContextID, if (!hICC) // can't allocate return NULL; - cmsSetProfileVersion(hICC, 4.3); + cmsSetProfileVersion(hICC, 4.4); cmsSetDeviceClass(hICC, cmsSigDisplayClass); cmsSetColorSpace(hICC, cmsSigGrayData); @@ -320,13 +320,13 @@ cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID, { cmsHPROFILE hICC; cmsPipeline* Pipeline; - cmsUInt32Number nChannels; + cmsInt32Number nChannels; hICC = cmsCreateProfilePlaceholder(ContextID); if (!hICC) return NULL; - cmsSetProfileVersion(hICC, 4.3); + cmsSetProfileVersion(hICC, 4.4); cmsSetDeviceClass(hICC, cmsSigLinkClass); cmsSetColorSpace(hICC, ColorSpace); @@ -335,7 +335,7 @@ cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID, cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL); // Set up channels - nChannels = cmsChannelsOf(ColorSpace); + nChannels = cmsChannelsOfColorSpace(ColorSpace); // Creates a Pipeline with prelinearization step only Pipeline = cmsPipelineAlloc(ContextID, nChannels, nChannels); @@ -397,7 +397,7 @@ int InkLimitingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUI InkLimit = (InkLimit * 655.35); - SumCMY = In[0] + In[1] + In[2]; + SumCMY = (cmsFloat64Number) In[0] + In[1] + In[2]; SumCMYK = SumCMY + In[3]; if (SumCMYK > InkLimit) { @@ -426,7 +426,7 @@ cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID, cmsHPROFILE hICC; cmsPipeline* LUT; cmsStage* CLUT; - cmsUInt32Number nChannels; + cmsInt32Number nChannels; if (ColorSpace != cmsSigCmykData) { cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "InkLimiting: Only CMYK currently supported"); @@ -445,7 +445,7 @@ cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID, if (!hICC) // can't allocate return NULL; - cmsSetProfileVersion(hICC, 4.3); + cmsSetProfileVersion(hICC, 4.4); cmsSetDeviceClass(hICC, cmsSigLinkClass); cmsSetColorSpace(hICC, ColorSpace); @@ -555,7 +555,7 @@ cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIE hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL); if (hProfile == NULL) return NULL; - cmsSetProfileVersion(hProfile, 4.3); + cmsSetProfileVersion(hProfile, 4.4); cmsSetDeviceClass(hProfile, cmsSigAbstractClass); cmsSetColorSpace(hProfile, cmsSigLabData); @@ -601,7 +601,7 @@ cmsHPROFILE CMSEXPORT cmsCreateXYZProfileTHR(cmsContext ContextID) hProfile = cmsCreateRGBProfileTHR(ContextID, cmsD50_xyY(), NULL, NULL); if (hProfile == NULL) return NULL; - cmsSetProfileVersion(hProfile, 4.3); + cmsSetProfileVersion(hProfile, 4.4); cmsSetDeviceClass(hProfile, cmsSigAbstractClass); cmsSetColorSpace(hProfile, cmsSigXYZData); @@ -868,7 +868,7 @@ cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID) if (!hProfile) // can't allocate return NULL; - cmsSetProfileVersion(hProfile, 4.3); + cmsSetProfileVersion(hProfile, 4.4); if (!SetTextTags(hProfile, L"NULL profile built-in")) goto Error; @@ -1003,7 +1003,7 @@ cmsHPROFILE CreateNamedColorDevicelink(cmsHTRANSFORM xform) // Make sure we have proper formatters cmsChangeBuffersFormat(xform, TYPE_NAMED_COLOR_INDEX, FLOAT_SH(0) | COLORSPACE_SH(_cmsLCMScolorSpace(v ->ExitColorSpace)) - | BYTES_SH(2) | CHANNELS_SH(cmsChannelsOf(v ->ExitColorSpace))); + | BYTES_SH(2) | CHANNELS_SH(cmsChannelsOfColorSpace(v ->ExitColorSpace))); // Apply the transfor to colorants. for (i=0; i < nColors; i++) { @@ -1091,8 +1091,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, ChansIn, ChansOut; - int ColorSpaceBitsIn, ColorSpaceBitsOut; + cmsUInt32Number FrmIn, FrmOut; + cmsInt32Number ChansIn, ChansOut; + int ColorSpaceBitsIn, ColorSpaceBitsOut; _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform; cmsPipeline* LUT = NULL; cmsStage* mpe; @@ -1143,8 +1144,8 @@ cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat // Optimize the LUT and precalculate a devicelink - ChansIn = cmsChannelsOf(xform -> EntryColorSpace); - ChansOut = cmsChannelsOf(xform -> ExitColorSpace); + ChansIn = cmsChannelsOfColorSpace(xform -> EntryColorSpace); + ChansOut = cmsChannelsOfColorSpace(xform -> ExitColorSpace); ColorSpaceBitsIn = _cmsLCMScolorSpace(xform -> EntryColorSpace); ColorSpaceBitsOut = _cmsLCMScolorSpace(xform -> ExitColorSpace); diff --git a/src/java.desktop/share/native/liblcms/cmswtpnt.c b/src/java.desktop/share/native/liblcms/cmswtpnt.c index d93889114e6..96bad5de7ca 100644 --- a/src/java.desktop/share/native/liblcms/cmswtpnt.c +++ b/src/java.desktop/share/native/liblcms/cmswtpnt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -293,16 +293,16 @@ cmsBool _cmsAdaptMatrixToD50(cmsMAT3* r, const cmsCIExyY* SourceWhitePt) // Build a White point, primary chromas transfer matrix from RGB to CIE XYZ // This is just an approximation, I am not handling all the non-linear -// aspects of the RGB to XYZ process, and assumming that the gamma correction +// aspects of the RGB to XYZ process, and assuming that the gamma correction // has transitive property in the transformation chain. // -// the alghoritm: +// the algorithm: // // - First I build the absolute conversion matrix using // primaries in XYZ. This matrix is next inverted // - Then I eval the source white point across this matrix -// obtaining the coeficients of the transformation -// - Then, I apply these coeficients to the original matrix +// obtaining the coefficients of the transformation +// - Then, I apply these coefficients to the original matrix // cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePt, const cmsCIExyYTRIPLE* Primrs) { diff --git a/src/java.desktop/share/native/liblcms/cmsxform.c b/src/java.desktop/share/native/liblcms/cmsxform.c index 6a2170c8fd2..8b8f831f0af 100644 --- a/src/java.desktop/share/native/liblcms/cmsxform.c +++ b/src/java.desktop/share/native/liblcms/cmsxform.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -313,7 +313,7 @@ void FloatXFORM(_cmsTRANSFORM* p, accum = p->FromInputFloat(p, fIn, accum, Stride->BytesPerPlaneIn); - // Any gamut chack to do? + // Any gamut check to do? if (p->GamutCheck != NULL) { // Evaluate gamut marker. @@ -810,6 +810,73 @@ cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMM return CMMcargo->dwOriginalFlags; } +// Returns the worker callback for parallelization plug-ins +_cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo) +{ + _cmsAssert(CMMcargo != NULL); + return CMMcargo->Worker; +} + +// This field holds maximum number of workers or -1 to auto +cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo) +{ + _cmsAssert(CMMcargo != NULL); + return CMMcargo->MaxWorkers; +} + +// This field is actually unused and reserved +cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo) +{ + _cmsAssert(CMMcargo != NULL); + return CMMcargo->WorkerFlags; +} + +// In the case there is a parallelization plug-in, let it to do its job +static +void ParalellizeIfSuitable(_cmsTRANSFORM* p) +{ + _cmsParallelizationPluginChunkType* ctx = (_cmsParallelizationPluginChunkType*)_cmsContextGetClientChunk(p->ContextID, ParallelizationPlugin); + + _cmsAssert(p != NULL); + if (ctx != NULL && ctx->SchedulerFn != NULL) { + + p->Worker = p->xform; + p->xform = ctx->SchedulerFn; + p->MaxWorkers = ctx->MaxWorkers; + p->WorkerFlags = ctx->WorkerFlags; + } +} + + +/** +* An empty unroll to avoid a check with NULL on cmsDoTransform() +*/ +static +cmsUInt8Number* UnrollNothing(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wIn[], + CMSREGISTER cmsUInt8Number* accum, + CMSREGISTER cmsUInt32Number Stride) +{ + return accum; + + cmsUNUSED_PARAMETER(info); + cmsUNUSED_PARAMETER(wIn); + cmsUNUSED_PARAMETER(Stride); +} + +static +cmsUInt8Number* PackNothing(CMSREGISTER _cmsTRANSFORM* info, + CMSREGISTER cmsUInt16Number wOut[], + CMSREGISTER cmsUInt8Number* output, + CMSREGISTER cmsUInt32Number Stride) +{ + return output; + + cmsUNUSED_PARAMETER(info); + cmsUNUSED_PARAMETER(wOut); + cmsUNUSED_PARAMETER(Stride); +} + // Allocate transform struct and set it to defaults. Ask the optimization plug-in about if those formats are proper // for separated transforms. If this is the case, static @@ -865,6 +932,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, p->xform = _cmsTransform2toTransformAdaptor; } + ParalellizeIfSuitable(p); return p; } } @@ -875,7 +943,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, } // Check whatever this is a true floating point transform - if (_cmsFormatterIsFloat(*InputFormat) && _cmsFormatterIsFloat(*OutputFormat)) { + if (_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; @@ -901,8 +969,10 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, } else { + // Formats are intended to be changed before use if (*InputFormat == 0 && *OutputFormat == 0) { - p ->FromInput = p ->ToOutput = NULL; + p->FromInput = UnrollNothing; + p->ToOutput = PackNothing; *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER; } else { @@ -919,7 +989,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, return NULL; } - BytesPerPixelInput = T_BYTES(p ->InputFormat); + BytesPerPixelInput = T_BYTES(*InputFormat); if (BytesPerPixelInput == 0 || BytesPerPixelInput >= 2) *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER; @@ -953,6 +1023,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, p ->dwOriginalFlags = *dwFlags; p ->ContextID = ContextID; p ->UserData = NULL; + ParalellizeIfSuitable(p); return p; } @@ -1110,6 +1181,15 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID, return NULL; } + // Check whatever the transform is 16 bits and involves linear RGB in first profile. If so, disable optimizations + if (EntryColorSpace == cmsSigRgbData && T_BYTES(InputFormat) == 2 && !(dwFlags & cmsFLAGS_NOOPTIMIZE)) + { + cmsFloat64Number gamma = cmsDetectRGBProfileGamma(hProfiles[0], 0.1); + + if (gamma > 0 && gamma < 1.6) + dwFlags |= cmsFLAGS_NOOPTIMIZE; + } + // Create a pipeline with all transformations Lut = _cmsLinkProfiles(ContextID, nProfiles, Intents, hProfiles, BPC, AdaptationStates, dwFlags); if (Lut == NULL) { @@ -1118,8 +1198,8 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID, } // Check channel count - if ((cmsChannelsOf(EntryColorSpace) != cmsPipelineInputChannels(Lut)) || - (cmsChannelsOf(ExitColorSpace) != cmsPipelineOutputChannels(Lut))) { + if ((cmsChannelsOfColorSpace(EntryColorSpace) != (cmsInt32Number) cmsPipelineInputChannels(Lut)) || + (cmsChannelsOfColorSpace(ExitColorSpace) != (cmsInt32Number) cmsPipelineOutputChannels(Lut))) { cmsPipelineFree(Lut); cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Channel count doesn't match. Profile is corrupted"); return NULL; diff --git a/src/java.desktop/share/native/liblcms/lcms2.h b/src/java.desktop/share/native/liblcms/lcms2.h index 69ada9ede64..ab122f3b342 100644 --- a/src/java.desktop/share/native/liblcms/lcms2.h +++ b/src/java.desktop/share/native/liblcms/lcms2.h @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2021 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -52,7 +52,7 @@ // //--------------------------------------------------------------------------------- // -// Version 2.12 +// Version 2.14 // #ifndef _lcms2_H @@ -110,7 +110,7 @@ extern "C" { #endif // Version/release -#define LCMS_VERSION 2120 +#define LCMS_VERSION 2140 // I will give the chance of redefining basic types for compilers that are not fully C99 compliant #ifndef CMS_BASIC_TYPES_ALREADY_DEFINED @@ -181,7 +181,7 @@ typedef double cmsFloat64Number; #endif // Handle "register" keyword -#if defined(CMS_NO_REGISTER_KEYWORD) && !defined(CMS_DLL) && !defined(CMS_DLL_BUILD) +#if defined(CMS_NO_REGISTER_KEYWORD) # define CMSREGISTER #else # define CMSREGISTER register @@ -319,6 +319,7 @@ typedef int cmsBool; // Base ICC type definitions typedef enum { cmsSigChromaticityType = 0x6368726D, // 'chrm' + cmsSigcicpType = 0x63696370, // 'cicp' cmsSigColorantOrderType = 0x636C726F, // 'clro' cmsSigColorantTableType = 0x636C7274, // 'clrt' cmsSigCrdInfoType = 0x63726469, // 'crdi' @@ -430,6 +431,7 @@ typedef enum { cmsSigViewingConditionsTag = 0x76696577, // 'view' cmsSigVcgtTag = 0x76636774, // 'vcgt' cmsSigMetaTag = 0x6D657461, // 'meta' + cmsSigcicpTag = 0x63696370, // 'cicp' cmsSigArgyllArtsTag = 0x61727473 // 'arts' } cmsTagSignature; @@ -695,9 +697,10 @@ typedef void* cmsHTRANSFORM; // Format of pixel is defined by one cmsUInt32Number, using bit fields as follows // // 2 1 0 -// 3 2 10987 6 5 4 3 2 1 098 7654 321 -// A O TTTTT U Y F P X S EEE CCCC BBB +// 4 3 2 10987 6 5 4 3 2 1 098 7654 321 +// M A O TTTTT U Y F P X S EEE CCCC BBB // +// M: Premultiplied alpha (only works when extra samples is 1) // A: Floating point -- With this flag we can differentiate 16 bits as float and as int // O: Optimized -- previous optimization already returns the final 8-bit value // T: Pixeltype @@ -710,6 +713,7 @@ typedef void* cmsHTRANSFORM; // B: bytes per sample // Y: Swap first - changes ABGR to BGRA and KCMY to CMYK +#define PREMUL_SH(m) ((m) << 23) #define FLOAT_SH(a) ((a) << 22) #define OPTIMIZED_SH(s) ((s) << 21) #define COLORSPACE_SH(s) ((s) << 16) @@ -723,6 +727,7 @@ typedef void* cmsHTRANSFORM; #define BYTES_SH(b) (b) // These macros unpack format specifiers into integers +#define T_PREMUL(m) (((m)>>23)&1) #define T_FLOAT(a) (((a)>>22)&1) #define T_OPTIMIZED(o) (((o)>>21)&1) #define T_COLORSPACE(s) (((s)>>16)&31) @@ -751,7 +756,6 @@ typedef void* cmsHTRANSFORM; #define PT_HSV 12 #define PT_HLS 13 #define PT_Yxy 14 - #define PT_MCH1 15 #define PT_MCH2 16 #define PT_MCH3 17 @@ -767,7 +771,6 @@ typedef void* cmsHTRANSFORM; #define PT_MCH13 27 #define PT_MCH14 28 #define PT_MCH15 29 - #define PT_LabV2 30 // Identical to PT_Lab, but using the V2 old encoding // Some (not all!) representations @@ -781,7 +784,9 @@ typedef void* cmsHTRANSFORM; #define TYPE_GRAY_16_REV (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1)) #define TYPE_GRAY_16_SE (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1)) #define TYPE_GRAYA_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)) +#define TYPE_GRAYA_8_PREMUL (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PREMUL_SH(1)) #define TYPE_GRAYA_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)) +#define TYPE_GRAYA_16_PREMUL (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PREMUL_SH(1)) #define TYPE_GRAYA_16_SE (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1)) #define TYPE_GRAYA_8_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PLANAR_SH(1)) #define TYPE_GRAYA_16_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PLANAR_SH(1)) @@ -798,24 +803,32 @@ typedef void* cmsHTRANSFORM; #define TYPE_BGR_16_SE (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1)) #define TYPE_RGBA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)) +#define TYPE_RGBA_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PREMUL_SH(1)) #define TYPE_RGBA_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1)) #define TYPE_RGBA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)) +#define TYPE_RGBA_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PREMUL_SH(1)) #define TYPE_RGBA_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1)) #define TYPE_RGBA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)) #define TYPE_ARGB_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)) +#define TYPE_ARGB_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_ARGB_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1)) #define TYPE_ARGB_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1)) +#define TYPE_ARGB_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_ABGR_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)) +#define TYPE_ABGR_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PREMUL_SH(1)) #define TYPE_ABGR_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1)) #define TYPE_ABGR_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)) +#define TYPE_ABGR_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PREMUL_SH(1)) #define TYPE_ABGR_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1)) #define TYPE_ABGR_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1)) #define TYPE_BGRA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)) +#define TYPE_BGRA_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_BGRA_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1)) #define TYPE_BGRA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1)) +#define TYPE_BGRA_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_BGRA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)) #define TYPE_CMY_8 (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1)) @@ -932,7 +945,7 @@ typedef void* cmsHTRANSFORM; #define TYPE_HSV_16_PLANAR (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1)) #define TYPE_HSV_16_SE (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)) -// Named color index. Only 16 bits allowed (don't check colorspace) +// Named color index. Only 16 bits is allowed (don't check colorspace) #define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2)) // Float formatters. @@ -940,13 +953,19 @@ typedef void* cmsHTRANSFORM; #define TYPE_Lab_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4)) #define TYPE_LabA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)) #define TYPE_GRAY_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4)) +#define TYPE_GRAYA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4)|EXTRA_SH(1)) +#define TYPE_GRAYA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4)|EXTRA_SH(1)|PREMUL_SH(1)) #define TYPE_RGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)) #define TYPE_RGBA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)) +#define TYPE_RGBA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|PREMUL_SH(1)) #define TYPE_ARGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1)) +#define TYPE_ARGB_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_BGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)) #define TYPE_BGRA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1)) +#define TYPE_BGRA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1)) #define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)) +#define TYPE_ABGR_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|PREMUL_SH(1)) #define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4)) @@ -1050,6 +1069,16 @@ typedef struct { } cmsICCViewingConditions; +typedef struct { + cmsUInt8Number ColourPrimaries; // Recommendation ITU-T H.273 + cmsUInt8Number TransferCharacteristics; // (ISO/IEC 23091-2) + cmsUInt8Number MatrixCoefficients; + cmsUInt8Number VideoFullRangeFlag; + +} cmsVideoSignalType; + + + // Get LittleCMS version (for shared objects) ----------------------------------------------------------------------------- CMSAPI int CMSEXPORT cmsGetEncodedCMMversion(void); @@ -1285,6 +1314,7 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsStageInputChannels(const cmsStage* mpe); CMSAPI cmsUInt32Number CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe); CMSAPI cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe); CMSAPI void* CMSEXPORT cmsStageData(const cmsStage* mpe); +CMSAPI cmsContext CMSEXPORT cmsGetStageContextID(const cmsStage* mpe); // Sampling typedef cmsInt32Number (* cmsSAMPLER16) (CMSREGISTER const cmsUInt16Number In[], @@ -1531,8 +1561,12 @@ CMSAPI cmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Numb CMSAPI cmsColorSpaceSignature CMSEXPORT _cmsICCcolorSpace(int OurNotation); CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace); +// Deprecated, use cmsChannelsOfColorSpace instead CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace); +// Get number of channels of color space or -1 if color space is not listed/supported +CMSAPI cmsInt32Number CMSEXPORT cmsChannelsOfColorSpace(cmsColorSpaceSignature ColorSpace); + // Build a suitable formatter for the colorspace of this profile. nBytes=1 means 8 bits, nBytes=2 means 16 bits. CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat); CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat); @@ -1935,6 +1969,8 @@ CMSAPI cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* Blac // Estimate total area coverage CMSAPI cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile); +// Estimate gamma space, always positive. Returns -1 on error. +CMSAPI cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFloat64Number threshold); // Poor man's gamut mapping CMSAPI cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab, diff --git a/src/java.desktop/share/native/liblcms/lcms2_internal.h b/src/java.desktop/share/native/liblcms/lcms2_internal.h index d1c78208b82..3999e24d771 100644 --- a/src/java.desktop/share/native/liblcms/lcms2_internal.h +++ b/src/java.desktop/share/native/liblcms/lcms2_internal.h @@ -30,7 +30,7 @@ // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -312,38 +312,38 @@ typedef CRITICAL_SECTION _cmsMutex; cmsINLINE int _cmsLockPrimitive(_cmsMutex *m) { - EnterCriticalSection(m); - return 0; + EnterCriticalSection(m); + return 0; } cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m) { - LeaveCriticalSection(m); - return 0; + LeaveCriticalSection(m); + return 0; } cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m) { - InitializeCriticalSection(m); - return 0; + InitializeCriticalSection(m); + return 0; } cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m) { - DeleteCriticalSection(m); - return 0; + DeleteCriticalSection(m); + return 0; } cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m) { - EnterCriticalSection(m); - return 0; + EnterCriticalSection(m); + return 0; } cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m) { - LeaveCriticalSection(m); - return 0; + LeaveCriticalSection(m); + return 0; } #else @@ -357,32 +357,32 @@ typedef pthread_mutex_t _cmsMutex; cmsINLINE int _cmsLockPrimitive(_cmsMutex *m) { - return pthread_mutex_lock(m); + return pthread_mutex_lock(m); } cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m) { - return pthread_mutex_unlock(m); + return pthread_mutex_unlock(m); } cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m) { - return pthread_mutex_init(m, NULL); + return pthread_mutex_init(m, NULL); } cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m) { - return pthread_mutex_destroy(m); + return pthread_mutex_destroy(m); } cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m) { - return pthread_mutex_lock(m); + return pthread_mutex_lock(m); } cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m) { - return pthread_mutex_unlock(m); + return pthread_mutex_unlock(m); } #endif @@ -395,37 +395,37 @@ typedef int _cmsMutex; cmsINLINE int _cmsLockPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m) { cmsUNUSED_PARAMETER(m); - return 0; + return 0; } #endif @@ -467,6 +467,9 @@ cmsBool _cmsRegisterTransformPlugin(cmsContext ContextID, cmsPluginBase* Plugin // Mutex cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Plugin); +// Paralellization +cmsBool _cmsRegisterParallelizationPlugin(cmsContext ContextID, cmsPluginBase* Plugin); + // --------------------------------------------------------------------------------------------------------- // Suballocators. @@ -514,6 +517,7 @@ typedef enum { OptimizationPlugin, TransformPlugin, MutexPlugin, + ParallelizationPlugin, // Last in list MemoryClientMax @@ -749,6 +753,24 @@ extern _cmsMutexPluginChunkType _cmsMutexPluginChunk; void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsContext_struct* src); +// Container for parallelization plug-in +typedef struct { + + cmsInt32Number MaxWorkers; // Number of workers to do as maximum + cmsInt32Number WorkerFlags; // reserved + _cmsTransform2Fn SchedulerFn; // callback to setup functions + +} _cmsParallelizationPluginChunkType; + +// The global Context0 storage for parallelization plug-in +extern _cmsParallelizationPluginChunkType _cmsParallelizationPluginChunk; + +// Allocate parallelization container. +void _cmsAllocParallelizationPluginChunk(struct _cmsContext_struct* ctx, + const struct _cmsContext_struct* src); + + + // ---------------------------------------------------------------------------------- // MLU internal representation typedef struct { @@ -1110,6 +1132,11 @@ typedef struct _cmstransform_struct { // A way to provide backwards compatibility with full xform plugins _cmsTransformFn OldXform; + // A one-worker transform entry for parallelization + _cmsTransform2Fn Worker; + cmsInt32Number MaxWorkers; + cmsUInt32Number WorkerFlags; + } _cmsTRANSFORM; // Copies extra channels from input to output if the original flags in the transform structure @@ -1147,5 +1174,8 @@ cmsBool _cmsAdaptationMatrix(cmsMAT3* r, const cmsMAT3* ConeMatrix, const cmsC cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePoint, const cmsCIExyYTRIPLE* Primaries); +// thread-safe gettime +cmsBool _cmsGetTime(struct tm* ptr_time); + #define _lcms_internal_H #endif diff --git a/src/java.desktop/share/native/liblcms/lcms2_plugin.h b/src/java.desktop/share/native/liblcms/lcms2_plugin.h index 61e963ff5f8..1dc1a4661e2 100644 --- a/src/java.desktop/share/native/liblcms/lcms2_plugin.h +++ b/src/java.desktop/share/native/liblcms/lcms2_plugin.h @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2020 Marti Maria Saguer +// Copyright (c) 1998-2022 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"), @@ -53,7 +53,7 @@ //--------------------------------------------------------------------------------- // // This is the plug-in header file. Normal LittleCMS clients should not use it. -// It is provided for plug-in writters that may want to access the support +// It is provided for plug-in writers that may want to access the support // functions to do low level operations. All plug-in related structures // are defined here. Including this file forces to include the standard API too. @@ -238,6 +238,7 @@ typedef void* (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data); #define cmsPluginOptimizationSig 0x6F707448 // 'optH' #define cmsPluginTransformSig 0x7A666D48 // 'xfmH' #define cmsPluginMutexSig 0x6D747A48 // 'mtxH' +#define cmsPluginParalellizationSig 0x70726C48 // 'prlH typedef struct _cmsPluginBaseStruct { @@ -625,7 +626,7 @@ typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // const void* InputBuffer, void* OutputBuffer, cmsUInt32Number Size, - cmsUInt32Number Stride); // Stride in bytes to the next plana in planar formats + cmsUInt32Number Stride); // Stride in bytes to the next plane in planar formats typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo, @@ -698,6 +699,25 @@ CMSAPI void CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx); CMSAPI cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx); CMSAPI void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx); +//---------------------------------------------------------------------------------------------------------- +// Parallelization + +CMSAPI _cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo); +CMSAPI cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo); +CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo); + +// Let's plug-in to guess the best number of workers +#define CMS_GUESS_MAX_WORKERS -1 + +typedef struct { + cmsPluginBase base; + + cmsInt32Number MaxWorkers; // Number of starts to do as maximum + cmsUInt32Number WorkerFlags; // Reserved + _cmsTransform2Fn SchedulerFn; // callback to setup functions + +} cmsPluginParalellization; + #ifndef CMS_USE_CPP_API # ifdef __cplusplus From f4eccbe1c704719e14ea05539c752e5492ce1520 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Jan 2023 14:11:28 +0000 Subject: [PATCH 080/205] 8296619: Upgrade jQuery to 3.6.1 Reviewed-by: mbaesken Backport-of: ead308168e3c240c85f62d7030efed28dea43b34 --- .../doclets/formats/html/HtmlDoclet.java | 2 +- .../html/resources/jquery/jquery-3.6.0.min.js | 2 - .../{jquery-3.6.0.js => jquery-3.6.1.js} | 214 ++++++++++-------- .../html/resources/jquery/jquery-3.6.1.min.js | 2 + .../doclets/toolkit/util/DocPaths.java | 2 +- src/jdk.javadoc/share/legal/jquery.md | 6 +- .../javadoc/doclet/testSearch/TestSearch.java | 4 +- .../jdk/javadoc/tool/api/basic/APITest.java | 2 +- .../tools/javadoc/api/basic/APITest.java | 2 +- 9 files changed, 132 insertions(+), 104 deletions(-) delete mode 100644 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.0.min.js rename src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/{jquery-3.6.0.js => jquery-3.6.1.js} (98%) create mode 100644 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.1.min.js diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java index a224f06f864..731c9b515d7 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java @@ -210,7 +210,7 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) private void copyJqueryFiles() throws DocletException { List files = Arrays.asList( - "jquery-3.6.0.min.js", + "jquery-3.6.1.min.js", "jquery-ui.min.js", "jquery-ui.min.css", "external/jquery/jquery.js", diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.0.min.js b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.0.min.js deleted file mode 100644 index c4c6022f298..00000000000 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.0.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="
",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0 to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) + // Prioritize #id over to avoid XSS via location.hash (trac-9521) + // Strict HTML recognition (trac-11290: must start with <) // Shortcut simple #id case for speed rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, @@ -4087,7 +4087,7 @@ jQuery.extend( { isReady: false, // A counter to track how many items to wait for before - // the ready event fires. See #6781 + // the ready event fires. See trac-6781 readyWait: 1, // Handle when the DOM is ready @@ -4215,7 +4215,7 @@ function fcamelCase( _all, letter ) { // Convert dashed to camelCase; used by the css and data modules // Support: IE <=9 - 11, Edge 12 - 15 -// Microsoft forgot to hump their vendor prefix (#9572) +// Microsoft forgot to hump their vendor prefix (trac-9572) function camelCase( string ) { return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); } @@ -4251,7 +4251,7 @@ Data.prototype = { value = {}; // We can accept data for non-element nodes in modern browsers, - // but we should not, see #8335. + // but we should not, see trac-8335. // Always return an empty object. if ( acceptData( owner ) ) { @@ -4490,7 +4490,7 @@ jQuery.fn.extend( { while ( i-- ) { // Support: IE 11 only - // The attrs elements can be null (#14894) + // The attrs elements can be null (trac-14894) if ( attrs[ i ] ) { name = attrs[ i ].name; if ( name.indexOf( "data-" ) === 0 ) { @@ -4913,9 +4913,9 @@ var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); input = document.createElement( "input" ); // Support: Android 4.0 - 4.3 only - // Check state lost if the name is set (#11217) + // Check state lost if the name is set (trac-11217) // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) + // `name` and `type` must use .setAttribute for WWA (trac-14901) input.setAttribute( "type", "radio" ); input.setAttribute( "checked", "checked" ); input.setAttribute( "name", "t" ); @@ -4939,7 +4939,7 @@ var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); } )(); -// We have to close these tags to support XHTML (#13200) +// We have to close these tags to support XHTML (trac-13200) var wrapMap = { // XHTML parsers do not magically insert elements in the @@ -4965,7 +4965,7 @@ if ( !support.option ) { function getAll( context, tag ) { // Support: IE <=9 - 11 only - // Use typeof to avoid zero-argument method invocation on host objects (#15151) + // Use typeof to avoid zero-argument method invocation on host objects (trac-15151) var ret; if ( typeof context.getElementsByTagName !== "undefined" ) { @@ -5048,7 +5048,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) { // Remember the top-level container tmp = fragment.firstChild; - // Ensure the created nodes are orphaned (#12392) + // Ensure the created nodes are orphaned (trac-12392) tmp.textContent = ""; } } @@ -5469,15 +5469,15 @@ jQuery.event = { for ( ; cur !== this; cur = cur.parentNode || this ) { - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + // Don't check non-elements (trac-13208) + // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764) if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { matchedHandlers = []; matchedSelectors = {}; for ( i = 0; i < delegateCount; i++ ) { handleObj = handlers[ i ]; - // Don't conflict with Object.prototype properties (#13203) + // Don't conflict with Object.prototype properties (trac-13203) sel = handleObj.selector + " "; if ( matchedSelectors[ sel ] === undefined ) { @@ -5731,7 +5731,7 @@ jQuery.Event = function( src, props ) { // Create target properties // Support: Safari <=6 - 7 only - // Target should not be a text node (#504, #13143) + // Target should not be a text node (trac-504, trac-13143) this.target = ( src.target && src.target.nodeType === 3 ) ? src.target.parentNode : src.target; @@ -5854,10 +5854,10 @@ jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateTyp return true; }, - // Suppress native focus or blur as it's already being fired - // in leverageNative. - _default: function() { - return true; + // Suppress native focus or blur if we're currently inside + // a leveraged native-event stack + _default: function( event ) { + return dataPriv.get( event.target, type ); }, delegateType: delegateType @@ -5956,7 +5956,8 @@ var // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, - rcleanScript = /^\s*\s*$/g; + + rcleanScript = /^\s*\s*$/g; // Prefer a tbody over its parent table for containing new rows function manipulationTarget( elem, content ) { @@ -6070,7 +6071,7 @@ function domManip( collection, args, callback, ignored ) { // Use the original fragment for the last item // instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). + // being emptied incorrectly in certain situations (trac-8070). for ( ; i < l; i++ ) { node = fragment; @@ -6111,6 +6112,12 @@ function domManip( collection, args, callback, ignored ) { }, doc ); } } else { + + // Unwrap a CDATA section containing script contents. This shouldn't be + // needed as in XML documents they're already not visible when + // inspecting element contents and in HTML documents they have no + // meaning but we're preserving that logic for backwards compatibility. + // This will be removed completely in 4.0. See gh-4904. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); } } @@ -6393,9 +6400,12 @@ jQuery.each( { } ); var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); +var rcustomProp = /^--/; + + var getStyles = function( elem ) { - // Support: IE <=11 only, Firefox <=30 (#15098, #14150) + // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150) // IE throws on elements created in popups // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" var view = elem.ownerDocument.defaultView; @@ -6430,6 +6440,15 @@ var swap = function( elem, options, callback ) { var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); +var whitespace = "[\\x20\\t\\r\\n\\f]"; + + +var rtrimCSS = new RegExp( + "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", + "g" +); + + ( function() { @@ -6495,7 +6514,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); } // Support: IE <=9 - 11 only - // Style of cloned element affects source element cloned (#8908) + // Style of cloned element affects source element cloned (trac-8908) div.style.backgroundClip = "content-box"; div.cloneNode( true ).style.backgroundClip = ""; support.clearCloneStyle = div.style.backgroundClip === "content-box"; @@ -6575,6 +6594,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); function curCSS( elem, name, computed ) { var width, minWidth, maxWidth, ret, + isCustomProp = rcustomProp.test( name ), // Support: Firefox 51+ // Retrieving style before computed somehow @@ -6585,11 +6605,22 @@ function curCSS( elem, name, computed ) { computed = computed || getStyles( elem ); // getPropertyValue is needed for: - // .css('filter') (IE 9 only, #12537) - // .css('--customProperty) (#3144) + // .css('filter') (IE 9 only, trac-12537) + // .css('--customProperty) (gh-3144) if ( computed ) { ret = computed.getPropertyValue( name ) || computed[ name ]; + // trim whitespace for custom property (issue gh-4926) + if ( isCustomProp ) { + + // rtrim treats U+000D CARRIAGE RETURN and U+000C FORM FEED + // as whitespace while CSS does not, but this is not a problem + // because CSS preprocessing replaces them with U+000A LINE FEED + // (which *is* CSS whitespace) + // https://www.w3.org/TR/css-syntax-3/#input-preprocessing + ret = ret.replace( rtrimCSS, "$1" ); + } + if ( ret === "" && !isAttached( elem ) ) { ret = jQuery.style( elem, name ); } @@ -6685,7 +6716,6 @@ var // except "table", "table-cell", or "table-caption" // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rcustomProp = /^--/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssNormalTransform = { letterSpacing: "0", @@ -6921,15 +6951,15 @@ jQuery.extend( { if ( value !== undefined ) { type = typeof value; - // Convert "+=" or "-=" to relative numbers (#7345) + // Convert "+=" or "-=" to relative numbers (trac-7345) if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { value = adjustCSS( elem, name, ret ); - // Fixes bug #9237 + // Fixes bug trac-9237 type = "number"; } - // Make sure that null and NaN values aren't set (#7116) + // Make sure that null and NaN values aren't set (trac-7116) if ( value == null || value !== value ) { return; } @@ -7553,7 +7583,7 @@ function Animation( elem, properties, options ) { remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), // Support: Android 2.3 only - // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) + // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497) temp = remaining / animation.duration || 0, percent = 1 - temp, index = 0, @@ -7943,7 +7973,6 @@ jQuery.fx.speeds = { // Based off of the plugin by Clint Helfers, with permission. -// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ jQuery.fn.delay = function( time, type ) { time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; type = type || "fx"; @@ -8168,8 +8197,7 @@ jQuery.extend( { // Support: IE <=9 - 11 only // elem.tabIndex doesn't always return the // correct value when it hasn't been explicitly set - // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - // Use proper attribute retrieval(#12072) + // Use proper attribute retrieval (trac-12072) var tabindex = jQuery.find.attr( elem, "tabindex" ); if ( tabindex ) { @@ -8273,8 +8301,7 @@ function classesToArray( value ) { jQuery.fn.extend( { addClass: function( value ) { - var classes, elem, cur, curValue, clazz, j, finalValue, - i = 0; + var classNames, cur, curValue, className, i, finalValue; if ( isFunction( value ) ) { return this.each( function( j ) { @@ -8282,36 +8309,35 @@ jQuery.fn.extend( { } ); } - classes = classesToArray( value ); + classNames = classesToArray( value ); - if ( classes.length ) { - while ( ( elem = this[ i++ ] ) ) { - curValue = getClass( elem ); - cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + if ( classNames.length ) { + return this.each( function() { + curValue = getClass( this ); + cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); if ( cur ) { - j = 0; - while ( ( clazz = classes[ j++ ] ) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; + if ( cur.indexOf( " " + className + " " ) < 0 ) { + cur += className + " "; } } // Only assign if different to avoid unneeded rendering. finalValue = stripAndCollapse( cur ); if ( curValue !== finalValue ) { - elem.setAttribute( "class", finalValue ); + this.setAttribute( "class", finalValue ); } } - } + } ); } return this; }, removeClass: function( value ) { - var classes, elem, cur, curValue, clazz, j, finalValue, - i = 0; + var classNames, cur, curValue, className, i, finalValue; if ( isFunction( value ) ) { return this.each( function( j ) { @@ -8323,45 +8349,42 @@ jQuery.fn.extend( { return this.attr( "class", "" ); } - classes = classesToArray( value ); + classNames = classesToArray( value ); - if ( classes.length ) { - while ( ( elem = this[ i++ ] ) ) { - curValue = getClass( elem ); + if ( classNames.length ) { + return this.each( function() { + curValue = getClass( this ); // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); if ( cur ) { - j = 0; - while ( ( clazz = classes[ j++ ] ) ) { + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) > -1 ) { - cur = cur.replace( " " + clazz + " ", " " ); + while ( cur.indexOf( " " + className + " " ) > -1 ) { + cur = cur.replace( " " + className + " ", " " ); } } // Only assign if different to avoid unneeded rendering. finalValue = stripAndCollapse( cur ); if ( curValue !== finalValue ) { - elem.setAttribute( "class", finalValue ); + this.setAttribute( "class", finalValue ); } } - } + } ); } return this; }, toggleClass: function( value, stateVal ) { - var type = typeof value, + var classNames, className, i, self, + type = typeof value, isValidValue = type === "string" || Array.isArray( value ); - if ( typeof stateVal === "boolean" && isValidValue ) { - return stateVal ? this.addClass( value ) : this.removeClass( value ); - } - if ( isFunction( value ) ) { return this.each( function( i ) { jQuery( this ).toggleClass( @@ -8371,17 +8394,20 @@ jQuery.fn.extend( { } ); } - return this.each( function() { - var className, i, self, classNames; + if ( typeof stateVal === "boolean" && isValidValue ) { + return stateVal ? this.addClass( value ) : this.removeClass( value ); + } + + classNames = classesToArray( value ); + return this.each( function() { if ( isValidValue ) { // Toggle individual class names - i = 0; self = jQuery( this ); - classNames = classesToArray( value ); - while ( ( className = classNames[ i++ ] ) ) { + for ( i = 0; i < classNames.length; i++ ) { + className = classNames[ i ]; // Check each className given, space separated list if ( self.hasClass( className ) ) { @@ -8515,7 +8541,7 @@ jQuery.extend( { val : // Support: IE <=10 - 11 only - // option.text throws exceptions (#14686, #14858) + // option.text throws exceptions (trac-14686, trac-14858) // Strip and collapse whitespace // https://html.spec.whatwg.org/#strip-and-collapse-whitespace stripAndCollapse( jQuery.text( elem ) ); @@ -8542,7 +8568,7 @@ jQuery.extend( { option = options[ i ]; // Support: IE <=9 only - // IE8-9 doesn't update selected after form reset (#2551) + // IE8-9 doesn't update selected after form reset (trac-2551) if ( ( option.selected || i === index ) && // Don't return options that are disabled or in a disabled optgroup @@ -8685,8 +8711,8 @@ jQuery.extend( jQuery.event, { return; } - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + // Determine event propagation path in advance, per W3C events spec (trac-9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724) if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { bubbleType = special.delegateType || type; @@ -8738,7 +8764,7 @@ jQuery.extend( jQuery.event, { acceptData( elem ) ) { // Call a native DOM method on the target with the same name as the event. - // Don't do default actions on window, that's where global variables be (#6170) + // Don't do default actions on window, that's where global variables be (trac-6170) if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method @@ -9012,7 +9038,7 @@ var rantiCache = /([?&])_=[^&]*/, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, - // #7653, #8125, #8152: local protocol detection + // trac-7653, trac-8125, trac-8152: local protocol detection rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, @@ -9035,7 +9061,7 @@ var */ transports = {}, - // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression + // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression allTypes = "*/".concat( "*" ), // Anchor tag for parsing the document origin @@ -9106,7 +9132,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX // A special extend for ajax options // that takes "flat" options (not to be deep extended) -// Fixes #9887 +// Fixes trac-9887 function ajaxExtend( target, src ) { var key, deep, flatOptions = jQuery.ajaxSettings.flatOptions || {}; @@ -9517,12 +9543,12 @@ jQuery.extend( { deferred.promise( jqXHR ); // Add protocol if not provided (prefilters might expect it) - // Handle falsy url in the settings object (#10093: consistency with old signature) + // Handle falsy url in the settings object (trac-10093: consistency with old signature) // We also use the url parameter if available s.url = ( ( url || s.url || location.href ) + "" ) .replace( rprotocol, location.protocol + "//" ); - // Alias method option to type as per ticket #12004 + // Alias method option to type as per ticket trac-12004 s.type = options.method || options.type || s.method || s.type; // Extract dataTypes list @@ -9565,7 +9591,7 @@ jQuery.extend( { } // We can fire global events as of now if asked to - // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) + // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118) fireGlobals = jQuery.event && s.global; // Watch for a new set of requests @@ -9594,7 +9620,7 @@ jQuery.extend( { if ( s.data && ( s.processData || typeof s.data === "string" ) ) { cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; - // #9682: remove data so that it's not used in an eventual retry + // trac-9682: remove data so that it's not used in an eventual retry delete s.data; } @@ -9867,7 +9893,7 @@ jQuery._evalUrl = function( url, options, doc ) { return jQuery.ajax( { url: url, - // Make this explicit, since user can override this through ajaxSetup (#11264) + // Make this explicit, since user can override this through ajaxSetup (trac-11264) type: "GET", dataType: "script", cache: true, @@ -9976,7 +10002,7 @@ var xhrSuccessStatus = { 0: 200, // Support: IE <=9 only - // #1450: sometimes IE returns 1223 when it should be 204 + // trac-1450: sometimes IE returns 1223 when it should be 204 1223: 204 }, xhrSupported = jQuery.ajaxSettings.xhr(); @@ -10048,7 +10074,7 @@ jQuery.ajaxTransport( function( options ) { } else { complete( - // File: protocol always yields status 0; see #8605, #14207 + // File: protocol always yields status 0; see trac-8605, trac-14207 xhr.status, xhr.statusText ); @@ -10109,7 +10135,7 @@ jQuery.ajaxTransport( function( options ) { xhr.send( options.hasContent && options.data || null ); } catch ( e ) { - // #14683: Only rethrow if this hasn't been notified as an error yet + // trac-14683: Only rethrow if this hasn't been notified as an error yet if ( callback ) { throw e; } @@ -10753,7 +10779,9 @@ jQuery.each( // Support: Android <=4.0 only // Make sure we trim BOM and NBSP -var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; +// Require that the "whitespace run" starts from a non-whitespace +// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position. +var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; // Bind a function to a context, optionally partially applying any // arguments. @@ -10820,7 +10848,7 @@ jQuery.isNumeric = function( obj ) { jQuery.trim = function( text ) { return text == null ? "" : - ( text + "" ).replace( rtrim, "" ); + ( text + "" ).replace( rtrim, "$1" ); }; @@ -10868,8 +10896,8 @@ jQuery.noConflict = function( deep ) { }; // Expose jQuery and $ identifiers, even in AMD -// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) -// and CommonJS for browser emulators (#13566) +// (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557) +// and CommonJS for browser emulators (trac-13566) if ( typeof noGlobal === "undefined" ) { window.jQuery = window.$ = jQuery; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.1.min.js b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.1.min.js new file mode 100644 index 00000000000..2c69bc908b1 --- /dev/null +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/jquery-3.6.1.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,y=n.hasOwnProperty,a=y.toString,l=a.call(Object),v={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&v(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!y||!y.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ve(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ye(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ve(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],y=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||y.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||y.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||y.push(".#.+[+~]"),e.querySelectorAll("\\\f"),y.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),y=y.length&&new RegExp(y.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),v=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&v(p,e)?-1:t==C||t.ownerDocument==p&&v(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!y||!y.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),v.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",v.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",v.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),v.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(v.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0\n", "\n", "\n", - "\n", + "\n", "", "var pathtoroot = \"./\";\n" + "var useModuleDirectories = " + moduleDirectoriesVar + ";\n" @@ -593,7 +593,7 @@ void checkJqueryAndImageFiles(boolean expectedOutput) { checkFiles(expectedOutput, "search.js", "jquery-ui.overrides.css", - "jquery/jquery-3.6.0.min.js", + "jquery/jquery-3.6.1.min.js", "jquery/jquery-ui.min.js", "jquery/jquery-ui.min.css", "jquery/external/jquery/jquery.js", diff --git a/test/langtools/jdk/javadoc/tool/api/basic/APITest.java b/test/langtools/jdk/javadoc/tool/api/basic/APITest.java index 9838f1a6ddf..6147bfc18c9 100644 --- a/test/langtools/jdk/javadoc/tool/api/basic/APITest.java +++ b/test/langtools/jdk/javadoc/tool/api/basic/APITest.java @@ -198,7 +198,7 @@ protected void error(String msg) { "help-doc.html", "index-all.html", "index.html", - "jquery/jquery-3.6.0.min.js", + "jquery/jquery-3.6.1.min.js", "jquery/jquery-ui.min.js", "jquery/jquery-ui.min.css", "jquery/external/jquery/jquery.js", diff --git a/test/langtools/tools/javadoc/api/basic/APITest.java b/test/langtools/tools/javadoc/api/basic/APITest.java index 9838f1a6ddf..6147bfc18c9 100644 --- a/test/langtools/tools/javadoc/api/basic/APITest.java +++ b/test/langtools/tools/javadoc/api/basic/APITest.java @@ -198,7 +198,7 @@ protected void error(String msg) { "help-doc.html", "index-all.html", "index.html", - "jquery/jquery-3.6.0.min.js", + "jquery/jquery-3.6.1.min.js", "jquery/jquery-ui.min.js", "jquery/jquery-ui.min.css", "jquery/external/jquery/jquery.js", From 0422f0585a808d33bc5b1aac54f443ddd7c0a23c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 19 Jan 2023 21:24:06 +0000 Subject: [PATCH 081/205] 8300642: [17u,11u] Fix DEFAULT_PROMOTED_VERSION_PRE=ea for -dev Reviewed-by: clanger Backport-of: b3e16fc287b6656e0227b30e698f544c3998843d --- make/autoconf/version-numbers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index 70d0edd2634..6ca0433951f 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -37,7 +37,7 @@ DEFAULT_VERSION_DATE=2023-04-18 DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" -DEFAULT_PROMOTED_VERSION_PRE= +DEFAULT_PROMOTED_VERSION_PRE=ea LAUNCHER_NAME=openjdk PRODUCT_NAME=OpenJDK From c9ce60b9d0b36ed9e563745dd219dd7a438149ac Mon Sep 17 00:00:00 2001 From: Autumn Capasso Date: Mon, 23 Jan 2023 21:08:21 +0000 Subject: [PATCH 082/205] 8261352: Create implementation for component peer for all the components who should be ignored in a11y interactions Backport-of: e543a5009847a8e3ccbb047b93e3cc6fb261ef8c --- .../awt/JavaComponentAccessibility.m | 36 ---------- .../awt/a11y/CommonComponentAccessibility.h | 1 + .../awt/a11y/CommonComponentAccessibility.m | 65 ++++++++++++++++++- .../awt/a11y/IgnoreAccessibility.h | 35 ++++++++++ .../awt/a11y/IgnoreAccessibility.m | 37 +++++++++++ 5 files changed, 137 insertions(+), 37 deletions(-) create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.h create mode 100644 src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.m diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m index 2775d0136b4..49985409ca0 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m @@ -90,9 +90,6 @@ #define GET_CACCESSIBLE_CLASS_RETURN(ret) \ GET_CLASS_RETURN(sjc_CAccessible, "sun/lwawt/macosx/CAccessible", ret); - -static jobject sAccessibilityClass = NULL; - // sAttributeNamesForRoleCache holds the names of the attributes to which each java // AccessibleRole responds (see AccessibleRole.java). // This cache is queried before attempting to access a given attribute for a particular role. @@ -292,39 +289,6 @@ + (void)initialize if (sRoles == nil) { initializeRoles(); } - - if (sAccessibilityClass == NULL) { - JNIEnv *env = [ThreadUtilities getJNIEnv]; - - GET_CACCESSIBILITY_CLASS(); - DECLARE_STATIC_METHOD(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;"); - -#ifdef JAVA_AX_NO_IGNORES - NSArray *ignoredKeys = [NSArray array]; -#else - NSArray *ignoredKeys = [sRoles allKeysForObject:JavaAccessibilityIgnore]; -#endif - jobjectArray result = NULL; - jsize count = [ignoredKeys count]; - - DECLARE_CLASS(jc_String, "java/lang/String"); - result = (*env)->NewObjectArray(env, count, jc_String, NULL); - CHECK_EXCEPTION(); - if (!result) { - NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__); - return; - } - - NSInteger i; - for (i = 0; i < count; i++) { - jstring jString = NSStringToJavaString(env, [ignoredKeys objectAtIndex:i]); - (*env)->SetObjectArrayElement(env, result, i, jString); - (*env)->DeleteLocalRef(env, jString); - } - - sAccessibilityClass = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibility, result); // AWT_THREADING Safe (known object) - CHECK_EXCEPTION(); - } } + (void)postFocusChanged:(id)message diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h index adce4f5e38a..5124b9bdd13 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.h @@ -37,6 +37,7 @@ - (NSRect)accessibilityFrame; - (nullable id)accessibilityParent; - (BOOL)performAccessibleAction:(int)index; +- (BOOL)isAccessibilityElement; @end #endif diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 7be8ab4cffd..340e8836307 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -36,6 +36,8 @@ "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;", ret); static NSMutableDictionary * _Nullable rolesMap; +NSString *const IgnoreClassName = @"IgnoreAccessibility"; +static jobject sAccessibilityClass = NULL; /* * Common ancestor for all the accessibility peers that implements the new method-based accessibility API @@ -46,7 +48,7 @@ + (void) initializeRolesMap { /* * Here we should keep all the mapping between the accessibility roles and implementing classes */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:8]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:26]; [rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; @@ -56,6 +58,63 @@ + (void) initializeRolesMap { [rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"]; [rolesMap setObject:@"RadiobuttonAccessibility" forKey:@"radiobutton"]; [rolesMap setObject:@"CheckboxAccessibility" forKey:@"checkbox"]; + + /* + * All the components below should be ignored by the accessibility subsystem, + * If any of the enclosed component asks for a parent the first ancestor + * participating in accessibility exchange should be returned. + */ + [rolesMap setObject:IgnoreClassName forKey:@"alert"]; + [rolesMap setObject:IgnoreClassName forKey:@"colorchooser"]; + [rolesMap setObject:IgnoreClassName forKey:@"desktoppane"]; + [rolesMap setObject:IgnoreClassName forKey:@"dialog"]; + [rolesMap setObject:IgnoreClassName forKey:@"directorypane"]; + [rolesMap setObject:IgnoreClassName forKey:@"filechooser"]; + [rolesMap setObject:IgnoreClassName forKey:@"filler"]; + [rolesMap setObject:IgnoreClassName forKey:@"fontchooser"]; + [rolesMap setObject:IgnoreClassName forKey:@"frame"]; + [rolesMap setObject:IgnoreClassName forKey:@"glasspane"]; + [rolesMap setObject:IgnoreClassName forKey:@"layeredpane"]; + [rolesMap setObject:IgnoreClassName forKey:@"optionpane"]; + [rolesMap setObject:IgnoreClassName forKey:@"panel"]; + [rolesMap setObject:IgnoreClassName forKey:@"rootpane"]; + [rolesMap setObject:IgnoreClassName forKey:@"separator"]; + [rolesMap setObject:IgnoreClassName forKey:@"tooltip"]; + [rolesMap setObject:IgnoreClassName forKey:@"viewport"]; + [rolesMap setObject:IgnoreClassName forKey:@"window"]; + + /* + * Initialize CAccessibility instance + */ +#ifdef JAVA_AX_NO_IGNORES + NSArray *ignoredKeys = [NSArray array]; +#else + NSArray *ignoredKeys = [rolesMap allKeysForObject:IgnoreClassName]; +#endif + + JNIEnv *env = [ThreadUtilities getJNIEnv]; + GET_CACCESSIBILITY_CLASS(); + DECLARE_STATIC_METHOD(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;"); + jobjectArray result = NULL; + jsize count = [ignoredKeys count]; + + DECLARE_CLASS(jc_String, "java/lang/String"); + result = (*env)->NewObjectArray(env, count, jc_String, NULL); + CHECK_EXCEPTION(); + if (!result) { + NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__); + return; + } + + NSInteger i; + for (i = 0; i < count; i++) { + jstring jString = NSStringToJavaString(env, [ignoredKeys objectAtIndex:i]); + (*env)->SetObjectArrayElement(env, result, i, jString); + (*env)->DeleteLocalRef(env, jString); + } + + sAccessibilityClass = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibility, result); + CHECK_EXCEPTION(); } /* @@ -117,4 +176,8 @@ - (BOOL)performAccessibleAction:(int)index return TRUE; } +- (BOOL)isAccessibilityElement { + return YES; +} + @end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.h new file mode 100644 index 00000000000..ef61ef71ca6 --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "JavaComponentAccessibility.h" +#import "CommonComponentAccessibility.h" + +#import + +@interface IgnoreAccessibility : CommonComponentAccessibility { + +}; +- (BOOL)isAccessibilityElement; +@end diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.m new file mode 100644 index 00000000000..0811c7003ab --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/IgnoreAccessibility.m @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#import "IgnoreAccessibility.h" + +/* + * Indicates that component does not participate in accessibility exchange + */ +@implementation IgnoreAccessibility +- (BOOL)isAccessibilityElement +{ + return NO; +} + +@end From e4fdd0391733756f5b898371a66b38869d625c77 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:35:17 +0000 Subject: [PATCH 083/205] 8209115: adjust libsplashscreen linux ppc64le builds for easier libpng update Backport-of: 8044814e305c53ff22ec1831411481c4f4dc1f62 --- make/lib/Awt2dLibraries.gmk | 6 ++++++ .../share/native/libsplashscreen/libpng/pngpriv.h | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk index 939cb3a4dde..b3cbdf20505 100644 --- a/make/lib/Awt2dLibraries.gmk +++ b/make/lib/Awt2dLibraries.gmk @@ -826,6 +826,12 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \ -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_IMPLEMENTATION=0 + ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc) + LIBSPLASHSCREEN_CFLAGS += -DPNG_POWERPC_VSX_OPT=0 + endif + endif + ifeq ($(OPENJDK_TARGET_OS), macosx) LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h index 5f704260305..73e1e9371a3 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h @@ -293,13 +293,10 @@ # endif #endif /* PNG_MIPS_MSA_OPT > 0 */ -#ifdef PNG_POWERPC_VSX_API_SUPPORTED #if PNG_POWERPC_VSX_OPT > 0 # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx # define PNG_POWERPC_VSX_IMPLEMENTATION 1 #endif -#endif - /* Is this a build of a DLL where compilation of the object modules requires From f4c5bdf0a51b043e6327d175b2c0bd75a4ec31d8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:40:44 +0000 Subject: [PATCH 084/205] 8272985: Reference discovery is confused about atomicity and degree of parallelism Reviewed-by: phh Backport-of: fb5b144eca761d4b4c667efe05ca638536c065ac --- .../share/gc/shared/referenceProcessor.cpp | 85 +++++++++++-------- .../share/gc/shared/referenceProcessor.hpp | 10 ++- .../gc/shared/referenceProcessor.inline.hpp | 5 ++ 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index 26bc2c8924e..252435f4a76 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -1022,34 +1022,61 @@ inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt) return list; } -inline void -ReferenceProcessor::add_to_discovered_list_mt(DiscoveredList& refs_list, - oop obj, - HeapWord* discovered_addr) { - assert(_discovery_is_mt, "!_discovery_is_mt should have been handled by caller"); - // First we must make sure this object is only enqueued once. CAS in a non null - // discovered_addr. +inline bool ReferenceProcessor::set_discovered_link(HeapWord* discovered_addr, oop next_discovered) { + return discovery_is_mt() ? set_discovered_link_mt(discovered_addr, next_discovered) + : set_discovered_link_st(discovered_addr, next_discovered); +} + +inline void ReferenceProcessor::add_to_discovered_list(DiscoveredList& refs_list, + oop obj, + HeapWord* discovered_addr) { oop current_head = refs_list.head(); - // The last ref must have its discovered field pointing to itself. + // Prepare value to put into the discovered field. The last ref must have its + // discovered field pointing to itself. oop next_discovered = (current_head != NULL) ? current_head : obj; - oop retest = HeapAccess::oop_atomic_cmpxchg(next_discovered, discovered_addr, oop(NULL)); + bool added = set_discovered_link(discovered_addr, next_discovered); + if (added) { + // We can always add the object without synchronization: every thread has its + // own list head. + refs_list.add_as_head(obj); + log_develop_trace(gc, ref)("Discovered reference (%s) (" INTPTR_FORMAT ": %s)", + discovery_is_mt() ? "mt" : "st", p2i(obj), obj->klass()->internal_name()); + } else { + log_develop_trace(gc, ref)("Already discovered reference (mt) (" INTPTR_FORMAT ": %s)", + p2i(obj), obj->klass()->internal_name()); + } +} - if (retest == NULL) { - // This thread just won the right to enqueue the object. - // We have separate lists for enqueueing, so no synchronization - // is necessary. - refs_list.set_head(obj); - refs_list.inc_length(1); +inline bool ReferenceProcessor::set_discovered_link_st(HeapWord* discovered_addr, + oop next_discovered) { + assert(!discovery_is_mt(), "must be"); - log_develop_trace(gc, ref)("Discovered reference (mt) (" INTPTR_FORMAT ": %s)", - p2i(obj), obj->klass()->internal_name()); + if (discovery_is_atomic()) { + // Do a raw store here: the field will be visited later when processing + // the discovered references. + RawAccess<>::oop_store(discovered_addr, next_discovered); } else { - // If retest was non NULL, another thread beat us to it: - // The reference has already been discovered... - log_develop_trace(gc, ref)("Already discovered reference (" INTPTR_FORMAT ": %s)", - p2i(obj), obj->klass()->internal_name()); + HeapAccess::oop_store(discovered_addr, next_discovered); } + // Always successful. + return true; +} + +inline bool ReferenceProcessor::set_discovered_link_mt(HeapWord* discovered_addr, + oop next_discovered) { + assert(discovery_is_mt(), "must be"); + + // We must make sure this object is only enqueued once. Try to CAS into the discovered_addr. + oop retest; + if (discovery_is_atomic()) { + // Try a raw store here, still making sure that we enqueue only once: the field + // will be visited later when processing the discovered references. + retest = RawAccess<>::oop_atomic_cmpxchg(next_discovered, discovered_addr, oop(NULL)); + } else { + retest = HeapAccess::oop_atomic_cmpxchg(next_discovered, discovered_addr, oop(NULL)); + } + return retest == NULL; } #ifndef PRODUCT @@ -1184,22 +1211,8 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) { return false; // nothing special needs to be done } - if (_discovery_is_mt) { - add_to_discovered_list_mt(*list, obj, discovered_addr); - } else { - // We do a raw store here: the field will be visited later when processing - // the discovered references. - oop current_head = list->head(); - // The last ref must have its discovered field pointing to itself. - oop next_discovered = (current_head != NULL) ? current_head : obj; + add_to_discovered_list(*list, obj, discovered_addr); - assert(discovered == NULL, "control point invariant"); - RawAccess<>::oop_store(discovered_addr, next_discovered); - list->set_head(obj); - list->inc_length(1); - - log_develop_trace(gc, ref)("Discovered reference (" INTPTR_FORMAT ": %s)", p2i(obj), obj->klass()->internal_name()); - } assert(oopDesc::is_oop(obj), "Discovered a bad reference"); verify_referent(obj); return true; diff --git a/src/hotspot/share/gc/shared/referenceProcessor.hpp b/src/hotspot/share/gc/shared/referenceProcessor.hpp index 6bb8abd4936..e4f1f627269 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.hpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp @@ -45,6 +45,7 @@ class DiscoveredList { return UseCompressedOops ? (HeapWord*)&_compressed_head : (HeapWord*)&_oop_head; } + inline void add_as_head(oop o); inline void set_head(oop o); inline bool is_empty() const; size_t length() { return _len; } @@ -359,8 +360,13 @@ class ReferenceProcessor : public ReferenceDiscoverer { return id; } DiscoveredList* get_discovered_list(ReferenceType rt); - inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj, - HeapWord* discovered_addr); + inline bool set_discovered_link(HeapWord* discovered_addr, oop next_discovered); + inline void add_to_discovered_list(DiscoveredList& refs_list, oop obj, + HeapWord* discovered_addr); + inline bool set_discovered_link_st(HeapWord* discovered_addr, + oop next_discovered); + inline bool set_discovered_link_mt(HeapWord* discovered_addr, + oop next_discovered); void clear_discovered_references(DiscoveredList& refs_list); diff --git a/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp b/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp index 4a981649fc6..8c1422398a6 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp @@ -34,6 +34,11 @@ oop DiscoveredList::head() const { _oop_head; } +void DiscoveredList::add_as_head(oop o) { + set_head(o); + inc_length(1); +} + void DiscoveredList::set_head(oop o) { if (UseCompressedOops) { // Must compress the head ptr. From d1fb7b25c8921c40a562dcdb14cf5568831cc920 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:49:06 +0000 Subject: [PATCH 085/205] 8285690: CloneableReference subtest should not throw CloneNotSupportedException Backport-of: 2d8d1402147f6ddd15732ce7098a8438317a2681 --- test/jdk/java/lang/ref/ReferenceClone.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/lang/ref/ReferenceClone.java b/test/jdk/java/lang/ref/ReferenceClone.java index bd1ead81bec..ada5d73fa4a 100644 --- a/test/jdk/java/lang/ref/ReferenceClone.java +++ b/test/jdk/java/lang/ref/ReferenceClone.java @@ -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,7 +23,7 @@ /* * @test - * @bug 8201793 + * @bug 8201793 8285690 * @summary Test Reference::clone to throw CloneNotSupportedException */ @@ -47,7 +47,9 @@ public void test() { CloneableReference ref = new CloneableReference(o); try { ref.clone(); - } catch (CloneNotSupportedException e) {} + } catch (CloneNotSupportedException e) { + throw new RuntimeException("CloneableReference::clone should not throw CloneNotSupportedException"); + } } private void assertCloneNotSupported(CloneableRef ref) { From f999efd282f9f97bf6a5f6bce3fe0a8710515aa4 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:51:44 +0000 Subject: [PATCH 086/205] 8287180: Update IANA Language Subtag Registry to Version 2022-08-08 Backport-of: 40b5f15c331c07f009cd49e2a1117c2754af24b9 --- make/data/lsrdata/language-subtag-registry.txt | 16 +++++++++++++++- .../util/Locale/LanguageSubtagRegistryTest.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index cade190589c..92e0a26f0cd 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2022-03-02 +File-Date: 2022-08-08 %% Type: language Subtag: aa @@ -46970,6 +46970,7 @@ Preferred-Value: TL %% Type: region Subtag: TR +Description: Türkiye Description: Turkey Added: 2005-10-16 %% @@ -47766,6 +47767,19 @@ Comments: The dialect of Lipovaz/Lipovec is one of the minor local dialects of Resian %% Type: variant +Subtag: ltg1929 +Description: The Latgalian language orthography codified in 1929 +Added: 2022-08-05 +Prefix: ltg +%% +Type: variant +Subtag: ltg2007 +Description: The Latgalian language orthography codified in the language + law in 2007 +Added: 2022-06-23 +Prefix: ltg +%% +Type: variant Subtag: luna1918 Description: Post-1917 Russian orthography Added: 2010-10-10 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index f13454536c1..a617aeb02cd 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -26,7 +26,7 @@ * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 * 8258795 8267038 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2022-03-02) with Locale and Locale.LanguageRange + * (LSR Revision: 2022-08-08) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ From 9ef11ac262649c338f2ed93ee25b744ca83f51af Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:55:55 +0000 Subject: [PATCH 087/205] 8295788: C2 compilation hits "assert((mode == ControlAroundStripMined && use == sfpt) || !use->is_reachable_from_root()) failed: missed a node" Backport-of: 761a4f4852cbb40660b6fb9eda4d740464218f75 --- src/hotspot/share/opto/loopopts.cpp | 41 +++++++------ .../TestUseFromInnerInOuterUnusedBySfpt.java | 61 +++++++++++++++++++ 2 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopstripmining/TestUseFromInnerInOuterUnusedBySfpt.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 6edb4314534..f0201d82614 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1858,26 +1858,28 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, } } -static void clone_outer_loop_helper(Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop, - const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase, - bool check_old_new) { +static void collect_nodes_in_outer_loop_not_reachable_from_sfpt(Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop, + const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase, + bool check_old_new) { for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) { Node* u = n->fast_out(j); assert(check_old_new || old_new[u->_idx] == NULL, "shouldn't have been cloned"); if (!u->is_CFG() && (!check_old_new || old_new[u->_idx] == NULL)) { Node* c = phase->get_ctrl(u); IdealLoopTree* u_loop = phase->get_loop(c); - assert(!loop->is_member(u_loop), "can be in outer loop or out of both loops only"); - if (outer_loop->is_member(u_loop)) { - wq.push(u); - } else { - // nodes pinned with control in the outer loop but not referenced from the safepoint must be moved out of - // the outer loop too - Node* u_c = u->in(0); - if (u_c != NULL) { - IdealLoopTree* u_c_loop = phase->get_loop(u_c); - if (outer_loop->is_member(u_c_loop) && !loop->is_member(u_c_loop)) { - wq.push(u); + assert(!loop->is_member(u_loop) || !loop->_body.contains(u), "can be in outer loop or out of both loops only"); + if (!loop->is_member(u_loop)) { + if (outer_loop->is_member(u_loop)) { + wq.push(u); + } else { + // nodes pinned with control in the outer loop but not referenced from the safepoint must be moved out of + // the outer loop too + Node* u_c = u->in(0); + if (u_c != NULL) { + IdealLoopTree* u_c_loop = phase->get_loop(u_c); + if (outer_loop->is_member(u_c_loop) && !loop->is_member(u_c_loop)) { + wq.push(u); + } } } } @@ -1996,12 +1998,17 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL Unique_Node_List wq; for (uint i = 0; i < extra_data_nodes.size(); i++) { Node* old = extra_data_nodes.at(i); - clone_outer_loop_helper(old, loop, outer_loop, old_new, wq, this, true); + collect_nodes_in_outer_loop_not_reachable_from_sfpt(old, loop, outer_loop, old_new, wq, this, true); + } + + for (uint i = 0; i < loop->_body.size(); i++) { + Node* old = loop->_body.at(i); + collect_nodes_in_outer_loop_not_reachable_from_sfpt(old, loop, outer_loop, old_new, wq, this, true); } Node* inner_out = sfpt->in(0); if (inner_out->outcnt() > 1) { - clone_outer_loop_helper(inner_out, loop, outer_loop, old_new, wq, this, true); + collect_nodes_in_outer_loop_not_reachable_from_sfpt(inner_out, loop, outer_loop, old_new, wq, this, true); } Node* new_ctrl = cl->outer_loop_exit(); @@ -2012,7 +2019,7 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL if (n->in(0) != NULL) { _igvn.replace_input_of(n, 0, new_ctrl); } - clone_outer_loop_helper(n, loop, outer_loop, old_new, wq, this, false); + collect_nodes_in_outer_loop_not_reachable_from_sfpt(n, loop, outer_loop, old_new, wq, this, false); } } else { Node *newhead = old_new[loop->_head->_idx]; diff --git a/test/hotspot/jtreg/compiler/loopstripmining/TestUseFromInnerInOuterUnusedBySfpt.java b/test/hotspot/jtreg/compiler/loopstripmining/TestUseFromInnerInOuterUnusedBySfpt.java new file mode 100644 index 00000000000..678cad4d91a --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopstripmining/TestUseFromInnerInOuterUnusedBySfpt.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022, Red Hat, Inc. All rights reserved. + * 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 8295788 + * @summary C2 compilation hits "assert((mode == ControlAroundStripMined && use == sfpt) || !use->is_reachable_from_root()) failed: missed a node" + * + * @run main/othervm -Xcomp -XX:CompileOnly=TestUseFromInnerInOuterUnusedBySfpt TestUseFromInnerInOuterUnusedBySfpt + * + */ + +public class TestUseFromInnerInOuterUnusedBySfpt { + + public static final int N = 400; + + public static void dMeth(long l, int i5, int i6) { + + int i7=14, i8=-14, i9=7476, i11=0; + long lArr[]=new long[N]; + + for (i7 = 3; i7 < 177; i7++) { + lArr[i7 + 1] >>= l; + l -= i8; + i6 = (int)l; + } + for (i9 = 15; i9 < 356; i9 += 3) { + i11 = 14; + do { + i5 |= i6; + } while (--i11 > 0); + } + } + + public static void main(String[] strArr) { + TestUseFromInnerInOuterUnusedBySfpt _instance = new TestUseFromInnerInOuterUnusedBySfpt(); + for (int i = 0; i < 10; i++) { + _instance.dMeth(-12L, -50242, 20); + } + } +} From 5b349eaf93d4224f36c052ef75c2070f316e62ab Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 08:58:23 +0000 Subject: [PATCH 088/205] 8297264: C2: Cast node is not processed again in CCP and keeps a wrong too narrow type which is later replaced by top Backport-of: ba023c6bf32da357e74bcb93b3cf13154b806866 --- src/hotspot/share/opto/phaseX.cpp | 25 +++++++- src/hotspot/share/opto/phaseX.hpp | 2 + .../compiler/ccp/TestCastIIWrongTypeCCP.java | 63 +++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp index 1eed41926da..d76a080af07 100644 --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -1937,6 +1937,30 @@ void PhaseCCP::analyze() { } } } + push_cast_ii(worklist, n, m); + } + } + } +} + +void PhaseCCP::push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const { + if (n->bottom_type() != type(n)) { + worklist.push(n); + } +} + +// CastII::Value() optimizes CmpI/If patterns if the right input of the CmpI has a constant type. If the CastII input is +// the same node as the left input into the CmpI node, the type of the CastII node can be improved accordingly. Add the +// CastII node back to the worklist to re-apply Value() to either not miss this optimization or to undo it because it +// cannot be applied anymore. We could have optimized the type of the CastII before but now the type of the right input +// of the CmpI (i.e. 'parent') is no longer constant. The type of the CastII must be widened in this case. +void PhaseCCP::push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const { + if (use->Opcode() == Op_CmpI && use->in(2) == parent) { + Node* other_cmp_input = use->in(1); + for (DUIterator_Fast imax, i = other_cmp_input->fast_outs(imax); i < imax; i++) { + Node* cast_ii = other_cmp_input->fast_out(i); + if (cast_ii->is_CastII()) { + push_if_not_bottom_type(worklist, cast_ii); } } } @@ -2001,7 +2025,6 @@ Node *PhaseCCP::transform( Node *n ) { return new_node; } - //------------------------------transform_once--------------------------------- // For PhaseCCP, transformation is IDENTITY unless Node computed a constant. Node *PhaseCCP::transform_once( Node *n ) { diff --git a/src/hotspot/share/opto/phaseX.hpp b/src/hotspot/share/opto/phaseX.hpp index d7a135bd4aa..21c714ee1a0 100644 --- a/src/hotspot/share/opto/phaseX.hpp +++ b/src/hotspot/share/opto/phaseX.hpp @@ -585,6 +585,8 @@ class PhaseCCP : public PhaseIterGVN { Unique_Node_List _safepoints; // Non-recursive. Use analysis to transform single Node. virtual Node *transform_once( Node *n ); + void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const; + void push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const; public: PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants diff --git a/test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java b/test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java new file mode 100644 index 00000000000..976e85133f1 --- /dev/null +++ b/test/hotspot/jtreg/compiler/ccp/TestCastIIWrongTypeCCP.java @@ -0,0 +1,63 @@ +/* + * 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 8297264 + * @summary Test that CastII nodes are added to the CCP worklist if they could have been + * optimized due to a CmpI/If pattern. + * @run main/othervm -Xcomp -XX:CompileCommand=compileonly,compiler.ccp.TestCastIIWrongTypeCCP::* + * compiler.ccp.TestCastIIWrongTypeCCP + */ +package compiler.ccp; + +public class TestCastIIWrongTypeCCP { + + static int x; + + public static void main(String[] args) { + test(); + } + + static void test() { + int iArr[] = new int[400]; + int i = 0; + do { + for (int i5 = 1; i5 < 4; i5++) { + for (int i9 = 2; i9 > i5; i9 -= 3) { + if (x != 0) { + A.unloaded(); // unloaded UCT + } + x = 1; + iArr[5] = 1; + } + } + i++; + } while (i < 10000); + } +} + +class A { + public static void unloaded() { + } +} From de8c37acea0d74524f4f735fef8b03e71a64589f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Jan 2023 09:00:14 +0000 Subject: [PATCH 089/205] 8297951: C2: Create skeleton predicates for all If nodes in loop predication Backport-of: 0bd04a658963c1126faa776cb8a96c23beb5e3e6 --- src/hotspot/share/opto/loopPredicate.cpp | 12 ++- ...TestMissingSkeletonPredicateForIfNode.java | 78 +++++++++++++++++++ 2 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestMissingSkeletonPredicateForIfNode.java diff --git a/src/hotspot/share/opto/loopPredicate.cpp b/src/hotspot/share/opto/loopPredicate.cpp index 8d6cfb21d0c..f1f11901641 100644 --- a/src/hotspot/share/opto/loopPredicate.cpp +++ b/src/hotspot/share/opto/loopPredicate.cpp @@ -1212,13 +1212,11 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree *loop, ProjNode* upper_bound_iff->set_req(1, upper_bound_bol); if (TraceLoopPredicate) tty->print_cr("upper bound check if: %s %d ", negate ? " negated" : "", lower_bound_iff->_idx); - // Fall through into rest of the clean up code which will move - // any dependent nodes onto the upper bound test. - new_predicate_proj = upper_bound_proj; - - if (iff->is_RangeCheck()) { - new_predicate_proj = insert_initial_skeleton_predicate(iff, loop, proj, predicate_proj, upper_bound_proj, scale, offset, init, limit, stride, rng, overflow, reason); - } + // Fall through into rest of the cleanup code which will move any dependent nodes to the skeleton predicates of the + // upper bound test. We always need to create skeleton predicates in order to properly remove dead loops when later + // splitting the predicated loop into (unreachable) sub-loops (i.e. done by unrolling, peeling, pre/main/post etc.). + new_predicate_proj = insert_initial_skeleton_predicate(iff, loop, proj, predicate_proj, upper_bound_proj, scale, + offset, init, limit, stride, rng, overflow, reason); #ifndef PRODUCT if (TraceLoopOpts && !TraceLoopPredicate) { diff --git a/test/hotspot/jtreg/compiler/loopopts/TestMissingSkeletonPredicateForIfNode.java b/test/hotspot/jtreg/compiler/loopopts/TestMissingSkeletonPredicateForIfNode.java new file mode 100644 index 00000000000..debc4a3890b --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestMissingSkeletonPredicateForIfNode.java @@ -0,0 +1,78 @@ +/* + * 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 8297951 + * @summary Test that crashes because we do not emit skeleton predicates for normal If nodes for which a range check + * predicate is created in loop predication. + * @requires vm.debug == true & vm.compiler2.enabled + * @run main/othervm -XX:-TieredCompilation -Xbatch -XX:-RangeCheckElimination -XX:+BailoutToInterpreterForThrows + compiler.loopopts.TestMissingSkeletonPredicateForIfNode + */ +package compiler.loopopts; + +public class TestMissingSkeletonPredicateForIfNode { + static int iFld = 2, x; + static short limit = 10; + + public static void main(String[] args) throws Exception { + for (int i = 0; i < 5000; i++) { + try { + test(i % 2 == 0, i % 3); + } catch (Exception e) { + // Expected + } + } + } + + public static void test(boolean flag, int arg) throws Exception { + int sum = 1; + int[] iArr2 = new int[4]; + RuntimeException r = new RuntimeException(); + + for (int i = 0; i < limit; i+=2) { // Pre/main/post + Unrolled once. This results in the following type for the iv phi i: [2..SHORT_MAX] + x = 5 / sum; + if (Integer.compareUnsigned(i, iArr2.length) < 0) { // (**) Loop predication creates a RC predicate for this check + // After unrolling, we have: + // + // iArr2[i] + // iArr2[i+2] + // + // The type of iArr2[i+2] is [4..SHORT_MAX+2] (we need limit to be short such that we do not have an integer overflow + // which would set the type to int). However, the type of the CastII node for the index i+2 is [0..3] because its size + // is only 4. Since the type of i+2 is outside the range of the CastII node, the CastII node is replaced by top and + // some of the data nodes and memory nodes die. We are left with a broken graph and later assert because of that. + iFld += iArr2[i]; // RangeCheck node is removed because it shares the same bool as the If (**). + sum += iFld; + } else { + // Emits an UCT with -XX:+BailoutToInterpreterForThrows and therefore the If (**) satisfies the condition of being a + // range check if with one of its blocks being an UCT. + throw r; + } + if (i > 50) { + break; + } + } + } +} From 684a870e4fa60dec7fc4d8933fb97be86c6979ab Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Wed, 25 Jan 2023 10:27:19 +0000 Subject: [PATCH 090/205] 8300119: CgroupMetrics.getTotalMemorySize0() can report invalid results on 32 bit systems Backport-of: dea58efb6280bb1d94daf208ac909aa013439397 --- src/java.base/linux/native/libjava/CgroupMetrics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java.base/linux/native/libjava/CgroupMetrics.c b/src/java.base/linux/native/libjava/CgroupMetrics.c index 4eaac0c6dd4..d9bb7369f1d 100644 --- a/src/java.base/linux/native/libjava/CgroupMetrics.c +++ b/src/java.base/linux/native/libjava/CgroupMetrics.c @@ -39,5 +39,7 @@ JNIEXPORT jlong JNICALL Java_jdk_internal_platform_CgroupMetrics_getTotalMemorySize0 (JNIEnv *env, jclass ignored) { - return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE); + jlong pages = sysconf(_SC_PHYS_PAGES); + jlong page_size = sysconf(_SC_PAGESIZE); + return pages * page_size; } From c02f7fea72c03c8181dbefe36266c84c6ebc4018 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 25 Jan 2023 17:33:45 +0000 Subject: [PATCH 091/205] 6528710: sRGB-ColorSpace to sRGB-ColorSpace Conversion Backport-of: abeddab991d71f4ea54665082ffcb284267d7f44 --- .../SimpleSRGBConversionQualityTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/jdk/java/awt/color/ICC_ColorSpace/SimpleSRGBConversionQualityTest.java diff --git a/test/jdk/java/awt/color/ICC_ColorSpace/SimpleSRGBConversionQualityTest.java b/test/jdk/java/awt/color/ICC_ColorSpace/SimpleSRGBConversionQualityTest.java new file mode 100644 index 00000000000..57239dd41e7 --- /dev/null +++ b/test/jdk/java/awt/color/ICC_ColorSpace/SimpleSRGBConversionQualityTest.java @@ -0,0 +1,51 @@ +/* + * 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.Color; +import java.awt.color.ColorSpace; + +/** + * @test + * @bug 6528710 + * @summary Verifies sRGB-ColorSpace to sRGB-ColorSpace conversion quality + */ +public final class SimpleSRGBConversionQualityTest { + + public static void main(String[] args) { + ColorSpace cspace = ColorSpace.getInstance(ColorSpace.CS_sRGB); + float fvalue[] = {1.0f, 1.0f, 1.0f}; + + Color c = new Color(cspace, fvalue, 1.0f); + if (c.getRed() != 255 || c.getGreen() != 255 || c.getBlue() != 255) { + throw new RuntimeException("Wrong color: " + c); + } + + float frgbvalue[] = cspace.toRGB(fvalue); + for (int i = 0; i < 3; ++i) { + if (frgbvalue[i] != 1.0f) { + System.err.println(fvalue[i] + " -> " + frgbvalue[i]); + throw new RuntimeException("Wrong value"); + } + } + } +} From 3c51c43731cbcdf6c8dffd7e9b191c09e4f0e02b Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 26 Jan 2023 14:09:03 +0000 Subject: [PATCH 092/205] 8280048: Missing comma in copyright header Backport-of: 9a18190a4f8e31801d1442d97f247f074a3fd5c0 --- test/jdk/java/awt/Graphics2D/CopyAreaOOB.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/awt/Graphics2D/CopyAreaOOB.java b/test/jdk/java/awt/Graphics2D/CopyAreaOOB.java index 0ebda98042a..8d218d9f189 100644 --- a/test/jdk/java/awt/Graphics2D/CopyAreaOOB.java +++ b/test/jdk/java/awt/Graphics2D/CopyAreaOOB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021 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 From e1ca75ab8d0536fd7b22b9d77481129ec7d52a89 Mon Sep 17 00:00:00 2001 From: Victor Rudometov Date: Thu, 26 Jan 2023 16:18:33 +0000 Subject: [PATCH 093/205] 8208077: File.listRoots performance degradation Backport-of: 5b0af1a80bb4d2a81cda7e26a6ad0db43e679519 --- .../classes/java/io/WinNTFileSystem.java | 4 +-- test/jdk/java/io/File/ListRoots.java | 36 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/java.base/windows/classes/java/io/WinNTFileSystem.java index efe64b1a57d..98fb2d198f7 100644 --- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java +++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, 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 @@ -642,7 +642,7 @@ public File[] listRoots() { .valueOf(new long[] {listRoots0()}) .stream() .mapToObj(i -> new File((char)('A' + i) + ":" + slash)) - .filter(f -> access(f.getPath()) && f.exists()) + .filter(f -> access(f.getPath())) .toArray(File[]::new); } diff --git a/test/jdk/java/io/File/ListRoots.java b/test/jdk/java/io/File/ListRoots.java index 51dd1913bd1..7b14b2f3b08 100644 --- a/test/jdk/java/io/File/ListRoots.java +++ b/test/jdk/java/io/File/ListRoots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 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 @@ -23,11 +23,17 @@ /* @test @bug 4071322 - @summary Basic test for listRoots method + @summary Basic test for File.listRoots method */ -import java.io.*; - +import java.io.File; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; public class ListRoots { @@ -37,15 +43,25 @@ public static void main(String[] args) throws Exception { System.out.println(i + ": " + rs[i]); } - File f = new File(System.getProperty("test.src", "."), - "ListRoots.java"); + File f = new File(System.getProperty("test.src", "."), "ListRoots.java"); String cp = f.getCanonicalPath(); - for (int i = 0; i < rs.length; i++) { - if (cp.startsWith(rs[i].getPath())) break; - if (i == rs.length - 1) - throw new Exception(cp + " does not have a recognized root"); + boolean found = Stream.of(rs) + .map(File::getPath) + .anyMatch(p -> cp.startsWith(p)); + if (!found) { + throw new RuntimeException(cp + " does not have a recognized root"); } + // the list of roots should match FileSystem::getRootDirectories + Set roots1 = Stream.of(rs).collect(Collectors.toSet()); + FileSystem fs = FileSystems.getDefault(); + Set roots2 = StreamSupport.stream(fs.getRootDirectories().spliterator(), false) + .map(Path::toFile) + .collect(Collectors.toSet()); + if (!roots1.equals(roots2)) { + System.out.println(roots2); + throw new RuntimeException("Does not match FileSystem::getRootDirectories"); + } } } From 08e09c52a5ca3e8ada9bcee911ebc0d8955e291a Mon Sep 17 00:00:00 2001 From: Masanori Yano Date: Thu, 26 Jan 2023 20:31:10 +0000 Subject: [PATCH 094/205] 8144030: [macosx] test java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java fails (again) Reviewed-by: serb Backport-of: e5041ae3d45b43be10d5da747d773882ebf0482b --- test/jdk/ProblemList.txt | 1 - .../ShapeNotSetSometimes.java | 159 ++++++++++-------- 2 files changed, 88 insertions(+), 72 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index fad85c6606e..7ed0b7cb31d 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -141,7 +141,6 @@ java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java 8169096 java/awt/event/KeyEvent/CorrectTime/CorrectTime.java 6626492 generic-all java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java 8198237 macosx-all -java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java 8144030 macosx-all java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java 8208290 macosx-all java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all diff --git a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java index efc80d4bded..20ca18587ef 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, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -31,18 +31,29 @@ */ -import java.awt.*; -import java.awt.event.InputEvent; -import java.awt.geom.*; +import java.awt.Color; +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.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Rectangle2D; public class ShapeNotSetSometimes { private Frame backgroundFrame; private Frame window; - private static final Color BACKGROUND_COLOR = Color.BLUE; - private Shape shape; - private int[][] pointsToCheck; + 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; @@ -54,43 +65,39 @@ public ShapeNotSetSometimes() throws Exception { private void initializeGUI() { backgroundFrame = new BackgroundFrame(); backgroundFrame.setUndecorated(true); - backgroundFrame.setSize(300, 300); - backgroundFrame.setLocation(20, 400); + backgroundFrame.setBounds(bounds); backgroundFrame.setVisible(true); - shape = null; - String shape_name = null; - Area a; - GeneralPath gp; - shape_name = "Rounded-corners"; - a = new Area(); - a.add(new Area(new Rectangle2D.Float(50, 0, 100, 150))); - a.add(new Area(new Rectangle2D.Float(0, 50, 200, 50))); - a.add(new Area(new Ellipse2D.Float(0, 0, 100, 100))); - a.add(new Area(new Ellipse2D.Float(0, 50, 100, 100))); - a.add(new Area(new Ellipse2D.Float(100, 0, 100, 100))); - a.add(new Area(new Ellipse2D.Float(100, 50, 100, 100))); - shape = a; - pointsToCheck = new int[][] { - // inside shape - {106, 86}, {96, 38}, {76, 107}, {180, 25}, {24, 105}, - {196, 77}, {165, 50}, {14, 113}, {89, 132}, {167, 117}, - // outside shape - {165, 196}, {191, 163}, {146, 185}, {61, 170}, {148, 171}, - {82, 172}, {186, 11}, {199, 141}, {13, 173}, {187, 3} + Area area = new Area(); + area.add(new Area(new Rectangle2D.Float(100, 50, 100, 150))); + area.add(new Area(new Rectangle2D.Float(50, 100, 200, 50))); + area.add(new Area(new Ellipse2D.Float(50, 50, 100, 100))); + area.add(new Area(new Ellipse2D.Float(50, 100, 100, 100))); + area.add(new Area(new Ellipse2D.Float(150, 50, 100, 100))); + area.add(new Area(new Ellipse2D.Float(150, 100, 100, 100))); + + + innerPoint = new Point(150, 130); + pointsOutsideToCheck = new Point[] { + new Point(150, 20), + new Point(280, 120), + new Point(150, 250), + new Point(20, 120) + }; + + shadedPointsToCheck = new Point[] { + new Point(62, 62), + new Point(240, 185) }; window = new TestFrame(); window.setUndecorated(true); - window.setSize(200, 200); - window.setLocation(70, 450); - window.setShape(shape); + window.setBounds(bounds); + window.setShape(area); window.setVisible(true); - - System.out.println("Checking " + window.getClass().getSuperclass().getName() + " with " + shape_name + " shape (" + window.getShape() + ")..."); } - class BackgroundFrame extends Frame { + static class BackgroundFrame extends Frame { @Override public void paint(Graphics g) { @@ -107,8 +114,8 @@ class TestFrame extends Frame { @Override public void paint(Graphics g) { - g.setColor(Color.WHITE); - g.fillRect(0, 0, 200, 200); + g.setColor(SHAPE_COLOR); + g.fillRect(0, 0, bounds.width, bounds.height); super.paint(g); } @@ -124,48 +131,58 @@ public static void main(String[] args) throws Exception { } private void doTest() throws Exception { - Point wls = backgroundFrame.getLocationOnScreen(); + EventQueue.invokeAndWait(backgroundFrame::toFront); + robot.waitForIdle(); - robot.mouseMove(wls.x + 5, wls.y + 5); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.delay(10); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.delay(500); + EventQueue.invokeAndWait(window::toFront); + robot.waitForIdle(); - EventQueue.invokeAndWait(window::requestFocus); + robot.delay(500); - robot.waitForIdle(); try { - Thread.sleep(300); - } catch (InterruptedException e) { - // ignore this one - } + colorCheck(innerPoint.x, innerPoint.y, SHAPE_COLOR, true); - // check transparency - final int COUNT_TARGET = 10; - - // checking outside points only - for(int i = COUNT_TARGET; i < COUNT_TARGET * 2; i++) { - int x = pointsToCheck[i][0]; - int y = pointsToCheck[i][1]; - boolean inside = i < COUNT_TARGET; - Color c = robot.getPixelColor(window.getX() + x, window.getY() + y); - System.out.println("checking " + x + ", " + y + ", color = " + c); - if (inside && BACKGROUND_COLOR.equals(c) || !inside && !BACKGROUND_COLOR.equals(c)) { - System.out.println("window.getX() = " + window.getX() + ", window.getY() = " + window.getY()); - System.err.println("Checking for transparency failed: point: " + - (window.getX() + x) + ", " + (window.getY() + y) + - ", color = " + c + (inside ? " is of un" : " is not of ") + - "expected background color " + BACKGROUND_COLOR); - throw new RuntimeException("Test failed. The shape has not been applied."); + for (Point point : pointsOutsideToCheck) { + colorCheck(point.x, point.y, BACKGROUND_COLOR, true); } - } - EventQueue.invokeAndWait(new Runnable() { - public void run() { + for (Point point : shadedPointsToCheck) { + colorCheck(point.x, point.y, SHAPE_COLOR, false); + } + } finally { + EventQueue.invokeAndWait(() -> { backgroundFrame.dispose(); window.dispose(); - } - }); + }); + } + } + + private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpectedColor) { + + int screenX = window.getX() + x; + int screenY = window.getY() + y; + + Color actualColor = robot.getPixelColor(screenX, screenY); + + System.out.printf( + "Checking %3d, %3d, %35s should %sbe %35s\n", + x, y, + actualColor, + (mustBeExpectedColor) ? "" : "not ", + expectedColor + ); + + if (mustBeExpectedColor != expectedColor.equals(actualColor)) { + 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, + screenY, + actualColor, + mustBeExpectedColor ? "" : "not ", + expectedColor); + throw new RuntimeException("Test failed. The shape has not been applied."); + } } } From 60d46cdce2d3981889c99b39bea25ab8db99108b Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 27 Jan 2023 17:20:14 +0000 Subject: [PATCH 095/205] 8192931: Regression test java/awt/font/TextLayout/CombiningPerf.java fails Backport-of: 54a29a4470a0482c6b7f9f2d695e357044e684a7 --- test/jdk/ProblemList.txt | 1 - .../awt/font/TextLayout/CombiningPerf.java | 85 ------------------- 2 files changed, 86 deletions(-) delete mode 100644 test/jdk/java/awt/font/TextLayout/CombiningPerf.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 7ed0b7cb31d..7e8805ef5f2 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -203,7 +203,6 @@ java/awt/Window/AlwaysOnTop/AutoTestOnTop.java 6847593 macosx-all java/awt/Window/GrabSequence/GrabSequence.java 6848409 macosx-all,linux-all java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java 8203371 linux-all,solaris-all java/awt/font/Rotate/RotatedFontTest.java 8244518 linux-all -java/awt/font/TextLayout/CombiningPerf.java 8192931 generic-all java/awt/font/TextLayout/TextLayoutBounds.java 8169188 generic-all java/awt/font/StyledMetrics/BoldSpace.java 8198422 linux-all java/awt/FontMetrics/FontCrash.java 8198336 windows-all diff --git a/test/jdk/java/awt/font/TextLayout/CombiningPerf.java b/test/jdk/java/awt/font/TextLayout/CombiningPerf.java deleted file mode 100644 index d51e586e507..00000000000 --- a/test/jdk/java/awt/font/TextLayout/CombiningPerf.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * 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 6328154 6962082 - * @summary ensure that ascii, and latin-1 text without combining marks, both layout faster - * than latin-1 text with combining marks. The presumption is then that the canonical - * GSUB table is being run only on the latter and not on either of the former. - */ - -import java.awt.Font; -import java.awt.GraphicsEnvironment; -import java.awt.font.FontRenderContext; -import java.awt.font.TextLayout; - -import static java.awt.Font.*; - -public class CombiningPerf { - private static Font font; - private static FontRenderContext frc; - - public static void main(String[] args) throws Exception { - System.err.println("start"); - - GraphicsEnvironment.getLocalGraphicsEnvironment(); - - font = new Font("Lucida Sans Regular", PLAIN, 12); - frc = new FontRenderContext(null, false, false); - - String ascii = "the characters are critical noodles?"; - String french = "l'aper\u00e7u caract\u00e8re one \u00e9t\u00e9 cr\u00e9\u00e9s"; - String frenchX = "l'aper\u00e7u caracte\u0300re one e\u0301te\u0301 ere\u0301e\u0301s"; - - // warmup - for (int i = 0; i < 100; ++i) { - TextLayout tl = new TextLayout(french, font, frc); - tl = new TextLayout(ascii, font, frc); - tl = new TextLayout(frenchX, font, frc); - } - /**/ - long atime = test(ascii); - System.err.println("atime: " + (atime/1000000.0) + " length: " + ascii.length()); - - long ftime = test(french); - System.err.println("ftime: " + (ftime/1000000.0) + " length: " + french.length()); - - long xtime = test(frenchX); - System.err.println("xtime: " + (xtime/1000000.0) + " length: " + frenchX.length()); - - long limit = xtime * 2 / 3; - if (atime > limit || ftime > limit) { - throw new Exception("took too long"); - } - /**/ - } - - private static long test(String text) { - long start = System.nanoTime(); - for (int i = 0; i < 2000; ++i) { - TextLayout tl = new TextLayout(text, font, frc); - } - return System.nanoTime() - start; - } -} From 644b50e0bc5a814d16d5f91a1b49c71bd971f1ae Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 27 Jan 2023 17:26:39 +0000 Subject: [PATCH 096/205] 8294705: Disable an assertion in test/jdk/java/util/DoubleStreamSums/CompensatedSums.java Backport-of: c08ff2c7b88e94885f6b4701654a9e47e49567b0 --- .../java/util/DoubleStreamSums/CompensatedSums.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/util/DoubleStreamSums/CompensatedSums.java b/test/jdk/java/util/DoubleStreamSums/CompensatedSums.java index 5dfeab142da..3d5ce9feb48 100644 --- a/test/jdk/java/util/DoubleStreamSums/CompensatedSums.java +++ b/test/jdk/java/util/DoubleStreamSums/CompensatedSums.java @@ -91,7 +91,13 @@ public void testCompensatedSums() { } Assert.assertTrue(jdkParallelStreamError <= goodParallelStreamError); - Assert.assertTrue(badParallelStreamError >= jdkParallelStreamError); + /* + * Due to floating-point addition being inherently non-associative, + * and due to the unpredictable scheduling of the threads used + * in parallel streams, this assertion can fail intermittently, + * hence is suppressed for now. + */ + // Assert.assertTrue(badParallelStreamError >= jdkParallelStreamError); Assert.assertTrue(goodSequentialStreamError >= jdkSequentialStreamError); Assert.assertTrue(naive > jdkSequentialStreamError); @@ -144,4 +150,4 @@ static double computeFinalSum(double[] summands) { ll[2] += rr[2]; }; -} \ No newline at end of file +} From 4e13da9908d46dfd596155eacf26e73631c31a63 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 30 Jan 2023 08:57:12 +0000 Subject: [PATCH 097/205] 8230374: maxOutputSize, instead of javatest.maxOutputSize, should be used in TEST.properties Backport-of: 04d8069bacc6259fc5bf9de6963bb099fcfc4961 --- test/jdk/jdk/lambda/TEST.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/jdk/lambda/TEST.properties b/test/jdk/jdk/lambda/TEST.properties index 58528a633db..eaae109a7fc 100644 --- a/test/jdk/jdk/lambda/TEST.properties +++ b/test/jdk/jdk/lambda/TEST.properties @@ -2,5 +2,5 @@ TestNG.dirs = . -javatest.maxOutputSize = 250000 +maxOutputSize = 250000 modules = jdk.compiler jdk.zipfs From d183dc25f7360c3012726acf8c03874df6fc41a4 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 30 Jan 2023 08:59:53 +0000 Subject: [PATCH 098/205] 8295685: Update Libpng to 1.6.38 Backport-of: b685fc2de4d2847de2d1efaab2890646257ea6d3 --- src/java.desktop/share/legal/libpng.md | 74 +++++++++++++++++-- .../native/libsplashscreen/libpng/CHANGES | 10 ++- .../native/libsplashscreen/libpng/LICENSE | 4 +- .../native/libsplashscreen/libpng/README | 8 +- .../libsplashscreen/libpng/UPDATING.txt | 27 ++++--- .../share/native/libsplashscreen/libpng/png.c | 14 ++-- .../share/native/libsplashscreen/libpng/png.h | 26 +++---- .../native/libsplashscreen/libpng/pngconf.h | 8 +- .../native/libsplashscreen/libpng/pngget.c | 14 ++-- .../libsplashscreen/libpng/pnglibconf.h | 4 +- .../native/libsplashscreen/libpng/pngpriv.h | 65 +++++++--------- .../native/libsplashscreen/libpng/pngread.c | 3 - .../native/libsplashscreen/libpng/pngrtran.c | 2 +- .../native/libsplashscreen/libpng/pngrutil.c | 36 ++++----- .../native/libsplashscreen/libpng/pngset.c | 13 ++-- .../native/libsplashscreen/libpng/pngstruct.h | 12 +-- 16 files changed, 188 insertions(+), 132 deletions(-) diff --git a/src/java.desktop/share/legal/libpng.md b/src/java.desktop/share/legal/libpng.md index 655cd095fe8..4f69da5383a 100644 --- a/src/java.desktop/share/legal/libpng.md +++ b/src/java.desktop/share/legal/libpng.md @@ -1,4 +1,4 @@ -## libpng v1.6.37 +## libpng v1.6.38 ### libpng License
@@ -9,11 +9,11 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
 PNG Reference Library License version 2
 ---------------------------------------
 
- * Copyright (c) 1995-2019 The PNG Reference Library Authors.
- * Copyright (c) 2018-2019 Cosmin Truta.
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * Copyright (c) 1996-1997 Andreas Dilger.
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+Copyright (c) 1995-2022 The PNG Reference Library Authors.
+Copyright (c) 2018-2022 Cosmin Truta
+Copyright (c) 1998-2018 Glenn Randers-Pehrson
+Copyright (c) 1996-1997 Andreas Dilger
+Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
 
 The software is supplied "as is", without warranty of any kind,
 express or implied, including, without limitation, the warranties
@@ -138,4 +138,66 @@ to supporting the PNG file format in commercial products.  If you use
 this source code in a product, acknowledgment is not required but would
 be appreciated.
 
+TRADEMARK
+=========
+
+The name "libpng" has not been registered by the Copyright owners
+as a trademark in any jurisdiction.  However, because libpng has
+been distributed and maintained world-wide, continually since 1995,
+the Copyright owners claim "common-law trademark protection" in any
+jurisdiction where common-law trademark is recognized.
+
 
+ +### AUTHORS File Information +``` +PNG REFERENCE LIBRARY AUTHORS +============================= + +This is the list of PNG Reference Library ("libpng") Contributing +Authors, for copyright and licensing purposes. + + * Andreas Dilger + * Cosmin Truta + * Dave Martindale + * Eric S. Raymond + * Gilles Vollant + * Glenn Randers-Pehrson + * Greg Roelofs + * Guy Eric Schalnat + * James Yu + * John Bowler + * Kevin Bracey + * Magnus Holmgren + * Mandar Sahastrabuddhe + * Mans Rullgard + * Matt Sarett + * Mike Klein + * Pascal Massimino + * Paul Schmidt + * Qiang Zhou + * Sam Bushell + * Samuel Williams + * Simon-Pierre Cadieux + * Tim Wegner + * Tom Lane + * Tom Tanner + * Vadim Barkov + * Willem van Schaik + * Zhijie Liang + * Arm Holdings + - Richard Townsend + * Google Inc. + - Matt Sarett + - Mike Klein + - Dan Field + - Sami Boukortt + +The build projects, the build scripts, the test scripts, and other +files in the "ci", "projects", "scripts" and "tests" directories, have +other copyright owners, but are released under the libpng license. + +Some files in the "contrib" directory, and some tools-generated files +that are distributed with libpng, have other copyright owners, and are +released under other open source licenses. +``` diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES index f0b0a9342c3..9a86869681b 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES +++ b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES @@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009] Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) Version 1.4.0beta59 [May 15, 2009] - Reformated sources in libpng style (3-space intentation, comment format) + Reformated sources in libpng style (3-space indentation, comment format) Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) Added sections about the git repository and our coding style to the documentation @@ -3886,7 +3886,7 @@ Version 1.6.0beta06 [January 24, 2012] Version 1.6.0beta07 [January 28, 2012] Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) compiler issues slightly different warnings from those issued by the - current vesions of GCC. This eliminates those warnings by + current versions of GCC. This eliminates those warnings by adding/removing casts and small code rewrites. Updated configure.ac from autoupdate: added --enable-werror option. Also some layout regularization and removal of introduced tab characters @@ -6103,6 +6103,12 @@ Version 1.6.37 [April 14, 2019] Added makefiles for AddressSanitizer-enabled builds. Cleaned up various makefiles. +Version 1.6.38 [September 14, 2022] + Added configurations and scripts for continuous integration. + Fixed various errors in the handling of tRNS, hIST and eXIf. + Implemented many stability improvements across all platforms. + Updated the internal documentation. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE b/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE index e0c5b531cf5..c8ad24eecf7 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE +++ b/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE @@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE PNG Reference Library License version 2 --------------------------------------- - * Copyright (c) 1995-2019 The PNG Reference Library Authors. - * Copyright (c) 2018-2019 Cosmin Truta. + * Copyright (c) 1995-2022 The PNG Reference Library Authors. + * Copyright (c) 2018-2022 Cosmin Truta. * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 1996-1997 Andreas Dilger. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/README b/src/java.desktop/share/native/libsplashscreen/libpng/README index cfc1f0e3dc9..e6e72aa5472 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/README +++ b/src/java.desktop/share/native/libsplashscreen/libpng/README @@ -1,12 +1,12 @@ -README for libpng version 1.6.37 - April 14, 2019 -================================================= +README for libpng version 1.6.38 +================================ See the note about version numbers near the top of png.h. See INSTALL for instructions on how to install libpng. Libpng comes in several distribution formats. Get libpng-*.tar.gz or -libpng-*.tar.xz or if you want UNIX-style line endings in the text -files, or lpng*.7z or lpng*.zip if you want DOS-style line endings. +libpng-*.tar.xz if you want UNIX-style line endings in the text files, +or lpng*.7z or lpng*.zip if you want DOS-style line endings. Version 0.89 was the first official release of libpng. Don't let the fact that it's the first release fool you. The libpng library has been diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt b/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt index a03cdd14a12..93c8f5bb703 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt +++ b/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt @@ -4,7 +4,7 @@ Updating libpng in OpenJDK Usually this is just a matter of updating the version at the top, and in the embedded text, and extending the copyright date. -The updated info comes from the LICENSE file. +The updated info comes from the LICENSE, TRADEMARK and AUTHORS files. 2) Copy LICENSE, README, and CHANGES from the new version into OpenJDK's libpng source directory @@ -21,9 +21,9 @@ OpenJDK has a heavily modified copy of pnglibconf.h. This is the trickiest part of the whole exercise. This file is generated by png at build time. Except for the dates and version, you should generally not need to update -OpenJDK's copy unless the new version of PNG has added rquired new #defines +OpenJDK's copy unless the new version of PNG has added required new #defines that cause problems building. -You can run configure && make on the downloaded source and compare but we +You can run configure && make on the downloaded source and compare, but we do not want to enable any of the WRITE support, and there are many more modifications as well. So do NOT just copy in a file from the new libpng. @@ -33,15 +33,22 @@ line in the GPL header. So lots of reasons to not copy over the new version, and instead just tweak the existing one. -5) Run scripts to expand tabs and remove trailing white space from source files. +5) Run script to expand tabs and remove trailing white space from source files. -Use expand to remove tabs -expand ${f} > ${f}.tmp -mv ${f}.tmp $f +First cd into the libpng folder and run the following script. -Use sed to remove trailing white space -sed -e 's/[ ]* $//' ${f} > ${f}.tmp -mv ${f}.tmp $f + for f in *.c *.h; + do + # replace tabs with spaces + expand ${f} > ${f}.tmp; + mv ${f}.tmp $f; + + # fix line endings to LF + sed -i -e 's/\r$//g' ${f}; + + # remove trailing spaces + sed -i -e 's/[ ]* $//g' ${f}; + done 6) As with all native code, run it through the official build systems, in case the updated code trigger any fatal warnings with the official compilers. diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.c b/src/java.desktop/share/native/libsplashscreen/libpng/png.c index 3740c3cd214..ba608f128ab 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/png.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.c @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -42,7 +42,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37; +typedef png_libpng_version_1_6_38 Your_png_h_is_not_version_1_6_38; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has @@ -748,7 +748,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp) * * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the * negative integral value is added the result will be an unsigned value - * correspnding to the 2's complement representation. + * corresponding to the 2's complement representation. */ void PNGAPI png_save_int_32(png_bytep buf, png_int_32 i) @@ -843,8 +843,8 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.37" PNG_STRING_NEWLINE \ - "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \ + "libpng version 1.6.38" PNG_STRING_NEWLINE \ + "Copyright (c) 2018-2022 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ @@ -1871,12 +1871,12 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, # ifdef PNG_WARNINGS_SUPPORTED else { - char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ + char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */ pos = png_safecat(message, (sizeof message), pos, png_format_number(number, number+(sizeof number), PNG_NUMBER_FORMAT_x, value)); - pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ + pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */ } # endif /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.h b/src/java.desktop/share/native/libsplashscreen/libpng/png.h index e5e87d3b818..aeff31573c7 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/png.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.h @@ -29,9 +29,9 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * libpng version 1.6.37 - April 14, 2019 + * libpng version 1.6.38 - September 14, 2022 * - * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -43,7 +43,7 @@ * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.35, July 2018: * Glenn Randers-Pehrson - * libpng versions 1.6.36, December 2018, through 1.6.37, April 2019: + * libpng versions 1.6.36, December 2018, through 1.6.38, September 2022: * Cosmin Truta * See also "Contributing Authors", below. */ @@ -55,8 +55,8 @@ * PNG Reference Library License version 2 * --------------------------------------- * - * * Copyright (c) 1995-2019 The PNG Reference Library Authors. - * * Copyright (c) 2018-2019 Cosmin Truta. + * * Copyright (c) 1995-2022 The PNG Reference Library Authors. + * * Copyright (c) 2018-2022 Cosmin Truta. * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * * Copyright (c) 1996-1997 Andreas Dilger. * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -267,7 +267,7 @@ * ... * 1.5.30 15 10530 15.so.15.30[.0] * ... - * 1.6.37 16 10637 16.so.16.37[.0] + * 1.6.38 16 10638 16.so.16.38[.0] * * Henceforth the source version will match the shared-library major and * minor numbers; the shared-library major version number will be used for @@ -306,8 +306,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.37" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n" +#define PNG_LIBPNG_VER_STRING "1.6.38" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.38 - September 14, 2022\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -315,7 +315,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 37 +#define PNG_LIBPNG_VER_RELEASE 38 /* This should be zero for a public release, or non-zero for a * development version. [Deprecated] @@ -346,7 +346,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10637 /* 1.6.37 */ +#define PNG_LIBPNG_VER 10638 /* 1.6.38 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -456,7 +456,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_37; +typedef char* png_libpng_version_1_6_38; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -1474,7 +1474,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. + * header file (zlib.h) for an explanation of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid @@ -1529,7 +1529,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, + * for PNG images, and do considerably fewer calculations. In the future, * these values may not correspond directly to the zlib compression levels. */ #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h index e6c993b8573..e95fa34ad7a 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h @@ -29,9 +29,9 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * libpng version 1.6.37 + * libpng version 1.6.38 * - * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -208,8 +208,8 @@ * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ -#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \ + defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c index 4e5f6c962a5..454d4e82273 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c @@ -1179,7 +1179,7 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED png_byte PNGAPI -png_get_rgb_to_gray_status (png_const_structrp png_ptr) +png_get_rgb_to_gray_status(png_const_structrp png_ptr) { return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); } @@ -1220,27 +1220,27 @@ png_get_compression_buffer_size(png_const_structrp png_ptr) /* These functions were added to libpng 1.2.6 and were enabled * by default in libpng-1.4.0 */ png_uint_32 PNGAPI -png_get_user_width_max (png_const_structrp png_ptr) +png_get_user_width_max(png_const_structrp png_ptr) { return (png_ptr ? png_ptr->user_width_max : 0); } png_uint_32 PNGAPI -png_get_user_height_max (png_const_structrp png_ptr) +png_get_user_height_max(png_const_structrp png_ptr) { return (png_ptr ? png_ptr->user_height_max : 0); } /* This function was added to libpng 1.4.0 */ png_uint_32 PNGAPI -png_get_chunk_cache_max (png_const_structrp png_ptr) +png_get_chunk_cache_max(png_const_structrp png_ptr) { return (png_ptr ? png_ptr->user_chunk_cache_max : 0); } /* This function was added to libpng 1.4.1 */ png_alloc_size_t PNGAPI -png_get_chunk_malloc_max (png_const_structrp png_ptr) +png_get_chunk_malloc_max(png_const_structrp png_ptr) { return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); } @@ -1249,13 +1249,13 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr) /* These functions were added to libpng 1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED png_uint_32 PNGAPI -png_get_io_state (png_const_structrp png_ptr) +png_get_io_state(png_const_structrp png_ptr) { return png_ptr->io_state; } png_uint_32 PNGAPI -png_get_io_chunk_type (png_const_structrp png_ptr) +png_get_io_chunk_type(png_const_structrp png_ptr) { return png_ptr->chunk_name; } diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h index efe99f78402..b3dc39a45be 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h @@ -31,9 +31,9 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: */ -/* libpng version 1.6.37 */ +/* libpng version 1.6.38 */ -/* Copyright (c) 2018-2019 Cosmin Truta */ +/* Copyright (c) 2018-2022 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h index 73e1e9371a3..ed44512ef20 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -202,7 +202,7 @@ # else /* !defined __ARM_NEON__ */ /* The 'intrinsics' code simply won't compile without this -mfpu=neon: */ -# if !defined(__aarch64__) +# if !defined(__aarch64__) && !defined(_M_ARM64) /* The assembler code currently does not work on ARM64 */ # define PNG_ARM_NEON_IMPLEMENTATION 2 # endif /* __aarch64__ */ @@ -213,6 +213,8 @@ /* Use the intrinsics code by default. */ # define PNG_ARM_NEON_IMPLEMENTATION 1 # endif +#else /* PNG_ARM_NEON_OPT == 0 */ +# define PNG_ARM_NEON_IMPLEMENTATION 0 #endif /* PNG_ARM_NEON_OPT > 0 */ #ifndef PNG_MIPS_MSA_OPT @@ -291,11 +293,15 @@ # ifndef PNG_MIPS_MSA_IMPLEMENTATION # define PNG_MIPS_MSA_IMPLEMENTATION 1 # endif +#else +# define PNG_MIPS_MSA_IMPLEMENTATION 0 #endif /* PNG_MIPS_MSA_OPT > 0 */ #if PNG_POWERPC_VSX_OPT > 0 # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx # define PNG_POWERPC_VSX_IMPLEMENTATION 1 +#else +# define PNG_POWERPC_VSX_IMPLEMENTATION 0 #endif @@ -520,16 +526,7 @@ static_cast(static_cast(value)) #else # define png_voidcast(type, value) (value) -# ifdef _WIN64 -# ifdef __GNUC__ - typedef unsigned long long png_ptruint; -# else - typedef unsigned __int64 png_ptruint; -# endif -# else - typedef unsigned long png_ptruint; -# endif -# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value)) +# define png_constcast(type, value) ((type)(void*)(const void*)(value)) # define png_aligncast(type, value) ((void*)(value)) # define png_aligncastconst(type, value) ((const void*)(value)) #endif /* __cplusplus */ @@ -571,9 +568,8 @@ # include #endif -#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ - defined(_WIN32) || defined(__WIN32__) -# include /* defines _WINDOWS_ macro */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) +# include #endif #endif /* PNG_VERSION_INFO_ONLY */ @@ -582,24 +578,20 @@ * functions that are passed far data must be model-independent. */ -/* Memory model/platform independent fns */ +/* Platform-independent functions */ #ifndef PNG_ABORT -# ifdef _WINDOWS_ -# define PNG_ABORT() ExitProcess(0) -# else -# define PNG_ABORT() abort() -# endif +# define PNG_ABORT() abort() #endif /* These macros may need to be architecture dependent. */ -#define PNG_ALIGN_NONE 0 /* do not use data alignment */ -#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ +#define PNG_ALIGN_NONE 0 /* do not use data alignment */ +#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ #ifdef offsetof -# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ +# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ #else # define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ #endif -#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ +#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ #ifndef PNG_ALIGN_TYPE /* Default to using aligned access optimizations and requiring alignment to a @@ -613,26 +605,25 @@ /* This is used because in some compiler implementations non-aligned * structure members are supported, so the offsetof approach below fails. * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access - * is good for performance. Do not do this unless you have tested the result - * and understand it. + * is good for performance. Do not do this unless you have tested the + * result and understand it. */ -# define png_alignof(type) (sizeof (type)) +# define png_alignof(type) (sizeof(type)) #else # if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET -# define png_alignof(type) offsetof(struct{char c; type t;}, t) +# define png_alignof(type) offsetof(struct{char c; type t;}, t) # else -# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS -# define png_alignof(type) (1) -# endif - /* Else leave png_alignof undefined to prevent use thereof */ +# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS +# define png_alignof(type) 1 +# endif + /* Else leave png_alignof undefined to prevent use thereof */ # endif #endif -/* This implicitly assumes alignment is always to a power of 2. */ +/* This implicitly assumes alignment is always a multiple of 2. */ #ifdef png_alignof -# define png_isaligned(ptr, type)\ - (((type)((const char*)ptr-(const char*)0) & \ - (type)(png_alignof(type)-1)) == 0) +# define png_isaligned(ptr, type) \ + (((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0) #else # define png_isaligned(ptr, type) 0 #endif diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c index b558c5716f8..3631e60f36b 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c @@ -3480,7 +3480,6 @@ png_image_read_background(png_voidp argument) for (pass = 0; pass < passes; ++pass) { - png_bytep row = png_voidcast(png_bytep, display->first_row); unsigned int startx, stepx, stepy; png_uint_32 y; @@ -3585,8 +3584,6 @@ png_image_read_background(png_voidp argument) inrow += 2; /* gray and alpha channel */ } - - row += display->row_bytes; } } } diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c index efe7135553a..843eb5fff2a 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c @@ -49,7 +49,7 @@ #ifdef PNG_ARM_NEON_IMPLEMENTATION # if PNG_ARM_NEON_IMPLEMENTATION == 1 # define PNG_ARM_NEON_INTRINSICS_AVAILABLE -# if defined(_MSC_VER) && defined(_M_ARM64) +# if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64) # include # else # include diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c index 5c6244116af..d41a6d09b27 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -329,7 +329,6 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) if (buffer != NULL && new_size > png_ptr->read_buffer_size) { - png_ptr->read_buffer = NULL; png_ptr->read_buffer = NULL; png_ptr->read_buffer_size = 0; png_free(png_ptr, buffer); @@ -2104,21 +2103,22 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_byte buf[1]; png_crc_read(png_ptr, buf, 1); info_ptr->eXIf_buf[i] = buf[0]; - if (i == 1 && buf[0] != 'M' && buf[0] != 'I' - && info_ptr->eXIf_buf[0] != buf[0]) + if (i == 1) { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); - png_free(png_ptr, info_ptr->eXIf_buf); - info_ptr->eXIf_buf = NULL; - return; + if ((buf[0] != 'M' && buf[0] != 'I') || + (info_ptr->eXIf_buf[0] != buf[0])) + { + png_crc_finish(png_ptr, length - 2); + png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; + return; + } } } - if (png_crc_finish(png_ptr, 0) != 0) - return; - - png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); + if (png_crc_finish(png_ptr, 0) == 0) + png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); png_free(png_ptr, info_ptr->eXIf_buf); info_ptr->eXIf_buf = NULL; @@ -2154,8 +2154,9 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || - num > (unsigned int) PNG_MAX_PALETTE_LENGTH) + if (length != num * 2 || + num != (unsigned int)png_ptr->num_palette || + num > (unsigned int)PNG_MAX_PALETTE_LENGTH) { png_crc_finish(png_ptr, length); png_chunk_benign_error(png_ptr, "invalid"); @@ -4649,14 +4650,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) */ { png_bytep temp = png_ptr->big_row_buf + 32; - int extra = (int)((temp - (png_bytep)0) & 0x0f); + size_t extra = (size_t)temp & 0x0f; png_ptr->row_buf = temp - extra - 1/*filter byte*/; temp = png_ptr->big_prev_row + 32; - extra = (int)((temp - (png_bytep)0) & 0x0f); + extra = (size_t)temp & 0x0f; png_ptr->prev_row = temp - extra - 1/*filter byte*/; } - #else /* Use 31 bytes of padding before and 17 bytes after row_buf. */ png_ptr->row_buf = png_ptr->big_row_buf + 31; diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c index 1b075795b65..ea7decaa065 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -1047,6 +1047,9 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans); + + info_ptr->valid |= PNG_INFO_tRNS; + info_ptr->free_me |= PNG_FREE_TRNS; } png_ptr->trans_alpha = info_ptr->trans_alpha; } @@ -1354,7 +1357,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_MNG_FEATURES_SUPPORTED png_uint_32 PNGAPI -png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) +png_permit_mng_features(png_structrp png_ptr, png_uint_32 mng_features) { png_debug(1, "in png_permit_mng_features"); @@ -1661,7 +1664,7 @@ png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) #ifdef PNG_SET_USER_LIMITS_SUPPORTED /* This function was added to libpng 1.2.6 */ void PNGAPI -png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, +png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max) { /* Images with dimensions larger than these limits will be @@ -1677,7 +1680,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, /* This function was added to libpng 1.4.0 */ void PNGAPI -png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) +png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max) { if (png_ptr != NULL) png_ptr->user_chunk_cache_max = user_chunk_cache_max; @@ -1685,7 +1688,7 @@ png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) /* This function was added to libpng 1.4.1 */ void PNGAPI -png_set_chunk_malloc_max (png_structrp png_ptr, +png_set_chunk_malloc_max(png_structrp png_ptr, png_alloc_size_t user_chunk_malloc_max) { if (png_ptr != NULL) diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h index 1f53e0534af..f153bdec602 100644 --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -362,18 +362,8 @@ struct png_struct_def size_t current_buffer_size; /* amount of data now in current_buffer */ int process_mode; /* what push library is currently doing */ int cur_palette; /* current push library palette index */ - #endif /* PROGRESSIVE_READ */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* For the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - #ifdef PNG_READ_QUANTIZE_SUPPORTED png_bytep palette_lookup; /* lookup table for quantizing */ png_bytep quantize_index; /* index translation for palette files */ From 271c46b8c842d3c9899a81de06dd884c5704a4c1 Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Mon, 30 Jan 2023 16:32:36 +0000 Subject: [PATCH 099/205] 7188098: TEST_BUG: closed/javax/sound/midi/Synthesizer/Receiver/bug6186488.java fails Backport-of: c640fe42c2b5e6668a2a875678be44443942c868 --- .../midi/Synthesizer/Receiver/bug6186488.java | 189 +++++++++++++++--- 1 file changed, 160 insertions(+), 29 deletions(-) diff --git a/test/jdk/javax/sound/midi/Synthesizer/Receiver/bug6186488.java b/test/jdk/javax/sound/midi/Synthesizer/Receiver/bug6186488.java index d2634a306c3..355d0c31a52 100644 --- a/test/jdk/javax/sound/midi/Synthesizer/Receiver/bug6186488.java +++ b/test/jdk/javax/sound/midi/Synthesizer/Receiver/bug6186488.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -21,52 +21,183 @@ * questions. */ +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import javax.sound.midi.MidiDevice; import javax.sound.midi.MidiMessage; import javax.sound.midi.MidiSystem; +import javax.sound.midi.MidiUnavailableException; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; +import javax.swing.JTextArea; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.Timer; +import javax.swing.JPanel; +import javax.swing.WindowConstants; -/** +/* * @test * @bug 6186488 * @summary Tests that software Java Syntesizer processed * non-ShortMessage-derived messages - * @run main/manual=yesno bug6186488 + * @run main/manual bug6186488 */ public class bug6186488 { - public static void main(String[] args) throws Exception { - MidiDevice/*Synthesizer*/ synth = null; + private static final CountDownLatch countDownLatch = new CountDownLatch(1); + private static final int testTimeout = 300000; + private static volatile String testFailureMsg; + private static volatile boolean testPassed; + private static volatile boolean testFinished; + public static void main(String[] args) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(() -> createAndShowTestDialog()); try { - synth = MidiSystem.getSynthesizer(); - //synth = MidiSystem.getMidiDevice(infos[0]); + if (!countDownLatch.await(testTimeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(String.format("Test timeout '%d ms' elapsed.", testTimeout)); + } + if (!testPassed) { + String failureMsg = testFailureMsg; + if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) { + throw new RuntimeException(failureMsg); + } else { + throw new RuntimeException("Test failed."); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } finally { + testFinished = true; + } + } + private static void pass() { + testPassed = true; + countDownLatch.countDown(); + } + + private static void fail(String failureMsg) { + testFailureMsg = failureMsg; + testPassed = false; + countDownLatch.countDown(); + } + + private static String convertMillisToTimeStr(int millis) { + if (millis < 0) { + return "00:00:00"; + } + int hours = millis / 3600000; + int minutes = (millis - hours * 3600000) / 60000; + int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000; + return String.format("%02d:%02d:%02d", hours, minutes, seconds); + } + + private static void createAndShowTestDialog() { + String testInstruction = "This test verify that software Java Syntesizer processed non-ShortMessage-derived messages.\n" + + "Close all other programs that may use the sound card.\n" + + "Make sure that the speakers are connected and the volume is up.\n" + + "Click on 'Start Test' button. If you listen a sound then test pass else test fail."; + + final JDialog dialog = new JDialog(); + dialog.setTitle("Test Sound"); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + dialog.dispose(); + fail("Main dialog was closed."); + } + }); + + final JLabel testTimeoutLabel = new JLabel(String.format("Test timeout: %s", convertMillisToTimeStr(testTimeout))); + final long startTime = System.currentTimeMillis(); + final Timer timer = new Timer(0, null); + timer.setDelay(1000); + timer.addActionListener((e) -> { + int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime); + if ((leftTime < 0) || testFinished) { + timer.stop(); + dialog.dispose(); + } + testTimeoutLabel.setText(String.format("Test timeout: %s", convertMillisToTimeStr(leftTime))); + }); + timer.start(); + + JTextArea textArea = new JTextArea(testInstruction); + textArea.setEditable(false); + + final JButton startTestButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + final JButton failButton = new JButton("FAIL"); + startTestButton.addActionListener((e) -> { + new Thread(() -> { + try { + doTest(); + + SwingUtilities.invokeLater(() -> { + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + } catch (Throwable t) { + t.printStackTrace(); + dialog.dispose(); + fail("Exception occurred in a thread executing the test."); + } + }).start(); + }); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail("Expected that sound will be heard but did not hear sound"); + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel labelPanel = new JPanel(new FlowLayout()); + labelPanel.add(testTimeoutLabel); + mainPanel.add(labelPanel, BorderLayout.NORTH); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(startTestButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + } + + public static void waitForSynToOpen(MidiDevice synth) throws InterruptedException { + int count = 0; + do { + if (synth.isOpen()) { + System.out.println("synth is opened"); + return; + } + TimeUnit.SECONDS.sleep(1); + } while( ++count >= 5); + throw new RuntimeException(synth + " did not open even after 5 seconds"); + } + + private static void doTest() throws MidiUnavailableException, InterruptedException { + try (MidiDevice synth = MidiSystem.getSynthesizer()) { System.out.println("Synthesizer: " + synth.getDeviceInfo()); synth.open(); + waitForSynToOpen(synth); MidiMessage msg = new GenericMidiMessage(0x90, 0x3C, 0x40); - //ShortMessage msg = new ShortMessage(); - //msg.setMessage(0x90, 0x3C, 0x40); - synth.getReceiver().send(msg, 0); Thread.sleep(2000); - - } catch (Exception ex) { - ex.printStackTrace(); - throw ex; - } finally { - if (synth != null && synth.isOpen()) - synth.close(); - } - System.out.print("Did you heard a note? (enter 'y' or 'n') "); - int result = System.in.read(); - System.in.skip(1000); - if (result == 'y' || result == 'Y') - { - System.out.println("Test passed sucessfully."); - } - else - { - System.out.println("Test FAILED."); - throw new RuntimeException("Test failed."); } } From 64d7622f8b1f35bec8e2817fe694d207ee0cd1ee Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Tue, 31 Jan 2023 09:40:22 +0000 Subject: [PATCH 100/205] 8301397: [11u, 17u] Bump jtreg to fix issue with build JDK 11.0.18 Reviewed-by: goetz Backport-of: 0e98d6a81a395741f992df97d98b4e07679951ea --- make/conf/github-actions.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf index 04d6e54ddc5..88c8cc25689 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+2 +JTREG_VERSION=6.1+3 LINUX_X64_BOOT_JDK_EXT=tar.gz LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz From 727ae39586fd4ad15078eaabc81d0ccdcfee9877 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 1 Feb 2023 08:05:14 +0000 Subject: [PATCH 101/205] 8295405: Add cause in a couple of IllegalArgumentException and InvalidParameterException shown by sun/security/pkcs11 tests Reviewed-by: phh Backport-of: d5d34241e21305379f1858556f225e7645cd294e --- .../security/tools/keytool/CertAndKeyGen.java | 8 ++++---- .../classes/sun/security/pkcs11/Config.java | 18 +++++++++++++----- .../sun/security/pkcs11/P11AEADCipher.java | 4 ++-- .../security/pkcs11/P11KeyPairGenerator.java | 2 +- .../sun/security/pkcs11/P11KeyStore.java | 2 +- .../sun/security/pkcs11/P11PSSSignature.java | 2 +- .../sun/security/pkcs11/P11Signature.java | 4 ++-- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java b/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java index 8ceab17e8e3..30647a0e1b1 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -144,7 +144,7 @@ public void generate(String name) { } } catch (Exception e) { - throw new IllegalArgumentException(e.getMessage()); + throw new IllegalArgumentException(e.getMessage(), e); } generateInternal(); } @@ -160,7 +160,7 @@ public void generate(int keyBits) { keyGen.initialize(keyBits, prng); } catch (Exception e) { - throw new IllegalArgumentException(e.getMessage()); + throw new IllegalArgumentException(e.getMessage(), e); } } generateInternal(); @@ -317,7 +317,7 @@ public X509Certificate getSelfCertificate (X500Name myname, Date firstDate, } catch (IOException e) { throw new CertificateEncodingException("getSelfCert: " + - e.getMessage()); + e.getMessage(), e); } catch (InvalidAlgorithmParameterException e2) { throw new SignatureException( "Unsupported PSSParameterSpec: " + e2.getMessage()); diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java index 3bcef1fac3e..83b633358ac 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java @@ -357,7 +357,7 @@ private static String expand(final String s) throws IOException { try { return PropertyExpander.expand(s); } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e.getMessage(), e); } } @@ -395,6 +395,10 @@ private ConfigurationException excLine(String msg) { return new ConfigurationException(msg + ", line " + st.lineno()); } + private ConfigurationException excLine(String msg, Throwable e) { + return new ConfigurationException(msg + ", line " + st.lineno(), e); + } + private void parse() throws IOException { while (true) { int token = nextToken(); @@ -799,7 +803,7 @@ private long parseMechanism(String mech) throws IOException { try { return Functions.getMechanismId(mech); } catch (IllegalArgumentException e) { - throw excLine("Unknown mechanism: " + mech); + throw excLine("Unknown mechanism: " + mech, e); } } } @@ -959,7 +963,7 @@ private long parseObjectClass() throws IOException { try { return Functions.getObjectClassId(name); } catch (IllegalArgumentException e) { - throw excLine("Unknown object class " + name); + throw excLine("Unknown object class " + name, e); } } @@ -971,7 +975,7 @@ private long parseKeyAlgorithm() throws IOException { try { return Functions.getKeyId(name); } catch (IllegalArgumentException e) { - throw excLine("Unknown key algorithm " + name); + throw excLine("Unknown key algorithm " + name, e); } } } @@ -983,7 +987,7 @@ private long decodeAttributeName(String name) throws IOException { try { return Functions.getAttributeId(name); } catch (IllegalArgumentException e) { - throw excLine("Unknown attribute name " + name); + throw excLine("Unknown attribute name " + name, e); } } } @@ -1039,4 +1043,8 @@ class ConfigurationException extends IOException { ConfigurationException(String msg) { super(msg); } + + ConfigurationException(String msg, Throwable e) { + super(msg, e); + } } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11AEADCipher.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11AEADCipher.java index bae116e2bdf..7f8d4a3a390 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11AEADCipher.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11AEADCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, 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 @@ -139,7 +139,7 @@ private enum Transformation { try { engineSetPadding(algoParts[2]); } catch (NoSuchPaddingException e) { - throw new NoSuchAlgorithmException(); + throw new NoSuchAlgorithmException(e); } } else if (algoParts[0].equals("ChaCha20-Poly1305")) { fixedKeySize = 32; diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java index f13ae3cd67d..1301f8f2bcb 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java @@ -145,7 +145,7 @@ public void initialize(int keySize, SecureRandom random) { try { checkKeySize(keySize, null); } catch (InvalidAlgorithmParameterException e) { - throw new InvalidParameterException(e.getMessage()); + throw (InvalidParameterException) new InvalidParameterException(e.getMessage()).initCause(e); } this.params = null; if (algorithm.equals("EC")) { diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java index c9c2362bcc1..0ab49c46c27 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java @@ -1321,7 +1321,7 @@ private PrivateKey loadPkey(Session session, long oHandle) RSAKeyFactory.checkKeyLengths(keyLength, null, -1, Integer.MAX_VALUE); } catch (InvalidKeyException e) { - throw new KeyStoreException(e.getMessage()); + throw new KeyStoreException(e.getMessage(), e); } return P11Key.privateKey(session, diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11PSSSignature.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11PSSSignature.java index a1542f56ad6..26eaa4735f1 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11PSSSignature.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11PSSSignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, 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 diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java index 94d38ffcd6f..e3af106d05a 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java @@ -440,7 +440,7 @@ private void checkRSAKeyLength(int len) throws InvalidKeyException { padding = RSAPadding.getInstance (RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3); } catch (InvalidAlgorithmParameterException iape) { - throw new InvalidKeyException(iape.getMessage()); + throw new InvalidKeyException(iape.getMessage(), iape); } int maxDataSize = padding.getMaxDataSize(); int encodedLength; @@ -801,7 +801,7 @@ private static byte[] dsaToASN1(byte[] signature) { DerValue result = new DerValue(DerValue.tag_Sequence, outseq.toByteArray()); return result.toByteArray(); - } catch (java.io.IOException e) { + } catch (IOException e) { throw new RuntimeException("Internal error", e); } } From a6d4402a74449defc6b426feb47dceeb7538a713 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 1 Feb 2023 09:12:08 +0000 Subject: [PATCH 102/205] 8217730: Split up MakeBase.gmk Reviewed-by: phh Backport-of: 16271669822c7500b60fc4da6268f682d0ba581c --- make/common/CopyFiles.gmk | 112 +++++++ make/common/MakeBase.gmk | 599 +------------------------------------- make/common/MakeIO.gmk | 272 +++++++++++++++++ make/common/Utils.gmk | 304 +++++++++++++++++++ 4 files changed, 697 insertions(+), 590 deletions(-) create mode 100644 make/common/CopyFiles.gmk create mode 100644 make/common/MakeIO.gmk create mode 100644 make/common/Utils.gmk diff --git a/make/common/CopyFiles.gmk b/make/common/CopyFiles.gmk new file mode 100644 index 00000000000..ac2ef69b4b1 --- /dev/null +++ b/make/common/CopyFiles.gmk @@ -0,0 +1,112 @@ +# +# 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 +# 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. +# + +ifeq (,$(_MAKEBASE_GMK)) + $(error You must include MakeBase.gmk prior to including CopyFiles.gmk) +endif + +################################################################################ +# +# Code for handling the SetupCopyFiles macro. +# +################################################################################ + +define AddFileToCopy + # Helper macro for SetupCopyFiles + # 1 : Source file + # 2 : Dest file + # 3 : Variable to add targets to + # 4 : Macro to call for copy operation + # 5 : Action text to log + $2: $1 + $$(call LogInfo, $(strip $5) $$(patsubst $(OUTPUTDIR)/%,%,$$(call DecodeSpace, $$@))) + $$($$(strip $4)) + + $3 += $2 + $3_SOURCES += $1 +endef + +# Returns the value of the first argument +identity = \ + $(strip $1) + +# Setup make rules for copying files, with an option to do more complex +# processing instead of copying. +# +# Parameter 1 is the name of the rule. This name is used as variable prefix, +# and the targets generated are listed in a variable by that name. +# +# The list of all source files is returned in $1_SOURCES. +# +# Remaining parameters are named arguments. These include: +# SRC : Source root dir (defaults to dir of first file) +# DEST : Dest root dir +# FILES : List of files to copy with absolute paths, or path relative to SRC. +# Must be in SRC. +# FLATTEN : Set to flatten the directory structure in the DEST dir. +# MACRO : Optionally override the default macro used for making the copy. +# Default is 'install-file' +# NAME_MACRO : Optionally supply a macro that rewrites the target file name +# based on the source file name +# LOG_ACTION : Optionally specify a different action text for log messages +SetupCopyFiles = $(NamedParamsMacroTemplate) +define SetupCopyFilesBody + + ifeq ($$($1_MACRO), ) + $1_MACRO := install-file + endif + + # Default SRC to the dir of the first file. + ifeq ($$($1_SRC), ) + $1_SRC := $$(dir $$(firstword $$($1_FILES))) + endif + + ifeq ($$($1_NAME_MACRO), ) + $1_NAME_MACRO := identity + endif + + ifeq ($$($1_LOG_ACTION), ) + $1_LOG_ACTION := Copying + endif + + # Remove any trailing slash from SRC and DEST + $1_SRC := $$(patsubst %/,%,$$($1_SRC)) + $1_DEST := $$(patsubst %/,%,$$($1_DEST)) + + # Need to wrap arguments in DoubleDollar because of the eval nested inside an + # eval macro body. + $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \ + $$(eval $$(call AddFileToCopy, \ + $$(call DoubleDollar, $$($1_SRC)/$$f), \ + $$(call DoubleDollar, \ + $$($1_DEST)/$$(call $$(strip $$($1_NAME_MACRO)),$$(if $$($1_FLATTEN),$$(notdir $$f),$$f)) \ + ), \ + $1, \ + $$($1_MACRO), \ + $$($1_LOG_ACTION) \ + )) \ + ) + +endef diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 49fbccd640a..2f892338be4 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, 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 @@ -75,17 +75,17 @@ ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION)))) RWILDCARD_WORKS := true endif -############################## -# Functions -############################## -### Debug functions +# For convenience, MakeBase.gmk continues to include these separate files, at +# least for now. -# Prints the name and value of a variable -PrintVar = \ - $(info $(strip $1) >$($(strip $1))<) +include $(TOPDIR)/make/common/Utils.gmk +include $(TOPDIR)/make/common/MakeIO.gmk +include $(TOPDIR)/make/common/CopyFiles.gmk -### Functions for timers +################################################################################ +# Functions for timers +################################################################################ # Store the build times in this directory. BUILDTIMESDIR=$(OUTPUTDIR)/make-support/build-times @@ -121,227 +121,6 @@ define TargetExit "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" endef -################################################################################ -# This macro translates $ into \$ to protect the $ from expansion in the shell. -# To make this macro resilient against already escaped strings, first remove -# any present escapes before escaping so that no double escapes are added. -EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1))) - -################################################################################ -# This macro works just like EscapeDollar above, but for #. -EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1))) - -################################################################################ -# This macro translates $ into $$ to protect the string from make itself. -DoubleDollar = $(subst $$,$$$$,$(strip $1)) - -################################################################################ -# ListPathsSafely can be used to print command parameters to a file. This is -# typically done if the command line lenght risk being too long for the -# OS/shell. In later make versions, the file function can be used for this -# purpose. For earlier versions, a more complex implementation is provided. -# -# The function ListPathsSafely can be called either directly or, more commonly -# from a recipe line. If called from a recipe, it will be executed in the -# evaluation phase of that recipe, which means that it will write to the file -# before any other line in the recipe has been run. -ifeq ($(HAS_FILE_FUNCTION), true) - # Param 1 - Name of variable containing paths/arguments to output - # Param 2 - File to print to - # Param 3 - Set to true to append to file instead of overwriting - define ListPathsSafely - $$(call MakeDir, $$(dir $$(strip $2))) - $$(file $$(if $$(filter true, $$(strip $3)),>>,>) \ - $$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1))))) - endef - -else # HAS_FILE_FUNCTION = false - - $(eval compress_paths = \ - $(strip $(shell $(CAT) $(TOPDIR)/make/common/support/ListPathsSafely-pre-compress.incl))) - compress_paths += \ - $(subst $(TOPDIR),X97, \ - $(subst $(OUTPUTDIR),X98, \ - $(subst X,X00, \ - $(subst $(SPACE),\n,$(strip $1))))) - $(eval compress_paths += \ - $(strip $(shell $(CAT) $(TOPDIR)/make/common/support/ListPathsSafely-post-compress.incl))) - - decompress_paths=$(SED) -f $(TOPDIR)/make/common/support/ListPathsSafely-uncompress.sed \ - -e 's|X99|\\n|g' \ - -e 's|X98|$(OUTPUTDIR)|g' -e 's|X97|$(TOPDIR)|g' \ - -e 's|X00|X|g' - - ListPathsSafely_IfPrintf = \ - $(if $(word $3,$($(strip $1))), \ - $(shell $(PRINTF) -- "$(strip $(call EscapeDollar, \ - $(call compress_paths, $(wordlist $3,$4,$($(strip $1))))))\n" \ - | $(decompress_paths) >> $2)) - - # Param 1 - Name of variable containing paths/arguments to output - # Param 2 - File to print to - # Param 3 - Set to true to append to file instead of overwriting - define ListPathsSafely - ifneq (,$$(word 30001,$$($$(strip $1)))) - $$(error Cannot list safely more than 30000 paths. $1 has $$(words $$($$(strip $1))) paths!) - endif - $$(call MakeDir, $$(dir $2)) - ifneq ($$(strip $3), true) - $$(shell $(RM) $$(strip $2)) - endif - - $$(call ListPathsSafely_IfPrintf,$1,$2,1,250) - $$(call ListPathsSafely_IfPrintf,$1,$2,251,500) - $$(call ListPathsSafely_IfPrintf,$1,$2,501,750) - $$(call ListPathsSafely_IfPrintf,$1,$2,751,1000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,1001,1250) - $$(call ListPathsSafely_IfPrintf,$1,$2,1251,1500) - $$(call ListPathsSafely_IfPrintf,$1,$2,1501,1750) - $$(call ListPathsSafely_IfPrintf,$1,$2,1751,2000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,2001,2250) - $$(call ListPathsSafely_IfPrintf,$1,$2,2251,2500) - $$(call ListPathsSafely_IfPrintf,$1,$2,2501,2750) - $$(call ListPathsSafely_IfPrintf,$1,$2,2751,3000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,3001,3250) - $$(call ListPathsSafely_IfPrintf,$1,$2,3251,3500) - $$(call ListPathsSafely_IfPrintf,$1,$2,3501,3750) - $$(call ListPathsSafely_IfPrintf,$1,$2,3751,4000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,4001,4250) - $$(call ListPathsSafely_IfPrintf,$1,$2,4251,4500) - $$(call ListPathsSafely_IfPrintf,$1,$2,4501,4750) - $$(call ListPathsSafely_IfPrintf,$1,$2,4751,5000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,5001,5250) - $$(call ListPathsSafely_IfPrintf,$1,$2,5251,5500) - $$(call ListPathsSafely_IfPrintf,$1,$2,5501,5750) - $$(call ListPathsSafely_IfPrintf,$1,$2,5751,6000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,6001,6250) - $$(call ListPathsSafely_IfPrintf,$1,$2,6251,6500) - $$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750) - $$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250) - $$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500) - $$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750) - $$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250) - $$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500) - $$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750) - $$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250) - $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500) - $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750) - $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,10001,10250) - $$(call ListPathsSafely_IfPrintf,$1,$2,10251,10500) - $$(call ListPathsSafely_IfPrintf,$1,$2,10501,10750) - $$(call ListPathsSafely_IfPrintf,$1,$2,10751,11000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,11001,11250) - $$(call ListPathsSafely_IfPrintf,$1,$2,11251,11500) - $$(call ListPathsSafely_IfPrintf,$1,$2,11501,11750) - $$(call ListPathsSafely_IfPrintf,$1,$2,11751,12000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,12001,12250) - $$(call ListPathsSafely_IfPrintf,$1,$2,12251,12500) - $$(call ListPathsSafely_IfPrintf,$1,$2,12501,12750) - $$(call ListPathsSafely_IfPrintf,$1,$2,12751,13000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,13001,13250) - $$(call ListPathsSafely_IfPrintf,$1,$2,13251,13500) - $$(call ListPathsSafely_IfPrintf,$1,$2,13501,13750) - $$(call ListPathsSafely_IfPrintf,$1,$2,13751,14000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,14001,14250) - $$(call ListPathsSafely_IfPrintf,$1,$2,14251,14500) - $$(call ListPathsSafely_IfPrintf,$1,$2,14501,14750) - $$(call ListPathsSafely_IfPrintf,$1,$2,14751,15000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,15001,15250) - $$(call ListPathsSafely_IfPrintf,$1,$2,15251,15500) - $$(call ListPathsSafely_IfPrintf,$1,$2,15501,15750) - $$(call ListPathsSafely_IfPrintf,$1,$2,15751,16000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,16001,16250) - $$(call ListPathsSafely_IfPrintf,$1,$2,16251,16500) - $$(call ListPathsSafely_IfPrintf,$1,$2,16501,16750) - $$(call ListPathsSafely_IfPrintf,$1,$2,16751,17000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,17001,17250) - $$(call ListPathsSafely_IfPrintf,$1,$2,17251,17500) - $$(call ListPathsSafely_IfPrintf,$1,$2,17501,17750) - $$(call ListPathsSafely_IfPrintf,$1,$2,17751,18000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,18001,18250) - $$(call ListPathsSafely_IfPrintf,$1,$2,18251,18500) - $$(call ListPathsSafely_IfPrintf,$1,$2,18501,18750) - $$(call ListPathsSafely_IfPrintf,$1,$2,18751,19000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,19001,19250) - $$(call ListPathsSafely_IfPrintf,$1,$2,19251,19500) - $$(call ListPathsSafely_IfPrintf,$1,$2,19501,19750) - $$(call ListPathsSafely_IfPrintf,$1,$2,19751,20000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,20001,20250) - $$(call ListPathsSafely_IfPrintf,$1,$2,20251,20500) - $$(call ListPathsSafely_IfPrintf,$1,$2,20501,20750) - $$(call ListPathsSafely_IfPrintf,$1,$2,20751,21000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,21001,21250) - $$(call ListPathsSafely_IfPrintf,$1,$2,21251,21500) - $$(call ListPathsSafely_IfPrintf,$1,$2,21501,21750) - $$(call ListPathsSafely_IfPrintf,$1,$2,21751,22000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,22001,22250) - $$(call ListPathsSafely_IfPrintf,$1,$2,22251,22500) - $$(call ListPathsSafely_IfPrintf,$1,$2,22501,22750) - $$(call ListPathsSafely_IfPrintf,$1,$2,22751,23000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,23001,23250) - $$(call ListPathsSafely_IfPrintf,$1,$2,23251,23500) - $$(call ListPathsSafely_IfPrintf,$1,$2,23501,23750) - $$(call ListPathsSafely_IfPrintf,$1,$2,23751,24000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,24001,24250) - $$(call ListPathsSafely_IfPrintf,$1,$2,24251,24500) - $$(call ListPathsSafely_IfPrintf,$1,$2,24501,24750) - $$(call ListPathsSafely_IfPrintf,$1,$2,24751,25000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,25001,25250) - $$(call ListPathsSafely_IfPrintf,$1,$2,25251,25500) - $$(call ListPathsSafely_IfPrintf,$1,$2,25501,25750) - $$(call ListPathsSafely_IfPrintf,$1,$2,25751,26000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,26001,26250) - $$(call ListPathsSafely_IfPrintf,$1,$2,26251,26500) - $$(call ListPathsSafely_IfPrintf,$1,$2,26501,26750) - $$(call ListPathsSafely_IfPrintf,$1,$2,26751,27000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,27001,27250) - $$(call ListPathsSafely_IfPrintf,$1,$2,27251,27500) - $$(call ListPathsSafely_IfPrintf,$1,$2,27501,27750) - $$(call ListPathsSafely_IfPrintf,$1,$2,27751,28000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,28001,28250) - $$(call ListPathsSafely_IfPrintf,$1,$2,28251,28500) - $$(call ListPathsSafely_IfPrintf,$1,$2,28501,28750) - $$(call ListPathsSafely_IfPrintf,$1,$2,28751,29000) - - $$(call ListPathsSafely_IfPrintf,$1,$2,29001,29250) - $$(call ListPathsSafely_IfPrintf,$1,$2,29251,29500) - $$(call ListPathsSafely_IfPrintf,$1,$2,29501,29750) - $$(call ListPathsSafely_IfPrintf,$1,$2,29751,30000) - endef -endif # HAS_FILE_FUNCTION - ################################################################################ # A file containing a way to uniquely identify the source code revision that @@ -413,21 +192,6 @@ endef # Make sure logging is setup for everyone that includes MakeBase.gmk. $(eval $(call SetupLogging)) -################################################################################ -# Creates a sequence of increasing numbers (inclusive). -# Param 1 - starting number -# Param 2 - ending number -sequence = \ - $(wordlist $1, $2, $(strip \ - $(eval SEQUENCE_COUNT :=) \ - $(call _sequence-do,$(strip $2)))) - -_sequence-do = \ - $(if $(word $1, $(SEQUENCE_COUNT)),, \ - $(eval SEQUENCE_COUNT += .) \ - $(words $(SEQUENCE_COUNT)) \ - $(call _sequence-do,$1)) - ################################################################################ MAX_PARAMS := 36 @@ -469,16 +233,6 @@ define NamedParamsMacroTemplate $(call $(0)Body,$(strip $1)) endef -################################################################################ -# Replace question marks with space in string. This macro needs to be called on -# files from FindFiles in case any of them contains space in their file name, -# since FindFiles replaces space with ?. -# Param 1 - String to replace in -DecodeSpace = \ - $(subst ?,$(SPACE),$(strip $1)) -EncodeSpace = \ - $(subst $(SPACE),?,$(strip $1)) - ################################################################################ # Make directory without forking mkdir if not needed. # @@ -506,13 +260,6 @@ MakeDir = \ MakeTargetDir = \ $(call MakeDir, $(dir $(call EncodeSpace, $@))) -################################################################################ -# Assign a variable only if it is empty -# Param 1 - Variable to assign -# Param 2 - Value to assign -SetIfEmpty = \ - $(if $($(strip $1)),,$(eval $(strip $1) := $2)) - ################################################################################ # All install-file and related macros automatically call DecodeSpace when needed. @@ -580,47 +327,6 @@ define install-file-nolink $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' endef -################################################################################ -# Take two paths and return the path of the last common directory. -# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar -# foo/bar/baz, /foo/bar -> -# -# The x prefix is used to preserve the presence of the initial slash -# -# $1 - Path to compare -# $2 - Other path to compare -FindCommonPathPrefix = \ - $(patsubst x%,%,$(subst $(SPACE),/,$(strip \ - $(call FindCommonPathPrefixHelper, \ - $(subst /,$(SPACE),x$(strip $1)), $(subst /,$(SPACE),x$(strip $2))) \ - ))) - -FindCommonPathPrefixHelper = \ - $(if $(call equals, $(firstword $1), $(firstword $2)), \ - $(firstword $1) \ - $(call FindCommonPathPrefixHelper, \ - $(wordlist 2, $(words $1), $1), $(wordlist 2, $(words $2), $2) \ - ) \ - ) - -# Convert a partial path into as many directory levels of ../, removing -# leading and following /. -# Ex: foo/bar/baz/ -> ../../.. -# foo/bar -> ../.. -# /foo -> .. -DirToDotDot = \ - $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..)) - -# Computes the relative path from a directory to a file -# $1 - File to compute the relative path to -# $2 - Directory to compute the relative path from -RelativePath = \ - $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \ - $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)%, %, $2))) \ - $(eval $1_dotdots := $(if $($(strip $1)_dotdots),$($(strip $1)_dotdots),.)) \ - $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \ - $($(strip $1)_dotdots)/$($(strip $1)_suffix) - ################################################################################ # link-file-* works similarly to install-file but creates a symlink instead. # There are two versions, either creating a relative or an absolute link. Be @@ -657,57 +363,6 @@ else endef endif -################################################################################ -# Filter out duplicate sub strings while preserving order. Keeps the first occurance. -uniq = \ - $(strip $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))) - -# Returns all whitespace-separated words in $2 where at least one of the -# whitespace-separated words in $1 is a substring. -containing = \ - $(strip \ - $(foreach v,$(strip $2),\ - $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v))))) - -# Returns all whitespace-separated words in $2 where none of the -# whitespace-separated words in $1 is a substring. -not-containing = \ - $(strip $(filter-out $(call containing,$1,$2),$2)) - -# Return a list of all string elements that are duplicated in $1. -dups = \ - $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \ - $(words $(filter $v, $1))), $v))) - -# String equals -equals = \ - $(and $(findstring $(strip $1),$(strip $2)),\ - $(findstring $(strip $2),$(strip $1))) - -# Remove a whole list of prefixes -# $1 - List of prefixes -# $2 - List of elements to process -remove-prefixes = \ - $(strip $(if $1,$(patsubst $(firstword $1)%,%,\ - $(call remove-prefixes,$(filter-out $(firstword $1),$1),$2)),$2)) - -# Convert the string given to upper case, without any $(shell) -# Inspired by http://lists.gnu.org/archive/html/help-make/2013-09/msg00009.html -uppercase_table := a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O \ - p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z - -uppercase_internal = \ - $(if $(strip $1), $$(subst $(firstword $1), $(call uppercase_internal, \ - $(wordlist 2, $(words $1), $1), $2)), $2) - -# Convert a string to upper case. Works only on a-z. -# $1 - The string to convert -uppercase = \ - $(strip \ - $(eval uppercase_result := $(call uppercase_internal, $(uppercase_table), $1)) \ - $(uppercase_result) \ - ) - ################################################################################ # Recursive wildcard function. Walks down directories recursively and matches @@ -822,144 +477,6 @@ else FindFiles = $(CacheFindFiles) endif -################################################################################ - -define AddFileToCopy - # Helper macro for SetupCopyFiles - # 1 : Source file - # 2 : Dest file - # 3 : Variable to add targets to - # 4 : Macro to call for copy operation - # 5 : Action text to log - $2: $1 - $$(call LogInfo, $(strip $5) $$(patsubst $(OUTPUTDIR)/%,%,$$(call DecodeSpace, $$@))) - $$($$(strip $4)) - - $3 += $2 - $3_SOURCES += $1 -endef - -# Returns the value of the first argument -identity = \ - $(strip $1) - -# Setup make rules for copying files, with an option to do more complex -# processing instead of copying. -# -# Parameter 1 is the name of the rule. This name is used as variable prefix, -# and the targets generated are listed in a variable by that name. -# -# The list of all source files is returned in $1_SOURCES. -# -# Remaining parameters are named arguments. These include: -# SRC : Source root dir (defaults to dir of first file) -# DEST : Dest root dir -# FILES : List of files to copy with absolute paths, or path relative to SRC. -# Must be in SRC. -# FLATTEN : Set to flatten the directory structure in the DEST dir. -# MACRO : Optionally override the default macro used for making the copy. -# Default is 'install-file' -# NAME_MACRO : Optionally supply a macro that rewrites the target file name -# based on the source file name -# LOG_ACTION : Optionally specify a different action text for log messages -SetupCopyFiles = $(NamedParamsMacroTemplate) -define SetupCopyFilesBody - - ifeq ($$($1_MACRO), ) - $1_MACRO := install-file - endif - - # Default SRC to the dir of the first file. - ifeq ($$($1_SRC), ) - $1_SRC := $$(dir $$(firstword $$($1_FILES))) - endif - - ifeq ($$($1_NAME_MACRO), ) - $1_NAME_MACRO := identity - endif - - ifeq ($$($1_LOG_ACTION), ) - $1_LOG_ACTION := Copying - endif - - # Remove any trailing slash from SRC and DEST - $1_SRC := $$(patsubst %/,%,$$($1_SRC)) - $1_DEST := $$(patsubst %/,%,$$($1_DEST)) - - # Need to wrap arguments in DoubleDollar because of the eval nested inside an - # eval macro body. - $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \ - $$(eval $$(call AddFileToCopy, \ - $$(call DoubleDollar, $$($1_SRC)/$$f), \ - $$(call DoubleDollar, \ - $$($1_DEST)/$$(call $$(strip $$($1_NAME_MACRO)),$$(if $$($1_FLATTEN),$$(notdir $$f),$$f)) \ - ), \ - $1, \ - $$($1_MACRO), \ - $$($1_LOG_ACTION) \ - )) \ - ) - -endef - -################################################################################ -# Parse a multiple-keyword variable, like FOO="KEYWORD1=val1;KEYWORD2=val2;..." -# These will be converted into a series of variables like FOO_KEYWORD1=val1, -# FOO_KEYWORD2=val2, etc. Unknown keywords will cause an error. -# -# Parameter 1 is the name of the rule, and is also the name of the variable. -# -# Remaining parameters are named arguments. These include: -# SINGLE_KEYWORDS A list of valid keywords with single string values -# STRING_KEYWORDS A list of valid keywords, processed as string. This means -# that '%20' will be replaced by ' ' to allow for multi-word strings. -# -ParseKeywordVariable = $(NamedParamsMacroTemplate) -define ParseKeywordVariableBody - ifneq ($$($1), ) - # To preserve spaces, substitute them with a hopefully unique pattern - # before splitting and then re-substitute spaces back. - $1_MANGLED := $$(subst $$(SPACE),||||,$$($1)) - $$(foreach mangled_part, $$(subst ;, , $$($1_MANGLED)), \ - $$(eval mangled_part_eval := $$(call DoubleDollar, $$(mangled_part))) \ - $$(eval part := $$$$(subst ||||,$$$$(SPACE),$$$$(mangled_part_eval))) \ - $$(eval $1_NO_MATCH := true) \ - $$(foreach keyword, $$($1_SINGLE_KEYWORDS), \ - $$(eval keyword_eval := $$(call DoubleDollar, $$(keyword))) \ - $$(if $$(filter $$(keyword)=%, $$(part)), \ - $$(eval $(strip $1)_$$$$(keyword_eval) := $$$$(strip $$$$(patsubst $$$$(keyword_eval)=%, %, $$$$(part)))) \ - $$(eval $1_NO_MATCH := ) \ - ) \ - ) \ - $$(foreach keyword, $$($1_STRING_KEYWORDS), \ - $$(eval keyword_eval := $$(call DoubleDollar, $$(keyword))) \ - $$(if $$(filter $$(keyword)=%, $$(part)), \ - $$(eval $(strip $1)_$$$$(keyword_eval) := $$$$(strip $$$$(subst %20, , $$$$(patsubst $$$$(keyword_eval)=%, %, $$$$(part))))) \ - $$(eval $1_NO_MATCH := ) \ - ) \ - ) \ - $$(if $$($1_NO_MATCH), \ - $$(if $$(filter $$(part), $$($1_SINGLE_KEYWORDS) $$($1_STRING_KEYWORDS)), \ - $$(info Keyword $$(part) for $1 needs to be assigned a value.) \ - , \ - $$(info $$(part) is not a valid keyword for $1.) \ - $$(info Valid keywords: $$($1_SINGLE_KEYWORDS) $$($1_STRING_KEYWORDS).) \ - ) \ - $$(error Cannot continue) \ - ) \ - ) - endif -endef - -################################################################################ -# ShellQuote -# -# Quotes a string with single quotes and replaces single quotes with '\'' so -# that the contents survives being given to the shell. - -ShellQuote = \ - $(SQUOTE)$(subst $(SQUOTE),$(SQUOTE)\$(SQUOTE)$(SQUOTE),$(strip $1))$(SQUOTE) - ################################################################################ # FixPath # @@ -978,35 +495,6 @@ else $1 endif -################################################################################ -# Write to and read from file - -# Param 1 - File to read -ReadFile = \ - $(shell $(CAT) $1) - -# Param 1 - Text to write -# Param 2 - File to write to -ifeq ($(HAS_FILE_FUNCTION), true) - WriteFile = \ - $(file >$2,$(strip $1)) -else - # Use printf to get consistent behavior on all platforms. - WriteFile = \ - $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2) -endif - -# Param 1 - Text to write -# Param 2 - File to write to -ifeq ($(HAS_FILE_FUNCTION), true) - AppendFile = \ - $(file >>$2,$(strip $1)) -else - # Use printf to get consistent behavior on all platforms. - AppendFile = \ - $(shell $(PRINTF) "%s" $(call ShellQuote, $1) >> $2) -endif - ################################################################################ # DependOnVariable # @@ -1093,75 +581,6 @@ ExecuteWithLog = \ $(CP) $(strip $1).cmdline $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).cmdline && \ exit $(DOLLAR)exitcode ) ) -################################################################################ -# Find lib dir for module -# Param 1 - module name -FindLibDirForModule = \ - $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) - -################################################################################ -# Find executable dir for module -# Param 1 - module name -FindExecutableDirForModule = \ - $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) - -################################################################################ -# Return a string suitable for use after a -classpath or --module-path option. It -# will be correct and safe to use on all platforms. Arguments are given as space -# separate classpath entries. Safe for multiple nested calls. -# param 1 : A space separated list of classpath entries -# The surrounding strip is needed to keep additional whitespace out -PathList = \ - "$(subst $(SPACE),:,$(strip $(subst $(DQUOTE),,$1)))" - -################################################################################ -# Check if a specified hotspot variant is being built, or at least one of a -# list of variants. Will return 'true' or 'false'. -# $1 - the variant to test for -check-jvm-variant = \ - $(strip \ - $(if $(filter-out $(VALID_JVM_VARIANTS), $1), \ - $(error Internal error: Invalid variant tested: $1)) \ - $(if $(filter $1, $(JVM_VARIANTS)), true, false)) - -################################################################################ -# Converts a space separated list to a comma separated list. -# -# Replacing double-comma with a single comma is to workaround the issue with -# some version of make on windows that doesn't substitute spaces with one comma -# properly. -CommaList = \ - $(strip \ - $(subst $(COMMA)$(COMMA),$(COMMA),$(subst $(SPACE),$(COMMA),$(strip $1))) \ - ) - -################################################################################ -# Converts a space separated list to a colon separated list. -# -# Replacing double-colon with a single colon is to workaround the issue with -# some version of make on windows that doesn't substitute spaces with one colon -# properly. -ColonList = \ - $(strip \ - $(subst ::,:,$(subst $(SPACE),:,$(strip $1))) \ - ) - -################################################################################ -# Given a list of files, filters out locale specific files for translations -# that should be excluded from this build. -# $1 - The list of files to filter -# $2 - The suffix of the files that should be considered (.java or .properties) -FilterExcludedTranslations = \ - $(strip $(if $(EXCLUDE_TRANSLATIONS), \ - $(filter-out \ - $(foreach suffix, $2, \ - $(addprefix %_, $(addsuffix $(suffix), $(EXCLUDE_TRANSLATIONS))) \ - ), \ - $1 \ - ), \ - $1 \ - )) - ################################################################################ # Hook to include the corresponding custom file, if present. diff --git a/make/common/MakeIO.gmk b/make/common/MakeIO.gmk new file mode 100644 index 00000000000..342e4f5c4b5 --- /dev/null +++ b/make/common/MakeIO.gmk @@ -0,0 +1,272 @@ +# +# 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 +# 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. +# + +ifeq (,$(_MAKEBASE_GMK)) + $(error You must include MakeBase.gmk prior to including MakeIO.gmk) +endif + +################################################################################ +# +# Functions for dealing with reading and writing from makefiles. Prior to GNU +# Make 4.0, this was tricky business. +# +################################################################################ + + +################################################################################ +# ListPathsSafely can be used to print command parameters to a file. This is +# typically done if the command line lenght risk being too long for the +# OS/shell. In later make versions, the file function can be used for this +# purpose. For earlier versions, a more complex implementation is provided. +# +# The function ListPathsSafely can be called either directly or, more commonly +# from a recipe line. If called from a recipe, it will be executed in the +# evaluation phase of that recipe, which means that it will write to the file +# before any other line in the recipe has been run. +ifeq ($(HAS_FILE_FUNCTION), true) + # Param 1 - Name of variable containing paths/arguments to output + # Param 2 - File to print to + # Param 3 - Set to true to append to file instead of overwriting + define ListPathsSafely + $$(call MakeDir, $$(dir $$(strip $2))) + $$(file $$(if $$(filter true, $$(strip $3)),>>,>) \ + $$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1))))) + endef + +else # HAS_FILE_FUNCTION = false + + $(eval compress_paths = \ + $(strip $(shell $(CAT) $(TOPDIR)/make/common/support/ListPathsSafely-pre-compress.incl))) + compress_paths += \ + $(subst $(TOPDIR),X97, \ + $(subst $(OUTPUTDIR),X98, \ + $(subst X,X00, \ + $(subst $(SPACE),\n,$(strip $1))))) + $(eval compress_paths += \ + $(strip $(shell $(CAT) $(TOPDIR)/make/common/support/ListPathsSafely-post-compress.incl))) + + decompress_paths=$(SED) -f $(TOPDIR)/make/common/support/ListPathsSafely-uncompress.sed \ + -e 's|X99|\\n|g' \ + -e 's|X98|$(OUTPUTDIR)|g' -e 's|X97|$(TOPDIR)|g' \ + -e 's|X00|X|g' + + ListPathsSafely_IfPrintf = \ + $(if $(word $3,$($(strip $1))), \ + $(shell $(PRINTF) -- "$(strip $(call EscapeDollar, \ + $(call compress_paths, $(wordlist $3,$4,$($(strip $1))))))\n" \ + | $(decompress_paths) >> $2)) + + # Param 1 - Name of variable containing paths/arguments to output + # Param 2 - File to print to + # Param 3 - Set to true to append to file instead of overwriting + define ListPathsSafely + ifneq (,$$(word 30001,$$($$(strip $1)))) + $$(error Cannot list safely more than 30000 paths. $1 has $$(words $$($$(strip $1))) paths!) + endif + $$(call MakeDir, $$(dir $2)) + ifneq ($$(strip $3), true) + $$(shell $(RM) $$(strip $2)) + endif + + $$(call ListPathsSafely_IfPrintf,$1,$2,1,250) + $$(call ListPathsSafely_IfPrintf,$1,$2,251,500) + $$(call ListPathsSafely_IfPrintf,$1,$2,501,750) + $$(call ListPathsSafely_IfPrintf,$1,$2,751,1000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,1001,1250) + $$(call ListPathsSafely_IfPrintf,$1,$2,1251,1500) + $$(call ListPathsSafely_IfPrintf,$1,$2,1501,1750) + $$(call ListPathsSafely_IfPrintf,$1,$2,1751,2000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,2001,2250) + $$(call ListPathsSafely_IfPrintf,$1,$2,2251,2500) + $$(call ListPathsSafely_IfPrintf,$1,$2,2501,2750) + $$(call ListPathsSafely_IfPrintf,$1,$2,2751,3000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,3001,3250) + $$(call ListPathsSafely_IfPrintf,$1,$2,3251,3500) + $$(call ListPathsSafely_IfPrintf,$1,$2,3501,3750) + $$(call ListPathsSafely_IfPrintf,$1,$2,3751,4000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,4001,4250) + $$(call ListPathsSafely_IfPrintf,$1,$2,4251,4500) + $$(call ListPathsSafely_IfPrintf,$1,$2,4501,4750) + $$(call ListPathsSafely_IfPrintf,$1,$2,4751,5000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,5001,5250) + $$(call ListPathsSafely_IfPrintf,$1,$2,5251,5500) + $$(call ListPathsSafely_IfPrintf,$1,$2,5501,5750) + $$(call ListPathsSafely_IfPrintf,$1,$2,5751,6000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,6001,6250) + $$(call ListPathsSafely_IfPrintf,$1,$2,6251,6500) + $$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750) + $$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250) + $$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500) + $$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750) + $$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250) + $$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500) + $$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750) + $$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250) + $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500) + $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750) + $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,10001,10250) + $$(call ListPathsSafely_IfPrintf,$1,$2,10251,10500) + $$(call ListPathsSafely_IfPrintf,$1,$2,10501,10750) + $$(call ListPathsSafely_IfPrintf,$1,$2,10751,11000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,11001,11250) + $$(call ListPathsSafely_IfPrintf,$1,$2,11251,11500) + $$(call ListPathsSafely_IfPrintf,$1,$2,11501,11750) + $$(call ListPathsSafely_IfPrintf,$1,$2,11751,12000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,12001,12250) + $$(call ListPathsSafely_IfPrintf,$1,$2,12251,12500) + $$(call ListPathsSafely_IfPrintf,$1,$2,12501,12750) + $$(call ListPathsSafely_IfPrintf,$1,$2,12751,13000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,13001,13250) + $$(call ListPathsSafely_IfPrintf,$1,$2,13251,13500) + $$(call ListPathsSafely_IfPrintf,$1,$2,13501,13750) + $$(call ListPathsSafely_IfPrintf,$1,$2,13751,14000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,14001,14250) + $$(call ListPathsSafely_IfPrintf,$1,$2,14251,14500) + $$(call ListPathsSafely_IfPrintf,$1,$2,14501,14750) + $$(call ListPathsSafely_IfPrintf,$1,$2,14751,15000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,15001,15250) + $$(call ListPathsSafely_IfPrintf,$1,$2,15251,15500) + $$(call ListPathsSafely_IfPrintf,$1,$2,15501,15750) + $$(call ListPathsSafely_IfPrintf,$1,$2,15751,16000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,16001,16250) + $$(call ListPathsSafely_IfPrintf,$1,$2,16251,16500) + $$(call ListPathsSafely_IfPrintf,$1,$2,16501,16750) + $$(call ListPathsSafely_IfPrintf,$1,$2,16751,17000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,17001,17250) + $$(call ListPathsSafely_IfPrintf,$1,$2,17251,17500) + $$(call ListPathsSafely_IfPrintf,$1,$2,17501,17750) + $$(call ListPathsSafely_IfPrintf,$1,$2,17751,18000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,18001,18250) + $$(call ListPathsSafely_IfPrintf,$1,$2,18251,18500) + $$(call ListPathsSafely_IfPrintf,$1,$2,18501,18750) + $$(call ListPathsSafely_IfPrintf,$1,$2,18751,19000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,19001,19250) + $$(call ListPathsSafely_IfPrintf,$1,$2,19251,19500) + $$(call ListPathsSafely_IfPrintf,$1,$2,19501,19750) + $$(call ListPathsSafely_IfPrintf,$1,$2,19751,20000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,20001,20250) + $$(call ListPathsSafely_IfPrintf,$1,$2,20251,20500) + $$(call ListPathsSafely_IfPrintf,$1,$2,20501,20750) + $$(call ListPathsSafely_IfPrintf,$1,$2,20751,21000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,21001,21250) + $$(call ListPathsSafely_IfPrintf,$1,$2,21251,21500) + $$(call ListPathsSafely_IfPrintf,$1,$2,21501,21750) + $$(call ListPathsSafely_IfPrintf,$1,$2,21751,22000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,22001,22250) + $$(call ListPathsSafely_IfPrintf,$1,$2,22251,22500) + $$(call ListPathsSafely_IfPrintf,$1,$2,22501,22750) + $$(call ListPathsSafely_IfPrintf,$1,$2,22751,23000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,23001,23250) + $$(call ListPathsSafely_IfPrintf,$1,$2,23251,23500) + $$(call ListPathsSafely_IfPrintf,$1,$2,23501,23750) + $$(call ListPathsSafely_IfPrintf,$1,$2,23751,24000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,24001,24250) + $$(call ListPathsSafely_IfPrintf,$1,$2,24251,24500) + $$(call ListPathsSafely_IfPrintf,$1,$2,24501,24750) + $$(call ListPathsSafely_IfPrintf,$1,$2,24751,25000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,25001,25250) + $$(call ListPathsSafely_IfPrintf,$1,$2,25251,25500) + $$(call ListPathsSafely_IfPrintf,$1,$2,25501,25750) + $$(call ListPathsSafely_IfPrintf,$1,$2,25751,26000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,26001,26250) + $$(call ListPathsSafely_IfPrintf,$1,$2,26251,26500) + $$(call ListPathsSafely_IfPrintf,$1,$2,26501,26750) + $$(call ListPathsSafely_IfPrintf,$1,$2,26751,27000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,27001,27250) + $$(call ListPathsSafely_IfPrintf,$1,$2,27251,27500) + $$(call ListPathsSafely_IfPrintf,$1,$2,27501,27750) + $$(call ListPathsSafely_IfPrintf,$1,$2,27751,28000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,28001,28250) + $$(call ListPathsSafely_IfPrintf,$1,$2,28251,28500) + $$(call ListPathsSafely_IfPrintf,$1,$2,28501,28750) + $$(call ListPathsSafely_IfPrintf,$1,$2,28751,29000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,29001,29250) + $$(call ListPathsSafely_IfPrintf,$1,$2,29251,29500) + $$(call ListPathsSafely_IfPrintf,$1,$2,29501,29750) + $$(call ListPathsSafely_IfPrintf,$1,$2,29751,30000) + endef +endif # HAS_FILE_FUNCTION + +################################################################################ +# Write to and read from file + +# Param 1 - File to read +ReadFile = \ + $(shell $(CAT) $1) + +# Param 1 - Text to write +# Param 2 - File to write to +ifeq ($(HAS_FILE_FUNCTION), true) + WriteFile = \ + $(file >$2,$(strip $1)) +else + # Use printf to get consistent behavior on all platforms. + WriteFile = \ + $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2) +endif + +# Param 1 - Text to write +# Param 2 - File to write to +ifeq ($(HAS_FILE_FUNCTION), true) + AppendFile = \ + $(file >>$2,$(strip $1)) +else + # Use printf to get consistent behavior on all platforms. + AppendFile = \ + $(shell $(PRINTF) "%s" $(call ShellQuote, $1) >> $2) +endif diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk new file mode 100644 index 00000000000..71cb38710be --- /dev/null +++ b/make/common/Utils.gmk @@ -0,0 +1,304 @@ +# +# 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 +# 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. +# + +ifeq (,$(_MAKEBASE_GMK)) + $(error You must include MakeBase.gmk prior to including Utils.gmk) +endif + +################################################################################ +# +# Common utility functions +# +################################################################################ + +### Debug functions + +# Prints the name and value of a variable +PrintVar = \ + $(info $(strip $1) >$($(strip $1))<) + +################################################################################ +# This macro translates $ into \$ to protect the $ from expansion in the shell. +# To make this macro resilient against already escaped strings, first remove +# any present escapes before escaping so that no double escapes are added. +EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1))) + +################################################################################ +# This macro works just like EscapeDollar above, but for #. +EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1))) + +################################################################################ +# This macro translates $ into $$ to protect the string from make itself. +DoubleDollar = $(subst $$,$$$$,$(strip $1)) + +################################################################################ +# Creates a sequence of increasing numbers (inclusive). +# Param 1 - starting number +# Param 2 - ending number +sequence = \ + $(wordlist $1, $2, $(strip \ + $(eval SEQUENCE_COUNT :=) \ + $(call _sequence-do,$(strip $2)))) + +_sequence-do = \ + $(if $(word $1, $(SEQUENCE_COUNT)),, \ + $(eval SEQUENCE_COUNT += .) \ + $(words $(SEQUENCE_COUNT)) \ + $(call _sequence-do,$1)) + +################################################################################ +# Replace question marks with space in string. This macro needs to be called on +# files from FindFiles in case any of them contains space in their file name, +# since FindFiles replaces space with ?. +# Param 1 - String to replace in +DecodeSpace = \ + $(subst ?,$(SPACE),$(strip $1)) +EncodeSpace = \ + $(subst $(SPACE),?,$(strip $1)) + +################################################################################ +# Assign a variable only if it is empty +# Param 1 - Variable to assign +# Param 2 - Value to assign +SetIfEmpty = \ + $(if $($(strip $1)),,$(eval $(strip $1) := $2)) + +################################################################################ +# Take two paths and return the path of the last common directory. +# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar +# foo/bar/baz, /foo/bar -> +# +# The x prefix is used to preserve the presence of the initial slash +# +# $1 - Path to compare +# $2 - Other path to compare +FindCommonPathPrefix = \ + $(patsubst x%,%,$(subst $(SPACE),/,$(strip \ + $(call FindCommonPathPrefixHelper, \ + $(subst /,$(SPACE),x$(strip $1)), $(subst /,$(SPACE),x$(strip $2))) \ + ))) + +FindCommonPathPrefixHelper = \ + $(if $(call equals, $(firstword $1), $(firstword $2)), \ + $(firstword $1) \ + $(call FindCommonPathPrefixHelper, \ + $(wordlist 2, $(words $1), $1), $(wordlist 2, $(words $2), $2) \ + ) \ + ) + +# Convert a partial path into as many directory levels of ../, removing +# leading and following /. +# Ex: foo/bar/baz/ -> ../../.. +# foo/bar -> ../.. +# /foo -> .. +DirToDotDot = \ + $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..)) + +# Computes the relative path from a directory to a file +# $1 - File to compute the relative path to +# $2 - Directory to compute the relative path from +RelativePath = \ + $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \ + $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)%, %, $2))) \ + $(eval $1_dotdots := $(if $($(strip $1)_dotdots),$($(strip $1)_dotdots),.)) \ + $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \ + $($(strip $1)_dotdots)/$($(strip $1)_suffix) + +################################################################################ +# Filter out duplicate sub strings while preserving order. Keeps the first occurance. +uniq = \ + $(strip $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))) + +# Returns all whitespace-separated words in $2 where at least one of the +# whitespace-separated words in $1 is a substring. +containing = \ + $(strip \ + $(foreach v,$(strip $2),\ + $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v))))) + +# Returns all whitespace-separated words in $2 where none of the +# whitespace-separated words in $1 is a substring. +not-containing = \ + $(strip $(filter-out $(call containing,$1,$2),$2)) + +# Return a list of all string elements that are duplicated in $1. +dups = \ + $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \ + $(words $(filter $v, $1))), $v))) + +# String equals +equals = \ + $(and $(findstring $(strip $1),$(strip $2)),\ + $(findstring $(strip $2),$(strip $1))) + +# Remove a whole list of prefixes +# $1 - List of prefixes +# $2 - List of elements to process +remove-prefixes = \ + $(strip $(if $1,$(patsubst $(firstword $1)%,%,\ + $(call remove-prefixes,$(filter-out $(firstword $1),$1),$2)),$2)) + +# Convert the string given to upper case, without any $(shell) +# Inspired by http://lists.gnu.org/archive/html/help-make/2013-09/msg00009.html +uppercase_table := a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O \ + p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z + +uppercase_internal = \ + $(if $(strip $1), $$(subst $(firstword $1), $(call uppercase_internal, \ + $(wordlist 2, $(words $1), $1), $2)), $2) + +# Convert a string to upper case. Works only on a-z. +# $1 - The string to convert +uppercase = \ + $(strip \ + $(eval uppercase_result := $(call uppercase_internal, $(uppercase_table), $1)) \ + $(uppercase_result) \ + ) + +################################################################################ +# Parse a multiple-keyword variable, like FOO="KEYWORD1=val1;KEYWORD2=val2;..." +# These will be converted into a series of variables like FOO_KEYWORD1=val1, +# FOO_KEYWORD2=val2, etc. Unknown keywords will cause an error. +# +# Parameter 1 is the name of the rule, and is also the name of the variable. +# +# Remaining parameters are named arguments. These include: +# SINGLE_KEYWORDS A list of valid keywords with single string values +# STRING_KEYWORDS A list of valid keywords, processed as string. This means +# that '%20' will be replaced by ' ' to allow for multi-word strings. +# +ParseKeywordVariable = $(NamedParamsMacroTemplate) +define ParseKeywordVariableBody + ifneq ($$($1), ) + # To preserve spaces, substitute them with a hopefully unique pattern + # before splitting and then re-substitute spaces back. + $1_MANGLED := $$(subst $$(SPACE),||||,$$($1)) + $$(foreach mangled_part, $$(subst ;, , $$($1_MANGLED)), \ + $$(eval mangled_part_eval := $$(call DoubleDollar, $$(mangled_part))) \ + $$(eval part := $$$$(subst ||||,$$$$(SPACE),$$$$(mangled_part_eval))) \ + $$(eval $1_NO_MATCH := true) \ + $$(foreach keyword, $$($1_SINGLE_KEYWORDS), \ + $$(eval keyword_eval := $$(call DoubleDollar, $$(keyword))) \ + $$(if $$(filter $$(keyword)=%, $$(part)), \ + $$(eval $(strip $1)_$$$$(keyword_eval) := $$$$(strip $$$$(patsubst $$$$(keyword_eval)=%, %, $$$$(part)))) \ + $$(eval $1_NO_MATCH := ) \ + ) \ + ) \ + $$(foreach keyword, $$($1_STRING_KEYWORDS), \ + $$(eval keyword_eval := $$(call DoubleDollar, $$(keyword))) \ + $$(if $$(filter $$(keyword)=%, $$(part)), \ + $$(eval $(strip $1)_$$$$(keyword_eval) := $$$$(strip $$$$(subst %20, , $$$$(patsubst $$$$(keyword_eval)=%, %, $$$$(part))))) \ + $$(eval $1_NO_MATCH := ) \ + ) \ + ) \ + $$(if $$($1_NO_MATCH), \ + $$(if $$(filter $$(part), $$($1_SINGLE_KEYWORDS) $$($1_STRING_KEYWORDS)), \ + $$(info Keyword $$(part) for $1 needs to be assigned a value.) \ + , \ + $$(info $$(part) is not a valid keyword for $1.) \ + $$(info Valid keywords: $$($1_SINGLE_KEYWORDS) $$($1_STRING_KEYWORDS).) \ + ) \ + $$(error Cannot continue) \ + ) \ + ) + endif +endef + +################################################################################ +# ShellQuote +# +# Quotes a string with single quotes and replaces single quotes with '\'' so +# that the contents survives being given to the shell. +ShellQuote = \ + $(SQUOTE)$(subst $(SQUOTE),$(SQUOTE)\$(SQUOTE)$(SQUOTE),$(strip $1))$(SQUOTE) + +################################################################################ +# Find lib dir for module +# Param 1 - module name +FindLibDirForModule = \ + $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) + +################################################################################ +# Find executable dir for module +# Param 1 - module name +FindExecutableDirForModule = \ + $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) + +################################################################################ +# Return a string suitable for use after a -classpath or --module-path option. It +# will be correct and safe to use on all platforms. Arguments are given as space +# separate classpath entries. Safe for multiple nested calls. +# param 1 : A space separated list of classpath entries +# The surrounding strip is needed to keep additional whitespace out +PathList = \ + "$(subst $(SPACE),:,$(strip $(subst $(DQUOTE),,$1)))" + +################################################################################ +# Check if a specified hotspot variant is being built, or at least one of a +# list of variants. Will return 'true' or 'false'. +# $1 - the variant to test for +check-jvm-variant = \ + $(strip \ + $(if $(filter-out $(VALID_JVM_VARIANTS), $1), \ + $(error Internal error: Invalid variant tested: $1)) \ + $(if $(filter $1, $(JVM_VARIANTS)), true, false)) + +################################################################################ +# Converts a space separated list to a comma separated list. +# +# Replacing double-comma with a single comma is to workaround the issue with +# some version of make on windows that doesn't substitute spaces with one comma +# properly. +CommaList = \ + $(strip \ + $(subst $(COMMA)$(COMMA),$(COMMA),$(subst $(SPACE),$(COMMA),$(strip $1))) \ + ) + +################################################################################ +# Converts a space separated list to a colon separated list. +# +# Replacing double-colon with a single colon is to workaround the issue with +# some version of make on windows that doesn't substitute spaces with one colon +# properly. +ColonList = \ + $(strip \ + $(subst ::,:,$(subst $(SPACE),:,$(strip $1))) \ + ) + +################################################################################ +# Given a list of files, filters out locale specific files for translations +# that should be excluded from this build. +# $1 - The list of files to filter +# $2 - The suffix of the files that should be considered (.java or .properties) +FilterExcludedTranslations = \ + $(strip $(if $(EXCLUDE_TRANSLATIONS), \ + $(filter-out \ + $(foreach suffix, $2, \ + $(addprefix %_, $(addsuffix $(suffix), $(EXCLUDE_TRANSLATIONS))) \ + ), \ + $1 \ + ), \ + $1 \ + )) From 54692ca250397ae799ea417cab304a509ef990a6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 1 Feb 2023 10:00:28 +0000 Subject: [PATCH 103/205] 8209935: Test to cover CodeSource.getCodeSigners() Backport-of: 0cb0ecf4433f1054ba2f0fbdabee01323893e0fe --- .../java/security/CodeSource/CertsMatch.java | 102 ++++++++++++++++++ .../jdk/java/security/CodeSource/Implies.java | 20 ++-- test/jdk/java/security/CodeSource/certs | 42 ++++++++ 3 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 test/jdk/java/security/CodeSource/CertsMatch.java create mode 100644 test/jdk/java/security/CodeSource/certs diff --git a/test/jdk/java/security/CodeSource/CertsMatch.java b/test/jdk/java/security/CodeSource/CertsMatch.java new file mode 100644 index 00000000000..0ad2650c5f9 --- /dev/null +++ b/test/jdk/java/security/CodeSource/CertsMatch.java @@ -0,0 +1,102 @@ +/* + * 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 + * 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 6299163 + * @summary Test to compare java.security.CodeSource + * Instructions to re-create the used certs file. + * - Generate a self-signed certificate with basicConstraints=CA:TRUE + * - Copy the generated certificate 2 times into a newly created certs file. + */ +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.net.URL; +import java.security.CodeSigner; +import java.security.CodeSource; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.util.ArrayList; +import java.util.List; + +public class CertsMatch { + + public static void main(String[] args) throws Exception { + + File certsFile = new File(System.getProperty("test.src", "."), "certs"); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + + try (FileInputStream fis = new FileInputStream(certsFile); + BufferedInputStream bis = new BufferedInputStream(fis)) { + + ArrayList certs1 = new ArrayList(); + ArrayList certs2 = new ArrayList(); + + // read the first cert + Certificate cert = cf.generateCertificate(bis); + certs1.add(cert); + certs2.add(cert); + + // read the second cert + cert = cf.generateCertificate(bis); + certs2.add(cert); + + URL location = certsFile.toURI().toURL(); + CodeSource cs0 = new CodeSource(location, (Certificate[]) null); + CodeSource cs1 = new CodeSource(location, + (Certificate[]) certs1.toArray(new Certificate[certs1.size()])); + CodeSource cs2 = new CodeSource(location, + (Certificate[]) certs2.toArray(new Certificate[certs2.size()])); + + if (!cs0.implies(cs1) || !cs1.implies(cs2)) { + throw new Exception("The implies method is not working correctly"); + } + if (cs0.equals(cs1) || cs1.equals(cs0) + || cs2.equals(cs1) || cs1.equals(cs2)) { + throw new Exception("The equals method is not working correctly"); + } + if (verifySigner(cs0.getCodeSigners(), null)) { + throw new RuntimeException("CodeSource.getCodeSigners() should be null"); + } + if (!((verifySigner(cs1.getCodeSigners(), certs1)) + && (verifySigner(cs2.getCodeSigners(), certs2)))) { + throw new RuntimeException("Mismatched CodeSigners certificate"); + } + } + } + + private static boolean verifySigner(CodeSigner[] css, List certs) { + if (css == null || certs == null) { + return false; + } + if (css.length < 1 || certs.size() < 1) { + return false; + } + boolean result = true; + for (CodeSigner cs : css) { + result &= cs.getSignerCertPath().getCertificates().equals(certs); + } + return result; + } +} diff --git a/test/jdk/java/security/CodeSource/Implies.java b/test/jdk/java/security/CodeSource/Implies.java index 9e4c26bf725..b64db57e2cf 100644 --- a/test/jdk/java/security/CodeSource/Implies.java +++ b/test/jdk/java/security/CodeSource/Implies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, 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 @@ -31,6 +31,7 @@ import java.net.URL; public class Implies { + public static void main(String[] args) throws Exception { URL thisURL = new URL("http", "localhost", "file"); URL thatURL = new URL("http", null, "file"); @@ -51,14 +52,17 @@ public static void main(String[] args) throws Exception { } private static void testImplies(URL thisURL, URL thatURL, boolean result) - throws SecurityException - { - CodeSource thisCs = - new CodeSource(thisURL, (java.security.cert.Certificate[]) null); - CodeSource thatCs = - new CodeSource(thatURL, (java.security.cert.Certificate[]) null); + throws SecurityException { + CodeSource thisCs + = new CodeSource(thisURL, (java.security.cert.Certificate[]) null); + CodeSource thatCs + = new CodeSource(thatURL, (java.security.cert.Certificate[]) null); if (thisCs.implies(thatCs) != result) { - throw new SecurityException("test failed"); + throw new SecurityException("CodeSource.implies() returned " + + !result + " instead of " + result); + } + if (thisCs.getCodeSigners() != null && thatCs.getCodeSigners() != null) { + throw new SecurityException("Both getCodeSigners should be null"); } } } diff --git a/test/jdk/java/security/CodeSource/certs b/test/jdk/java/security/CodeSource/certs new file mode 100644 index 00000000000..3acd92f7229 --- /dev/null +++ b/test/jdk/java/security/CodeSource/certs @@ -0,0 +1,42 @@ +-----BEGIN CERTIFICATE----- +MIIDgzCCAmugAwIBAgIJALi3XHB1pDxTMA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV +BAYTAlVTMQ0wCwYDVQQIDAR0ZXN0MQ0wCwYDVQQHDAR0ZXN0MQ0wCwYDVQQKDAR0 +ZXN0MQ0wCwYDVQQLDAR0ZXN0MQ0wCwYDVQQDDAR0ZXN0MB4XDTIyMDYwODA3Mzkz +MFoXDTQ3MDYwMjA3MzkzMFowWDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBHRlc3Qx +DTALBgNVBAcMBHRlc3QxDTALBgNVBAoMBHRlc3QxDTALBgNVBAsMBHRlc3QxDTAL +BgNVBAMMBHRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCUfQUR +jdnE1KyZKjPoL2np9T9grBJFaApt1oxNOXLzOW19EYUbbmzERKf9bHALfYIRZonj +wYEywWMLxVuM1YdJAKO2X/X2nvPZLmi9BPVa0aGyG/X19L9FKXEKugzujrq2gko0 +ryDpV1Rrbqpv5G9wXA1+jzPVteFgCX9IoNLEatXVAN8gfnuOCvAM83VMit91+LNs +uK9Eo9xcPyVt0n7Tl+VtW/nVzlRz/p6xHIB0Uo3Dl//QziMllWng98TCxtcTvOBd +gl1AlTAwFWGwQRL2xC8iFrJ5vgY4/afth68W0pqsIH5TCJumGVf/0VBYIs+OWdyT +Wu0Eswjx34gsuvyTAgMBAAGjUDBOMB0GA1UdDgQWBBRmeQRExt2gPyc+b6fB8hL8 ++oiT+jAfBgNVHSMEGDAWgBRmeQRExt2gPyc+b6fB8hL8+oiT+jAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCRlgYqBPXnrhHySR0GzTG2eSQ2B6MqLTOX +nt10kmp92zFJ/AZIoHZGyNC45dRXLX1ZcV8dtAKzbZLo2u07TGxM/q66bHOpXbCn +FGZqyhanDrkwHWPI58pyDuzRKUQKq+kuwpctDiZpjVBcZIVP/ecZcI0DO7qKWEXc +JVXgfkqjU0PMCQDpahDuPLQ3otYDUgNAY82c4WETypjTE8GaLCg++JmPy0Yo8kR4 +VBabOgp4FJi+DDo7VNZRuCTZG91pNlKUZNnR/T1VO0KPtbJoRV5XBRcwdCfhtxNW +lK33pqJx7xAY5Gkg+SdvQOA0d4y6YbCF7eO1QyA5x+dqq+YGHpw7 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDgzCCAmugAwIBAgIJALi3XHB1pDxTMA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV +BAYTAlVTMQ0wCwYDVQQIDAR0ZXN0MQ0wCwYDVQQHDAR0ZXN0MQ0wCwYDVQQKDAR0 +ZXN0MQ0wCwYDVQQLDAR0ZXN0MQ0wCwYDVQQDDAR0ZXN0MB4XDTIyMDYwODA3Mzkz +MFoXDTQ3MDYwMjA3MzkzMFowWDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBHRlc3Qx +DTALBgNVBAcMBHRlc3QxDTALBgNVBAoMBHRlc3QxDTALBgNVBAsMBHRlc3QxDTAL +BgNVBAMMBHRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCUfQUR +jdnE1KyZKjPoL2np9T9grBJFaApt1oxNOXLzOW19EYUbbmzERKf9bHALfYIRZonj +wYEywWMLxVuM1YdJAKO2X/X2nvPZLmi9BPVa0aGyG/X19L9FKXEKugzujrq2gko0 +ryDpV1Rrbqpv5G9wXA1+jzPVteFgCX9IoNLEatXVAN8gfnuOCvAM83VMit91+LNs +uK9Eo9xcPyVt0n7Tl+VtW/nVzlRz/p6xHIB0Uo3Dl//QziMllWng98TCxtcTvOBd +gl1AlTAwFWGwQRL2xC8iFrJ5vgY4/afth68W0pqsIH5TCJumGVf/0VBYIs+OWdyT +Wu0Eswjx34gsuvyTAgMBAAGjUDBOMB0GA1UdDgQWBBRmeQRExt2gPyc+b6fB8hL8 ++oiT+jAfBgNVHSMEGDAWgBRmeQRExt2gPyc+b6fB8hL8+oiT+jAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCRlgYqBPXnrhHySR0GzTG2eSQ2B6MqLTOX +nt10kmp92zFJ/AZIoHZGyNC45dRXLX1ZcV8dtAKzbZLo2u07TGxM/q66bHOpXbCn +FGZqyhanDrkwHWPI58pyDuzRKUQKq+kuwpctDiZpjVBcZIVP/ecZcI0DO7qKWEXc +JVXgfkqjU0PMCQDpahDuPLQ3otYDUgNAY82c4WETypjTE8GaLCg++JmPy0Yo8kR4 +VBabOgp4FJi+DDo7VNZRuCTZG91pNlKUZNnR/T1VO0KPtbJoRV5XBRcwdCfhtxNW +lK33pqJx7xAY5Gkg+SdvQOA0d4y6YbCF7eO1QyA5x+dqq+YGHpw7 +-----END CERTIFICATE----- \ No newline at end of file From b10ad197bf779541621af2c3f4f5ae1cf7db115b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 1 Feb 2023 10:07:05 +0000 Subject: [PATCH 104/205] 8282036: Change java/util/zip/ZipFile/DeleteTempJar.java to stop HttpServer cleanly in case of exceptions Backport-of: 784fa0add77a3e473e2cdbdcc27b3ed076678565 --- .../java/util/zip/ZipFile/DeleteTempJar.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java b/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java index 58cc830b4aa..7ac4f2616c3 100644 --- a/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java +++ b/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -72,16 +72,19 @@ public void handle(HttpExchange e) { } } }); - server.start(); - URL url = new URL("jar:http://localhost:" + server.start(); + try { + URL url = new URL("jar:http://localhost:" + new Integer(server.getAddress().getPort()).toString() + "/deletetemp.jar!/"); - JarURLConnection c = (JarURLConnection)url.openConnection(); - JarFile f = c.getJarFile(); - check(f.getEntry("entry") != null); - System.out.println(f.getName()); - server.stop(0); + JarURLConnection c = (JarURLConnection)url.openConnection(); + JarFile f = c.getJarFile(); + check(f.getEntry("entry") != null); + System.out.println(f.getName()); + } finally { + server.stop(0); + } } //--------------------- Infrastructure --------------------------- From 8547c8040e115174339414308ab79e09d2cb8a45 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 1 Feb 2023 10:10:17 +0000 Subject: [PATCH 105/205] 8300773: Address the inconsistency between the constant array and pool size Backport-of: a34f2d3728c077d1dbdfa313f1bf29629fbc32f6 --- .../bcel/internal/classfile/ConstantPool.java | 6 +++--- .../internal/generic/ConstantPoolGen.java | 21 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java index ed4ce0948ed..b10c6521a38 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java @@ -37,7 +37,7 @@ * @see Constant * @see com.sun.org.apache.bcel.internal.generic.ConstantPoolGen - * @LastModified: May 2022 + * @LastModified: June 2022 */ public class ConstantPool implements Cloneable, Node { @@ -228,8 +228,8 @@ public void dump( final DataOutputStream file ) throws IOException { * This is a redundant measure as the ConstantPoolGen should have already * reported an error back in the situation. */ - int size = constantPool.length < ConstantPoolGen.CONSTANT_POOL_SIZE - 1 ? - constantPool.length : ConstantPoolGen.CONSTANT_POOL_SIZE - 1; + int size = constantPool.length < ConstantPoolGen.CONSTANT_POOL_SIZE ? + constantPool.length : ConstantPoolGen.CONSTANT_POOL_SIZE; file.writeShort(size); for (int i = 1; i < size; i++) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java index 806b40da1ed..622cdb1b7ac 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java @@ -50,10 +50,10 @@ * JVM and that Double and Long constants need two slots. * * @see Constant - * @LastModified: May 2022 + * @LastModified: June 2022 */ public class ConstantPoolGen { - public static final int CONSTANT_POOL_SIZE = 65536; + public static final int CONSTANT_POOL_SIZE = 65535; private static final int DEFAULT_BUFFER_SIZE = 256; private int size; private Constant[] constants; @@ -81,6 +81,19 @@ private static class Index { * @param cs array of given constants, new ones will be appended */ public ConstantPoolGen(final Constant[] cs) { + /* + * To be logically/programmatically correct, the size of the constant pool + * shall not exceed the size limit as the code below does a copy and then + * walk through the whole array. + * This is however, not used by XSLT (or the java.xml implementation), + * and only happens when BCELifier is called (see BCELifier). + */ + if (cs.length > CONSTANT_POOL_SIZE) { + throw new RuntimeException("The number of constants " + cs.length + + " is over the size limit of the constant pool: " + + CONSTANT_POOL_SIZE); + } + final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), CONSTANT_POOL_SIZE); @@ -215,8 +228,8 @@ protected void adjustSize() { // 3 extra spaces are needed as some entries may take 3 slots if (index + 3 >= CONSTANT_POOL_SIZE) { throw new RuntimeException("The number of constants " + (index + 3) - + " is over the size of the constant pool: " - + (CONSTANT_POOL_SIZE - 1)); + + " is over the size limit of the constant pool: " + + CONSTANT_POOL_SIZE); } if (index + 3 >= size) { From 37a15a10024c5f7b103cc688e1ba26b8cfc42d8d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 3 Feb 2023 10:13:26 +0000 Subject: [PATCH 106/205] 8286800: Assert in PhaseIdealLoop::dump_real_LCA is too strong Backport-of: decb1b79bc475f024a02135fa3394ff97098e758 --- src/hotspot/share/opto/loopnode.cpp | 170 ++++++++++++++++------------ src/hotspot/share/opto/loopnode.hpp | 10 +- 2 files changed, 105 insertions(+), 75 deletions(-) diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index 46c7bb12ab1..c803001c525 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -4601,80 +4601,88 @@ void PhaseIdealLoop::dump_bad_graph(const char* msg, Node* n, Node* early, Node* } } } - tty->cr(); - tty->print_cr("idoms of early %d:", early->_idx); - dump_idom(early); - tty->cr(); - tty->print_cr("idoms of (wrong) LCA %d:", LCA->_idx); - dump_idom(LCA); - tty->cr(); - dump_real_LCA(early, LCA); + dump_idoms(early, LCA); tty->cr(); } -// Find the real LCA of early and the wrongly assumed LCA. -void PhaseIdealLoop::dump_real_LCA(Node* early, Node* wrong_lca) { - assert(!is_dominator(early, wrong_lca) && !is_dominator(early, wrong_lca), - "sanity check that one node does not dominate the other"); - assert(!has_ctrl(early) && !has_ctrl(wrong_lca), "sanity check, no data nodes"); +// Class to compute the real LCA given an early node and a wrong LCA in a bad graph. +class RealLCA { + const PhaseIdealLoop* _phase; + Node* _early; + Node* _wrong_lca; + uint _early_index; + int _wrong_lca_index; + + // Given idom chains of early and wrong LCA: Walk through idoms starting at StartNode and find the first node which + // is different: Return the previously visited node which must be the real LCA. + // The node lists also contain _early and _wrong_lca, respectively. + Node* find_real_lca(Unique_Node_List& early_with_idoms, Unique_Node_List& wrong_lca_with_idoms) { + int early_index = early_with_idoms.size() - 1; + int wrong_lca_index = wrong_lca_with_idoms.size() - 1; + bool found_difference = false; + do { + if (early_with_idoms[early_index] != wrong_lca_with_idoms[wrong_lca_index]) { + // First time early and wrong LCA idoms differ. Real LCA must be at the previous index. + found_difference = true; + break; + } + early_index--; + wrong_lca_index--; + } while (wrong_lca_index >= 0); - ResourceMark rm; - Node_List nodes_seen; - Node* real_LCA = NULL; - Node* n1 = wrong_lca; - Node* n2 = early; - uint count_1 = 0; - uint count_2 = 0; - // Add early and wrong_lca to simplify calculation of idom indices - nodes_seen.push(n1); - nodes_seen.push(n2); - - // Walk the idom chain up from early and wrong_lca and stop when they intersect. - while (!n1->is_Start() && !n2->is_Start()) { - n1 = idom(n1); - n2 = idom(n2); - if (n1 == n2) { - // Both idom chains intersect at the same index - real_LCA = n1; - count_1 = nodes_seen.size() / 2; - count_2 = count_1; - break; - } - if (check_idom_chains_intersection(n1, count_1, count_2, &nodes_seen)) { - real_LCA = n1; - break; - } - if (check_idom_chains_intersection(n2, count_2, count_1, &nodes_seen)) { - real_LCA = n2; - break; - } - nodes_seen.push(n1); - nodes_seen.push(n2); + assert(early_index >= 0, "must always find an LCA - cannot be early"); + _early_index = early_index; + _wrong_lca_index = wrong_lca_index; + Node* real_lca = early_with_idoms[_early_index + 1]; // Plus one to skip _early. + assert(found_difference || real_lca == _wrong_lca, "wrong LCA dominates early and is therefore the real LCA"); + return real_lca; } - assert(real_LCA != NULL, "must always find an LCA"); - tty->print_cr("Real LCA of early %d (idom[%d]) and (wrong) LCA %d (idom[%d]):", early->_idx, count_2, wrong_lca->_idx, count_1); - real_LCA->dump(); -} + void dump(Node* real_lca) { + tty->cr(); + tty->print_cr("idoms of early \"%d %s\":", _early->_idx, _early->Name()); + _phase->dump_idom(_early, _early_index + 1); -// Check if n is already on nodes_seen (i.e. idom chains of early and wrong_lca intersect at n). Determine the idom index of n -// on both idom chains and return them in idom_idx_new and idom_idx_other, respectively. -bool PhaseIdealLoop::check_idom_chains_intersection(const Node* n, uint& idom_idx_new, uint& idom_idx_other, const Node_List* nodes_seen) const { - if (nodes_seen->contains(n)) { - // The idom chain has just discovered n. - // Divide by 2 because nodes_seen contains the same amount of nodes from both chains. - idom_idx_new = nodes_seen->size() / 2; - - // The other chain already contained n. Search the index. - for (uint i = 0; i < nodes_seen->size(); i++) { - if (nodes_seen->at(i) == n) { - // Divide by 2 because nodes_seen contains the same amount of nodes from both chains. - idom_idx_other = i / 2; - } + tty->cr(); + tty->print_cr("idoms of (wrong) LCA \"%d %s\":", _wrong_lca->_idx, _wrong_lca->Name()); + _phase->dump_idom(_wrong_lca, _wrong_lca_index + 1); + + tty->cr(); + tty->print("Real LCA of early \"%d %s\" (idom[%d]) and wrong LCA \"%d %s\"", + _early->_idx, _early->Name(), _early_index, _wrong_lca->_idx, _wrong_lca->Name()); + if (_wrong_lca_index >= 0) { + tty->print(" (idom[%d])", _wrong_lca_index); } - return true; + tty->print_cr(":"); + real_lca->dump(); } - return false; + + public: + RealLCA(const PhaseIdealLoop* phase, Node* early, Node* wrong_lca) + : _phase(phase), _early(early), _wrong_lca(wrong_lca), _early_index(0), _wrong_lca_index(0) { + assert(!wrong_lca->is_Start(), "StartNode is always a common dominator"); + } + + void compute_and_dump() { + ResourceMark rm; + Unique_Node_List early_with_idoms; + Unique_Node_List wrong_lca_with_idoms; + early_with_idoms.push(_early); + wrong_lca_with_idoms.push(_wrong_lca); + _phase->get_idoms(_early, 10000, early_with_idoms); + _phase->get_idoms(_wrong_lca, 10000, wrong_lca_with_idoms); + Node* real_lca = find_real_lca(early_with_idoms, wrong_lca_with_idoms); + dump(real_lca); + } +}; + +// Dump the idom chain of early, of the wrong LCA and dump the real LCA of early and wrong LCA. +void PhaseIdealLoop::dump_idoms(Node* early, Node* wrong_lca) { + assert(!is_dominator(early, wrong_lca), "sanity check that early does not dominate wrong lca"); + assert(!has_ctrl(early) && !has_ctrl(wrong_lca), "sanity check, no data nodes"); + + RealLCA real_lca(this, early, wrong_lca); + real_lca.compute_and_dump(); } #endif // ASSERT @@ -4748,16 +4756,38 @@ void PhaseIdealLoop::dump(IdealLoopTree* loop, uint idx, Node_List &rpo_list) co } } -void PhaseIdealLoop::dump_idom(Node* n) const { +void PhaseIdealLoop::dump_idom(Node* n, const uint count) const { if (has_ctrl(n)) { tty->print_cr("No idom for data nodes"); } else { - for (int i = 0; i < 100 && !n->is_Start(); i++) { - tty->print("idom[%d] ", i); - n->dump(); - n = idom(n); + ResourceMark rm; + Unique_Node_List idoms; + get_idoms(n, count, idoms); + dump_idoms_in_reverse(n, idoms); + } +} + +void PhaseIdealLoop::get_idoms(Node* n, const uint count, Unique_Node_List& idoms) const { + Node* next = n; + for (uint i = 0; !next->is_Start() && i < count; i++) { + next = idom(next); + assert(!idoms.member(next), "duplicated idom is not possible"); + idoms.push(next); + } +} + +void PhaseIdealLoop::dump_idoms_in_reverse(const Node* n, const Node_List& idom_list) const { + Node* next; + uint padding = 3; + uint node_index_padding_width = static_cast(log10(C->unique())) + 1; + for (int i = idom_list.size() - 1; i >= 0; i--) { + if (i == 9 || i == 99) { + padding++; } + next = idom_list[i]; + tty->print_cr("idom[%d]:%*c%*d %s", i, padding, ' ', node_index_padding_width, next->_idx, next->Name()); } + tty->print_cr("n: %*c%*d %s", padding, ' ', node_index_padding_width, n->_idx, n->Name()); } #endif // NOT PRODUCT diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index aceab1776f0..2010adb9f24 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -1429,10 +1429,8 @@ SHENANDOAHGC_ONLY(private:) } bool _created_loop_node; -#ifdef ASSERT - void dump_real_LCA(Node* early, Node* wrong_lca); - bool check_idom_chains_intersection(const Node* n, uint& idom_idx_new, uint& idom_idx_other, const Node_List* nodes_seen) const; -#endif + DEBUG_ONLY(void dump_idoms(Node* early, Node* wrong_lca);) + NOT_PRODUCT(void dump_idoms_in_reverse(const Node* n, const Node_List& idom_list) const;) public: void set_created_loop_node() { _created_loop_node = true; } @@ -1445,7 +1443,9 @@ SHENANDOAHGC_ONLY(private:) #ifndef PRODUCT void dump() const; - void dump_idom(Node* n) const; + void dump_idom(Node* n) const { dump_idom(n, 1000); } // For debugging + void dump_idom(Node* n, uint count) const; + void get_idoms(Node* n, uint count, Unique_Node_List& idoms) const; void dump(IdealLoopTree* loop, uint rpo_idx, Node_List &rpo_list) const; void verify() const; // Major slow :-) void verify_compare(Node* n, const PhaseIdealLoop* loop_verify, VectorSet &visited) const; From acedbcbecbc9f26352e80f7517e15235f36381d6 Mon Sep 17 00:00:00 2001 From: Victor Rudometov Date: Fri, 3 Feb 2023 18:48:38 +0000 Subject: [PATCH 107/205] 8299296: Write a test to verify the components selection sends ItemEvent Backport-of: 5ae6de859d472d107cdf642c417c6d2f1c74e5db --- .../ComponentItemEventTest.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 test/jdk/java/awt/event/ComponentEvent/ComponentItemEventTest.java diff --git a/test/jdk/java/awt/event/ComponentEvent/ComponentItemEventTest.java b/test/jdk/java/awt/event/ComponentEvent/ComponentItemEventTest.java new file mode 100644 index 00000000000..4300cfa9357 --- /dev/null +++ b/test/jdk/java/awt/event/ComponentEvent/ComponentItemEventTest.java @@ -0,0 +1,130 @@ +/* + * 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. + */ + +import java.awt.Checkbox; +import java.awt.Choice; +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.event.InputEvent; + +/* + * @test + * @key headful + * @bug 8299296 + * @summary Verify that Component selection via mouse generates ItemEvent. + * @run main ComponentItemEventTest + */ +public class ComponentItemEventTest { + + private static Frame frame; + private volatile static Choice choice; + private volatile static Checkbox cb; + private static Robot robot; + private volatile static boolean cbStateChanged = false; + private volatile static boolean choiceStateChanged = false; + private volatile static Point compAt; + private volatile static Dimension compSize; + + private static void initializeGUI() { + frame = new Frame("Test Frame"); + frame.setLayout(new FlowLayout()); + choice = new Choice(); + for (int i = 0; i < 8; i++) { + choice.add("Choice "+i); + } + choice.select(3); + choice.addItemListener((event) -> { + System.out.println("Choice got an ItemEvent: " + event); + choiceStateChanged = true; + }); + + cb = new Checkbox("CB"); + cb.addItemListener((event) -> { + System.out.println("Checkbox got an ItemEvent: " + event); + cbStateChanged = true; + }); + frame.add(choice); + frame.add(cb); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(ComponentItemEventTest::initializeGUI); + robot = new Robot(); + robot.setAutoDelay(1000); + robot.setAutoWaitForIdle(true); + + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> { + compAt = choice.getLocationOnScreen(); + compSize = choice.getSize(); + }); + robot.mouseMove(compAt.x + choice.getSize().width - 10, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height + 15); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!choiceStateChanged) { + throw new RuntimeException( + "FAIL: Choice did not trigger ItemEvent when item selected!"); + } + + EventQueue.invokeAndWait(() -> { + compAt = cb.getLocationOnScreen(); + compSize = cb.getSize(); + }); + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!cbStateChanged) { + throw new RuntimeException( + "FAIL: Checkbox did not trigger ItemEvent when item selected!"); + } + System.out.println("Test passed!"); + } finally { + EventQueue.invokeAndWait(ComponentItemEventTest::disposeFrame); + } + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + frame = null; + } + } +} From f5a04fbca5892a1ce589afa9b2d10fbbac8149be Mon Sep 17 00:00:00 2001 From: Ichiroh Takiguchi Date: Sat, 4 Feb 2023 04:51:50 +0000 Subject: [PATCH 108/205] 8299194: CustomTzIDCheckDST.java may fail at future date Backport-of: 5e2de89628aaf6acb8e458fb417426ca5e477bea --- .../util/TimeZone/CustomTzIDCheckDST.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java index bceb26eec32..99f3ae96e94 100644 --- a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java +++ b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java @@ -33,32 +33,48 @@ import java.util.Date; import java.util.List; import java.util.SimpleTimeZone; +import java.util.TimeZone; import java.time.DayOfWeek; import java.time.ZonedDateTime; import java.time.temporal.TemporalAdjusters; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; public class CustomTzIDCheckDST { - private static String CUSTOM_TZ = "MEZ-1MESZ,M3.5.0,M10.5.0"; + // Northern Hemisphere + private static String CUSTOM_TZ = "MEZ-1MESZ,M3.5.0,M10.5.0/3"; + // Simulate Southern Hemisphere + private static String CUSTOM_TZ2 = "MEZ-1MESZ,M10.5.0,M3.5.0/3"; public static void main(String args[]) throws Throwable { if (args.length == 0) { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CustomTzIDCheckDST", "runTZTest"); pb.environment().put("TZ", CUSTOM_TZ); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); + pb.environment().put("TZ", CUSTOM_TZ2); + output = ProcessTools.executeProcess(pb); + output.shouldHaveExitValue(0); } else { runTZTest(); } } - /* TZ code will always be set to "MEZ-1MESZ,M3.5.0,M10.5.0". + /* TZ is set to "MEZ-1MESZ,M3.5.0,M10.5.0/3", it will be the northern hemisphere. * This ensures the transition periods for Daylights Savings should be at March's last * Sunday and October's last Sunday. */ private static void runTZTest() { Date time = new Date(); - if (new SimpleTimeZone(3600000, "MEZ-1MESZ", Calendar.MARCH, -1, Calendar.SUNDAY, 0, - Calendar.OCTOBER, -1, Calendar.SUNDAY, 0).inDaylightTime(time)) { + String tzStr = System.getenv("TZ"); + if (tzStr == null) + throw new RuntimeException("Got unexpected timezone information: TZ is null"); + boolean nor = CUSTOM_TZ.equals(tzStr); + TimeZone tz = new SimpleTimeZone(3600000, tzStr, + nor ? Calendar.MARCH : Calendar.OCTOBER, -1, + Calendar.SUNDAY, 3600000, SimpleTimeZone.UTC_TIME, + nor ? Calendar.OCTOBER : Calendar.MARCH, -1, + Calendar.SUNDAY, 3600000, SimpleTimeZone.UTC_TIME, + 3600000); + if (tz.inDaylightTime(time)) { // We are in Daylight savings period. if (time.toString().endsWith("GMT+02:00 " + Integer.toString(time.getYear() + 1900))) return; @@ -68,7 +84,7 @@ private static void runTZTest() { } // Reaching here means time zone did not match up as expected. - throw new RuntimeException("Got unexpected timezone information: " + time); + throw new RuntimeException("Got unexpected timezone information: " + tzStr + " " + time); } private static ZonedDateTime getLastSundayOfMonth(ZonedDateTime date) { From 6ffd006da08eb5b9ac7bf0f89f42895fa7a1e2a9 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sun, 5 Feb 2023 04:11:08 +0000 Subject: [PATCH 109/205] 8241806: The sun/awt/shell/FileSystemViewMemoryLeak.java is unstable Backport-of: e730e8b6919e4e7879e2c702b1c3101768110973 --- test/jdk/ProblemList.txt | 1 - .../sun/awt/shell/FileSystemViewMemoryLeak.java | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 7e8805ef5f2..9afa99aea6e 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -216,7 +216,6 @@ java/awt/image/MultiResolutionImage/MultiResolutionDrawImageWithTransformTest.ja java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all -sun/awt/shell/FileSystemViewMemoryLeak.java 8241806 windows-all sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java 8144029 macosx-all diff --git a/test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.java b/test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.java index a0f8407f184..96b5cd360b4 100644 --- a/test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.java +++ b/test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.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 @@ -27,10 +27,12 @@ * @summary FileSystemView.isDrive(File) memory leak on "C:\" file reference * @modules java.desktop/sun.awt.shell * @requires (os.family == "windows") - * @run main/othervm -Xmx8m FileSystemViewMemoryLeak + * @run main/othervm/timeout=320 -Xmx8m FileSystemViewMemoryLeak */ import java.io.File; import java.text.NumberFormat; +import java.util.concurrent.TimeUnit; + import javax.swing.filechooser.FileSystemView; public class FileSystemViewMemoryLeak { @@ -39,6 +41,9 @@ public static void main(String[] args) { test(); } + // Will run the test no more than 300 seconds + static long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(300); + private static void test() { File root = new File("C:\\"); @@ -52,6 +57,10 @@ private static void test() { int iMax = 50000; long lastPercentFinished = 0L; for (int i = 0; i < iMax; i++) { + if (isComplete()) { + System.out.println("Time is over"); + return; + } long percentFinished = Math.round(((i * 1000d) / (double) iMax)); @@ -77,5 +86,9 @@ private static void test() { boolean drive = fileSystemView.isDrive(root); } } + + private static boolean isComplete() { + return endtime - System.nanoTime() < 0; + } } From fc4b9de4079bb3fb7b845f570f3acb66fbb04380 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Feb 2023 11:24:38 +0000 Subject: [PATCH 110/205] 8218431: Improved platform checking in makefiles Reviewed-by: mbaesken Backport-of: 208c58c8621247023e39c98a7b81638c62daedec --- make/Bundles.gmk | 6 +- make/CompileDemos.gmk | 2 +- make/CompileJavaModules.gmk | 20 ++-- make/CopyImportModules.gmk | 2 +- make/CreateJmods.gmk | 2 +- make/Images.gmk | 6 +- make/InitSupport.gmk | 2 +- make/MacBundles.gmk | 2 +- make/Main.gmk | 2 +- make/ModuleWrapper.gmk | 2 +- make/RunTests.gmk | 8 +- make/ZipSecurity.gmk | 4 +- make/common/MakeBase.gmk | 6 +- make/common/Modules.gmk | 4 +- make/common/NativeCompilation.gmk | 18 ++-- make/common/Utils.gmk | 61 ++++++++++++ make/copy/Copy-java.base.gmk | 8 +- make/copy/Copy-jdk.crypto.cryptoki.gmk | 2 +- make/copy/Copy-jdk.crypto.ucrypto.gmk | 2 +- make/gensrc/Gensrc-java.desktop.gmk | 10 +- make/gensrc/Gensrc-jdk.hotspot.agent.gmk | 2 +- make/gensrc/GensrcIcons.gmk | 2 +- make/gensrc/GensrcMisc.gmk | 4 +- make/hotspot/CopyToExplodedJdk.gmk | 2 +- make/hotspot/gensrc/GensrcAdlc.gmk | 20 ++-- make/hotspot/gensrc/GensrcDtrace.gmk | 8 +- make/hotspot/ide/CreateVSProject.gmk | 2 +- make/hotspot/lib/CompileDtraceLibraries.gmk | 2 +- make/hotspot/lib/CompileGtest.gmk | 4 +- make/hotspot/lib/CompileJvm.gmk | 28 +++--- make/hotspot/lib/JvmDtraceObjects.gmk | 4 +- make/hotspot/lib/JvmFeatures.gmk | 4 +- make/hotspot/lib/JvmFlags.gmk | 2 +- make/hotspot/lib/JvmMapfile.gmk | 20 ++-- make/hotspot/lib/JvmOverrideFiles.gmk | 16 ++-- make/hotspot/test/GtestImage.gmk | 4 +- make/launcher/Launcher-java.base.gmk | 6 +- make/launcher/Launcher-java.security.jgss.gmk | 2 +- make/launcher/Launcher-jdk.accessibility.gmk | 4 +- make/launcher/Launcher-jdk.pack.gmk | 2 +- make/launcher/LauncherCommon.gmk | 4 +- make/lib/Awt2dLibraries.gmk | 92 +++++++++---------- make/lib/CoreLibraries.gmk | 12 +-- make/lib/Lib-java.base.gmk | 4 +- make/lib/Lib-java.desktop.gmk | 9 +- make/lib/Lib-java.instrument.gmk | 4 +- make/lib/Lib-java.management.gmk | 3 +- make/lib/Lib-java.prefs.gmk | 2 +- make/lib/Lib-java.security.jgss.gmk | 4 +- make/lib/Lib-jdk.accessibility.gmk | 4 +- make/lib/Lib-jdk.attach.gmk | 2 +- make/lib/Lib-jdk.crypto.mscapi.gmk | 2 +- make/lib/Lib-jdk.crypto.ucrypto.gmk | 2 +- make/lib/Lib-jdk.hotspot.agent.gmk | 10 +- make/lib/Lib-jdk.internal.le.gmk | 4 +- make/lib/Lib-jdk.jdi.gmk | 4 +- make/lib/Lib-jdk.management.gmk | 5 +- make/lib/Lib-jdk.net.gmk | 2 +- make/lib/Lib-jdk.sctp.gmk | 4 +- make/test/BuildFailureHandler.gmk | 4 +- make/test/JtregNativeHotspot.gmk | 10 +- make/test/JtregNativeJdk.gmk | 8 +- test/make/TestMakeBase.gmk | 22 +++++ test/make/UtilsForTests.gmk | 2 +- 64 files changed, 301 insertions(+), 225 deletions(-) diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 56d7dc8797b..55cb343e0bd 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -36,7 +36,7 @@ DOCS_TARGETS := # On Windows tar frequently complains that "file changed as we read it" for # some random source files. This seems to be cause by anti virus scanners and # is most likely safe to ignore. When it happens, tar returns '1'. -ifeq ($(OPENJDK_BUILD_OS), windows) +ifeq ($(call isBuildOs, windows), true) TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1" endif @@ -156,7 +156,7 @@ endef # On Macosx, we bundle up the macosx specific images which already have the # correct base directories. -ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) +ifeq ($(call isTargetOs, macosx)+$(DEBUG_LEVEL), true+release) JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR) JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home @@ -208,7 +208,7 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), ) # Create special filter rules when dealing with unzipped .dSYM directories on # macosx - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false) JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, \ diff --git a/make/CompileDemos.gmk b/make/CompileDemos.gmk index 64ecf48301f..74c54ce0cf2 100644 --- a/make/CompileDemos.gmk +++ b/make/CompileDemos.gmk @@ -234,7 +234,7 @@ $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/% $(call install-file) $(CHMOD) -f ug+w $@ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \ $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \ $(call FindFiles, $(DEMO_SHARE_SRC)/nbproject)) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 40c7e06f540..46fb9b4219b 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -51,21 +51,18 @@ java.base_EXCLUDES += java/lang/doc-files # data files and shouldn't go in the product java.base_EXCLUDE_FILES += sun/text/resources/BreakIteratorRules.java -ifneq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), false) java.base_EXCLUDE_FILES += \ SolarisLoginModule.java \ SolarisSystem.java \ # endif -ifeq ($(filter $(OPENJDK_TARGET_OS), solaris macosx aix), ) - # - # only solaris, macosx and aix - # +ifeq ($(call isTargetOs, solaris macosx aix), false) java.base_EXCLUDE_FILES += sun/nio/fs/PollingWatchService.java endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) java.base_EXCLUDE_FILES += \ sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \ # @@ -124,7 +121,7 @@ java.desktop_EXCLUDE_FILES += \ .template \ # -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # exclude all X11 on Mac. java.desktop_EXCLUDES += \ sun/awt/X11 \ @@ -186,7 +183,7 @@ else sun/awt/X11/XwcTextItem.java endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) java.desktop_EXCLUDES += com/sun/java/swing/plaf/gtk endif @@ -194,8 +191,7 @@ ifdef BUILD_HEADLESS_ONLY java.desktop_EXCLUDES += sun/applet endif -# Used on windows and macosx -ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) java.desktop_EXCLUDE_FILES += sun/awt/AWTCharset.java endif @@ -374,11 +370,11 @@ SCTP_IMPL_CLASSES = \ $(TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SendFailed.java \ $(TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/Shutdown.java -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) jdk.sctp_EXCLUDE_FILES += $(SCTP_IMPL_CLASSES) endif -ifeq ($(OPENJDK_TARGET_OS),aix) +ifeq ($(call isTargetOs, aix), true) jdk.sctp_EXCLUDE_FILES += $(SCTP_IMPL_CLASSES) endif diff --git a/make/CopyImportModules.gmk b/make/CopyImportModules.gmk index e71d29c38df..34baaf9d37b 100644 --- a/make/CopyImportModules.gmk +++ b/make/CopyImportModules.gmk @@ -38,7 +38,7 @@ CONF_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CONF))) $(call FillFindCache, $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR)) ifneq ($(LIBS_DIR), ) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \ diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index de068ecf071..f0e152b1079 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -165,7 +165,7 @@ ifeq ($(MODULE), java.base) endif endif else # not java.base - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) # Only java.base needs to include the MSVC*_DLLs. Make sure no other module # tries to include them (typically imported ones). ifneq ($(MSVCR_DLL), ) diff --git a/make/Images.gmk b/make/Images.gmk index 524f76dd23a..2c9f0b866d8 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -255,7 +255,7 @@ ifneq ($(filter jdk, $(MAKECMDGOALS)), ) ) ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES)) else DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES)) @@ -296,7 +296,7 @@ ALL_JDK_MODULES := $(JDK_MODULES) ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \ $(call FindTransitiveDepsForModule, $m))) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBS_TARGET_SUBDIR := bin else LIBS_TARGET_SUBDIR := lib @@ -316,7 +316,7 @@ else DEBUGINFO_SUFFIXES := .debuginfo .pdb .map # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM # dirs. - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(call FillFindCache, \ $(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds) FindDebuginfoFiles = \ diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index 9c11e2c2bcd..df175a11cc5 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -488,7 +488,7 @@ else # $(HAS_SPEC)=true $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true endef - ifeq ($(OPENJDK_BUILD_OS), windows) + ifeq ($(call isBuildOs, windows), true) # On windows we need to synchronize with the javac server to be able to # move or remove the build output directory. Since we have no proper # synchronization process, wait for a while and hope it helps. This is only diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk index 5a5394d6a22..45d0c78dc2a 100644 --- a/make/MacBundles.gmk +++ b/make/MacBundles.gmk @@ -30,7 +30,7 @@ include TextFileProcessing.gmk default: bundles # Only macosx has bundles defined. -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) bundles: jre-bundle jdk-bundle diff --git a/make/Main.gmk b/make/Main.gmk index 6b4b0ac6ee4..5a48954ca10 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -1123,7 +1123,7 @@ ifneq ($(CREATE_BUILDJDK), true) endif endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) product-images: mac-jdk-bundle legacy-images: mac-legacy-jre-bundle diff --git a/make/ModuleWrapper.gmk b/make/ModuleWrapper.gmk index 5f9c5fc82ec..54bf26ea467 100644 --- a/make/ModuleWrapper.gmk +++ b/make/ModuleWrapper.gmk @@ -42,7 +42,7 @@ TARGETS := include $(MAKEFILE_PREFIX)-$(MODULE).gmk # Setup copy rules from the modules directories to the jdk image directory. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \ diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 0c998c21e27..1c9778ee90f 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -61,7 +61,7 @@ define SetTestOpt endef # Setup _NT_SYMBOL_PATH on Windows, which points to our pdb files. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) ifndef _NT_SYMBOL_PATH SYMBOL_PATH := $(call PathList, $(sort $(patsubst %/, %, $(dir $(wildcard \ $(addprefix $(SYMBOLS_IMAGE_DIR)/bin/, *.pdb */*.pdb)))))) @@ -200,7 +200,7 @@ TEST_JOBS_FACTOR_MACHINE ?= 1 ifeq ($(TEST_JOBS), 0) CORES_DIVIDER := 2 - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) # For smaller SPARC machines we see reasonable scaling of throughput up to # cpus/4 without affecting test reliability. On the bigger machines, cpus/4 # causes intermittent timeouts. @@ -632,7 +632,7 @@ define SetupRunJtregTestBody $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $(AWK) 'BEGIN { print 25 / $$($1_JTREG_JOBS); }') # SPARC is in general slower per core so need to scale up timeouts a bit. - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) JTREG_TIMEOUT_FACTOR ?= 8 else JTREG_TIMEOUT_FACTOR ?= 4 @@ -673,7 +673,7 @@ define SetupRunJtregTestBody $1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK) # If running on Windows, propagate the _NT_SYMBOL_PATH to enable # symbol lookup in hserr files - ifeq ($$(OPENJDK_TARGET_OS), windows) + ifeq ($$(call isTargetOs, windows), true) $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH endif diff --git a/make/ZipSecurity.gmk b/make/ZipSecurity.gmk index ba5664122ce..cbe1e216415 100644 --- a/make/ZipSecurity.gmk +++ b/make/ZipSecurity.gmk @@ -70,7 +70,7 @@ TARGETS += $(IMAGES_OUTPUTDIR)/sec-bin.zip # # Windows specific binary security packages. # -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # sec-windows-bin.zip is used by builds where the corresponding sources are not available $(eval $(call SetupZipArchive,BUILD_SEC_WINDOWS_BIN_ZIP, \ SRC := $(JDK_OUTPUTDIR), \ @@ -80,7 +80,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(IMAGES_OUTPUTDIR)/sec-windows-bin.zip # JGSS files contain the native Kerberos library - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) JGSS_ZIP_NAME = jgss-windows-x64-bin.zip else JGSS_ZIP_NAME = jgss-windows-i586-bin.zip diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 2f892338be4..dd81ba3484c 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -263,7 +263,7 @@ MakeTargetDir = \ ################################################################################ # All install-file and related macros automatically call DecodeSpace when needed. -ifeq ($(OPENJDK_TARGET_OS),solaris) +ifeq ($(call isTargetOs, solaris), true) # On Solaris, if the target is a symlink and exists, cp won't overwrite. # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the # name of the target file differs from the source file, rename after copy. @@ -289,7 +289,7 @@ ifeq ($(OPENJDK_TARGET_OS),solaris) $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \ fi endef -else ifeq ($(OPENJDK_TARGET_OS),macosx) +else ifeq ($(call isTargetOs, macosx), true) # On mac, extended attributes sometimes creep into the source files, which may later # cause the creation of ._* files which confuses testing. Clear these with xattr if # set. Some files get their write permissions removed after being copied to the @@ -487,7 +487,7 @@ endif # list. # This is normally not needed since we use the FIXPATH prefix for command lines, # but might be needed in certain circumstances. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) FixPath = \ $(strip $(subst \,\\, $(shell $(FIXPATH_BASE) print $(patsubst $(FIXPATH), , $1)))) else diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index 41533e5661a..4f846c78eba 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -118,11 +118,11 @@ PLATFORM_MODULES += \ jdk.zipfs \ # -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) PLATFORM_MODULES += jdk.crypto.mscapi endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) PLATFORM_MODULES += jdk.crypto.ucrypto endif diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index bc297fbe079..8eeb6def43d 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -909,7 +909,7 @@ define SetupNativeCompilationBody $(TOUCH) $$@ # On windows we need to create a resource file - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifneq ($$($1_VERSIONINFO_RESOURCE), ) $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res $1_RES_DEPS_FILE := $$($1_RES).d @@ -950,7 +950,7 @@ define SetupNativeCompilationBody ifneq ($(DISABLE_MAPFILES), true) $1_REAL_MAPFILE := $$($1_MAPFILE) - ifneq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), false) ifneq ($$($1_REORDER), ) $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile @@ -984,7 +984,7 @@ define SetupNativeCompilationBody # Only copy debug symbols for dynamic libraries and programs. ifneq ($$($1_TYPE), STATIC_LIBRARY) # Generate debuginfo files. - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \ "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map" ifeq ($(SHIP_DEBUG_SYMBOLS), public) @@ -993,7 +993,7 @@ define SetupNativeCompilationBody $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \ $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map - else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) + else ifeq ($(call isTargetOs, linux solaris), true) $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo # Setup the command line creating debuginfo files, to be run after linking. # It cannot be run separately since it updates the original target file @@ -1009,13 +1009,13 @@ define SetupNativeCompilationBody $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo $1_CREATE_DEBUGINFO_CMDS := $(CP) $$($1_TARGET) $$($1_DEBUGINFO_FILES) - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) $1_DEBUGINFO_FILES := \ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME) $1_CREATE_DEBUGINFO_CMDS := \ $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) - endif # OPENJDK_TARGET_OS + endif # Since the link rule creates more than one file that we want to track, # we have to use some tricks to get make to cooperate. To properly @@ -1101,7 +1101,7 @@ define SetupNativeCompilationBody endif endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifeq ($$($1_EMBED_MANIFEST), true) $1_EXTRA_LDFLAGS += -manifest:embed endif @@ -1181,7 +1181,7 @@ define SetupNativeCompilationBody # Keep as much as possible on one execution line for best performance # on Windows $$(call LogInfo, Linking $$($1_BASENAME)) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ @@ -1199,7 +1199,7 @@ define SetupNativeCompilationBody $$($1_CREATE_DEBUGINFO_CMDS) $$($1_STRIP_CMD) endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifneq ($$($1_MANIFEST), ) $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 endif diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk index 71cb38710be..acb6a303131 100644 --- a/make/common/Utils.gmk +++ b/make/common/Utils.gmk @@ -177,6 +177,23 @@ uppercase = \ $(uppercase_result) \ ) +################################################################################ +# Boolean operators. + +# Return the word "true" if all the boolean words given as argument is "true", +# and returns "false" otherwise. Boolean words must be "true" or "false". It is +# an error to supply a non-boolean word. An empty string is considered "true". +And = \ + $(strip $(if $(filter-out true false, $1), $(error Non-boolean values: $1)) \ + $(if $(strip $(filter-out true, $1)), false, true)) + +# Return the word "false" if all the boolean words given as argument is "false", +# and returns "true" otherwise. Boolean words must be "true" or "false". It is +# an error to supply a non-boolean word. An empty string is considered "false". +Or = \ + $(strip $(if $(filter-out true false, $1), $(error Non-boolean values: $1)) \ + $(if $(strip $(filter-out false, $1)), true, false)) + ################################################################################ # Parse a multiple-keyword variable, like FOO="KEYWORD1=val1;KEYWORD2=val2;..." # These will be converted into a series of variables like FOO_KEYWORD1=val1, @@ -265,6 +282,50 @@ check-jvm-variant = \ $(error Internal error: Invalid variant tested: $1)) \ $(if $(filter $1, $(JVM_VARIANTS)), true, false)) +################################################################################ +# Check if our build or target conforms to certain restrictions. This set of +# functions all work in similar ways, testing the property that the name +# implies, so e.g. isTargetCpu test the CPU of the target system. +# +# $1 - A property, or a space separated list of properties to test for. +# +# Returns true if the actual property matches one of the properties in the list, +# and false otherwise. +# +# Examples: $(call isTargetOs, linux solaris) will return true when executed +# on either linux or solaris, and false otherwise. +# $(call isBuildCpuArch, x86) will return true iff the build CPU Arch is x86. + +isTargetOs = \ + $(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, false)) + +isTargetOsType = \ + $(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false)) + +isTargetCpu = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU), $1), true, false)) + +isTargetCpuArch = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU_ARCH), $1), true, false)) + +isTargetCpuBits = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU_BITS), $1), true, false)) + +isBuildOs = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS), $1), true, false)) + +isBuildOsType = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS_TYPE), $1), true, false)) + +isBuildOsEnv = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS_ENV), $1), true, false)) + +isBuildCpu = \ + $(strip $(if $(filter $(OPENJDK_BUILD_CPU), $1), true, false)) + +isBuildCpuArch = \ + $(strip $(if $(filter $(OPENJDK_BUILD_CPU_ARCH), $1), true, false)) + ################################################################################ # Converts a space separated list to a comma separated list. # diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy-java.base.gmk index 4734d3f2613..8fb59d2e655 100644 --- a/make/copy/Copy-java.base.gmk +++ b/make/copy/Copy-java.base.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk)) ################################################################################ -ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),) +ifeq ($(call isTargetOs, windows aix), true) TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf @@ -89,7 +89,7 @@ endif ################################################################################ # In jvm.cfg, the first listed KNOWN variant is the default. On most build # configurations, that is the server variant. -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86) +ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86)), true) DEFAULT_CFG_VARIANT ?= client endif DEFAULT_CFG_VARIANT ?= server @@ -151,7 +151,7 @@ DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC) DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST) -ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), ) +ifeq ($(call isTargetOs, windows solaris), true) DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy endif @@ -191,7 +191,7 @@ $(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \ TARGETS += $(COPY_NET_PROPERTIES) -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \ FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \ DEST := $(CONF_DST_DIR)/sdp, \ diff --git a/make/copy/Copy-jdk.crypto.cryptoki.gmk b/make/copy/Copy-jdk.crypto.cryptoki.gmk index 7965c568545..f5d1632e7cb 100644 --- a/make/copy/Copy-jdk.crypto.cryptoki.gmk +++ b/make/copy/Copy-jdk.crypto.cryptoki.gmk @@ -27,7 +27,7 @@ include CopyCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) SUNPKCS11_CFG_SRC := \ $(TOPDIR)/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg diff --git a/make/copy/Copy-jdk.crypto.ucrypto.gmk b/make/copy/Copy-jdk.crypto.ucrypto.gmk index 0007e4471ba..a9320e834ce 100644 --- a/make/copy/Copy-jdk.crypto.ucrypto.gmk +++ b/make/copy/Copy-jdk.crypto.ucrypto.gmk @@ -27,7 +27,7 @@ include CopyCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) UCRYPTO_CFG_SRC := $(TOPDIR)/src/jdk.crypto.ucrypto/solaris/conf/security/ucrypto-solaris.cfg UCRYPTO_CFG_DST := $(CONF_DST_DIR)/security/ucrypto-solaris.cfg diff --git a/make/gensrc/Gensrc-java.desktop.gmk b/make/gensrc/Gensrc-java.desktop.gmk index aca529c8134..af5ed4fe7a5 100644 --- a/make/gensrc/Gensrc-java.desktop.gmk +++ b/make/gensrc/Gensrc-java.desktop.gmk @@ -28,11 +28,11 @@ include GensrcCommonJdk.gmk # Hook to include the corresponding custom file, if present. $(eval $(call IncludeCustomExtension, gensrc/Gensrc-java.desktop.gmk)) -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), false) include GensrcIcons.gmk endif -ifneq ($(filter $(OPENJDK_TARGET_OS), linux solaris aix), ) +ifeq ($(call isTargetOs, linux solaris aix), true) include GensrcX11Wrappers.gmk endif @@ -52,21 +52,21 @@ PROP_SRC_DIRS := \ $(TOPDIR)/src/java.desktop/share/classes/sun/print/resources \ # -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) PROP_SRC_DIRS += \ $(TOPDIR)/src/java.desktop/macosx/classes/com/apple/laf/resources \ $(TOPDIR)/src/java.desktop/macosx/classes/sun/awt/resources \ # endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) PROP_SRC_DIRS += \ $(TOPDIR)/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources \ $(TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows \ # endif -ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) PROP_SRC_DIRS += $(TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources endif diff --git a/make/gensrc/Gensrc-jdk.hotspot.agent.gmk b/make/gensrc/Gensrc-jdk.hotspot.agent.gmk index a368a5c109a..6345f12ebb4 100644 --- a/make/gensrc/Gensrc-jdk.hotspot.agent.gmk +++ b/make/gensrc/Gensrc-jdk.hotspot.agent.gmk @@ -42,7 +42,7 @@ TARGETS += $(SA_PROPERTIES) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) MIG_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent MACH_EXC_HEADER := $(MIG_OUTPUT_DIR)/mach_exc.h MACH_EXC_USER := $(MIG_OUTPUT_DIR)/mach_excUser.c diff --git a/make/gensrc/GensrcIcons.gmk b/make/gensrc/GensrcIcons.gmk index de04286e62d..d036618f610 100644 --- a/make/gensrc/GensrcIcons.gmk +++ b/make/gensrc/GensrcIcons.gmk @@ -108,7 +108,7 @@ GENSRC_JAVA_DESKTOP += $(GENSRC_AWT_ICONS) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) GENSRC_OSX_ICONS_DST := $(SUPPORT_OUTPUTDIR)/headers/java.desktop GENSRC_OSX_ICONS := $(GENSRC_OSX_ICONS_DST)/AWTIconData.h diff --git a/make/gensrc/GensrcMisc.gmk b/make/gensrc/GensrcMisc.gmk index 19c37a5f573..3da532e0ce0 100644 --- a/make/gensrc/GensrcMisc.gmk +++ b/make/gensrc/GensrcMisc.gmk @@ -99,7 +99,7 @@ GENSRC_JAVA_BASE += $(GENSRC_SOR_FILE) ################################################################################ -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), false) GENSRC_UC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java @@ -113,7 +113,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) GENSRC_SC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java diff --git a/make/hotspot/CopyToExplodedJdk.gmk b/make/hotspot/CopyToExplodedJdk.gmk index eee2d0cd81e..2413dfcefef 100644 --- a/make/hotspot/CopyToExplodedJdk.gmk +++ b/make/hotspot/CopyToExplodedJdk.gmk @@ -25,7 +25,7 @@ # Copy all built libraries into exploded jdk LIB_TARGETS := $(filter $(LIB_OUTPUTDIR)/%, $(TARGETS)) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupCopyFiles, COPY_LIBS_BIN, \ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \ DEST := $(JDK_OUTPUTDIR)/bin, \ diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index bfb097023da..c5a3ac5724b 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -34,16 +34,16 @@ ifeq ($(call check-jvm-feature, compiler2), true) # Flags depending on the build platform/tool chain # NOTE: No optimization or debug flags set here - ifeq ($(OPENJDK_BUILD_OS), linux) + ifeq ($(call isBuildOs, linux), true) ADLC_CFLAGS := -fno-exceptions -DLINUX - else ifeq ($(OPENJDK_BUILD_OS), solaris) + else ifeq ($(call isBuildOs, solaris), true) ADLC_LDFLAGS := -m64 ADLC_CFLAGS := -m64 ADLC_CFLAGS_WARNINGS := +w - else ifeq ($(OPENJDK_BUILD_OS), aix) + else ifeq ($(call isBuildOs, aix), true) ADLC_LDFLAGS := -q64 ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX - else ifeq ($(OPENJDK_BUILD_OS), windows) + else ifeq ($(call isBuildOs, windows), true) ADLC_LDFLAGS := -nologo ADLC_CFLAGS := -nologo -EHsc # NOTE: The old build also have -D_CRT_SECURE_NO_DEPRECATE but it doesn't @@ -91,13 +91,13 @@ ifeq ($(call check-jvm-feature, compiler2), true) ADLCFLAGS += -q -T # ADLC flags depending on target OS - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1 - else ifeq ($(OPENJDK_TARGET_OS), solaris) + else ifeq ($(call isTargetOs, solaris), true) ADLCFLAGS += -DSOLARIS=1 -DSPARC_WORKS=1 - else ifeq ($(OPENJDK_TARGET_OS), aix) + else ifeq ($(call isTargetOs, aix), true) ADLCFLAGS += -DAIX=1 - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1 ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64) ADLCFLAGS += -DR18_RESERVED @@ -111,7 +111,7 @@ ifeq ($(call check-jvm-feature, compiler2), true) endif endif - ifneq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), false) # NOTE: Windows adlc flags was different in the old build. Is this really # correct? @@ -123,7 +123,7 @@ ifeq ($(call check-jvm-feature, compiler2), true) # This generates checks in the generated C++ files that _LP64 is correctly # (un)defined when compiling them. - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) ADLCFLAGS += -D_LP64=1 else ADLCFLAGS += -U_LP64 diff --git a/make/hotspot/gensrc/GensrcDtrace.gmk b/make/hotspot/gensrc/GensrcDtrace.gmk index 9b279e8200c..304e29b78f6 100644 --- a/make/hotspot/gensrc/GensrcDtrace.gmk +++ b/make/hotspot/gensrc/GensrcDtrace.gmk @@ -28,12 +28,12 @@ ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) DTRACE_FLAGS := -64 DTRACE_CPP_FLAGS := -D_LP64 - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) DTRACE_CPP_FLAGS := -D_LP64 -x c - else ifeq ($(OPENJDK_TARGET_OS), linux) + else ifeq ($(call isTargetOs, linux), true) DTRACE_CPP_FLAGS := -x c endif @@ -54,7 +54,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) TARGETS += $(patsubst $(DTRACE_SOURCE_DIR)/%.d, \ $(DTRACE_GENSRC_DIR)/%.h, $(wildcard $(DTRACE_SOURCE_DIR)/*.d)) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) ############################################################################ # First we need to generate the dtraceGenOffsets tool. When run, this will # produce two header files and a C++ file. Note that generateJvmOffsets.cpp diff --git a/make/hotspot/ide/CreateVSProject.gmk b/make/hotspot/ide/CreateVSProject.gmk index 2cc9dab68e2..2c6507d363e 100644 --- a/make/hotspot/ide/CreateVSProject.gmk +++ b/make/hotspot/ide/CreateVSProject.gmk @@ -31,7 +31,7 @@ include MakeBase.gmk include JavaCompilation.gmk include SetupJavaCompilers.gmk -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # The next part is a bit hacky. We include the CompileJvm.gmk to be # able to extact flags, but we do not wish to execute the rules. diff --git a/make/hotspot/lib/CompileDtraceLibraries.gmk b/make/hotspot/lib/CompileDtraceLibraries.gmk index 391f1355472..d354f926601 100644 --- a/make/hotspot/lib/CompileDtraceLibraries.gmk +++ b/make/hotspot/lib/CompileDtraceLibraries.gmk @@ -24,7 +24,7 @@ # ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) ############################################################################ # Build the stand-alone dtrace libraries. diff --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk index ecbefa5c94b..891c540bb80 100644 --- a/make/hotspot/lib/CompileGtest.gmk +++ b/make/hotspot/lib/CompileGtest.gmk @@ -31,7 +31,7 @@ GTEST_FRAMEWORK_SRC := $(TOPDIR)/test/fmw/gtest # On Windows, there are no internal debug symbols so must set copying to true # to get any at all. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) GTEST_COPY_DEBUG_SYMBOLS := true else GTEST_COPY_DEBUG_SYMBOLS := false @@ -39,7 +39,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) GTEST_JVM_MAPFILE := $(JVM_MAPFILE) else GTEST_JVM_MAPFILE := $(JVM_OUTPUTDIR)/gtest/mapfile diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 5c2aac6cc5a..bce8bf0c9d1 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -58,9 +58,9 @@ JVM_EXCLUDE_FILES += args.cc JVM_EXCLUDES += adlc # Needed by abstract_vm_version.cpp -ifeq ($(OPENJDK_TARGET_CPU), x86_64) +ifeq ($(call isTargetCpu, x86_64), true) OPENJDK_TARGET_CPU_VM_VERSION := amd64 -else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) +else ifeq ($(call isTargetCpu, sparcv9), true) OPENJDK_TARGET_CPU_VM_VERSION := sparc else ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm) ifeq ($(OPENJDK_TARGET_CPU), aarch64) @@ -86,10 +86,10 @@ CFLAGS_VM_VERSION := \ # ARM source selection -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-arm) +ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, arm)), true) JVM_EXCLUDE_PATTERNS += arm_64 -else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64) +else ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true) # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm. # Exclude the aarch64 and 32 bit arm files for this build. @@ -98,21 +98,21 @@ else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64) endif endif -ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), ) +ifeq ($(call isTargetOs, linux macosx windows), true) JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp endif -ifeq ($(OPENJDK_TARGET_CPU), x86) +ifeq ($(call isTargetCpu, x86), true) JVM_EXCLUDE_PATTERNS += x86_64 -else ifeq ($(OPENJDK_TARGET_CPU), x86_64) +else ifeq ($(call isTargetCpu, x86_64), true) JVM_EXCLUDE_PATTERNS += x86_32 endif # Inline assembly for solaris -ifeq ($(OPENJDK_TARGET_OS), solaris) - ifeq ($(OPENJDK_TARGET_CPU), x86_64) +ifeq ($(call isTargetOs, solaris), true) + ifeq ($(call isTargetCpu, x86_64), true) JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.il - else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) + else ifeq ($(call isTargetCpu, sparcv9), true) JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_sparc/solaris_sparc.il endif # Exclude warnings in devstudio 12.6 @@ -122,7 +122,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) endif endif -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false) # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless # of if debug symbols were needed. Without it, compilation fails on @@ -131,8 +131,8 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) endif endif -ifeq ($(OPENJDK_TARGET_OS), windows) - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) +ifeq ($(call isTargetOs, windows), true) + ifeq ($(call isTargetCpuBits, 64), true) RC_DESC := 64-Bit$(SPACE) endif JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM" @@ -190,7 +190,7 @@ $(ABSTRACT_VM_VERSION_OBJ): $(filter-out $(ABSTRACT_VM_VERSION_OBJ) $(JVM_MAPFIL $(BUILD_LIBJVM_TARGET_DEPS)) ifneq ($(GENERATE_COMPILE_COMMANDS_ONLY), true) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) # It doesn't matter which jvm.lib file gets exported, but we need # to pick just one. ifeq ($(JVM_VARIANT), $(JVM_VARIANT_MAIN)) diff --git a/make/hotspot/lib/JvmDtraceObjects.gmk b/make/hotspot/lib/JvmDtraceObjects.gmk index 895cfdf4907..52000fa5058 100644 --- a/make/hotspot/lib/JvmDtraceObjects.gmk +++ b/make/hotspot/lib/JvmDtraceObjects.gmk @@ -24,7 +24,7 @@ # ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) ############################################################################ # Integrate with libjvm. Here we generate two object files which are @@ -131,7 +131,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) > $(DTRACE_SUPPORT_DIR)/$(@F).d)) $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \ -s $(DTRACE_SUPPORT_DIR)/$(@F).d) - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@) endif diff --git a/make/hotspot/lib/JvmFeatures.gmk b/make/hotspot/lib/JvmFeatures.gmk index 752568132f8..7b86f83cc98 100644 --- a/make/hotspot/lib/JvmFeatures.gmk +++ b/make/hotspot/lib/JvmFeatures.gmk @@ -47,14 +47,14 @@ endif ifeq ($(call check-jvm-feature, zero), true) JVM_CFLAGS_FEATURES += -DZERO -DCC_INTERP -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS) JVM_LIBS_FEATURES += $(LIBFFI_LIBS) - ifeq ($(OPENJDK_TARGET_CPU), sparcv9) + ifeq ($(call isTargetCpu, sparcv9), true) BUILD_LIBJVM_EXTRA_FILES := $(TOPDIR)/src/hotspot/cpu/sparc/memset_with_concurrent_readers_sparc.cpp endif endif ifeq ($(call check-jvm-feature, minimal), true) JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\" - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) # Override the default -g with a more liberal strip policy for the minimal JVM JVM_STRIPFLAGS := --strip-unneeded endif diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index 9e62c37091d..903a6192f52 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -74,7 +74,7 @@ ifeq ($(DEBUG_LEVEL), release) endif else ifeq ($(DEBUG_LEVEL), fastdebug) JVM_CFLAGS_DEBUGLEVEL := -DASSERT - ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), ) + ifeq ($call isTargetOs, windows aix), false) # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX. JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS endif diff --git a/make/hotspot/lib/JvmMapfile.gmk b/make/hotspot/lib/JvmMapfile.gmk index 81bc880fd4f..ba44e579832 100644 --- a/make/hotspot/lib/JvmMapfile.gmk +++ b/make/hotspot/lib/JvmMapfile.gmk @@ -28,13 +28,13 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/JvmMapfile.gmk)) ################################################################################ # Combine a list of static symbols -ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86_64) +ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86_64)), false) # On Windows x86_64, we should not have any symbols at all, since that # results in duplicate warnings from the linker (JDK-8043491). SYMBOLS_SRC += $(TOPDIR)/make/hotspot/symbols/symbols-shared endif -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) SYMBOLS_SRC += $(TOPDIR)/make/hotspot/symbols/symbols-unix endif @@ -48,7 +48,7 @@ ifneq ($(findstring debug, $(DEBUG_LEVEL)), ) endif endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) ifeq ($(call check-jvm-feature, dtrace), true) # Additional mapfiles that are only used when dtrace is enabled ifeq ($(call check-jvm-feature, compiler2), true) @@ -64,7 +64,7 @@ endif # Create a dynamic list of symbols from the built object files. This is highly # platform dependent. -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) DUMP_SYMBOLS_CMD := $(NM) --defined-only *.o ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| @@ -76,7 +76,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) DUMP_SYMBOLS_CMD := $(NM) -p *.o ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| @@ -90,7 +90,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) # nm on macosx prints out "warning: nm: no name list" to stderr for # files without symbols. Hide this, even at the expense of hiding real errors. DUMP_SYMBOLS_CMD := $(NM) -Uj *.o 2> /dev/null @@ -107,7 +107,7 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) # The script below might be what was intended, but it failes to link with tons # of 'cannot export hidden symbol vtable for X'. # '{ if ($$1 ~ /^__ZTV/ || $$1 ~ /^_gHotSpotVM/) print substr($$1, 2) }' -else ifeq ($(OPENJDK_TARGET_OS), aix) +else ifeq ($(call isTargetOs, aix), true) # NOTE: The old build had the solution below. This should to be fixed in # configure instead. @@ -123,7 +123,7 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) if ($$3 ~ /^SharedArchivePath__9Arguments$$/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) DUMP_SYMBOLS_CMD := $(DUMPBIN) -symbols *.obj FILTER_SYMBOLS_AWK_SCRIPT := \ '{ \ @@ -153,12 +153,12 @@ $(JVM_OUTPUTDIR)/symbols: $(SYMBOLS_SRC) ################################################################################ # Finally convert the symbol list into a platform-specific mapfile -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # On macosx, we need to add a leading underscore define create-mapfile-work $(AWK) '{ if ($$0 ~ ".") { print " _" $$0 } }' < $^ > $@.tmp endef -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) # On windows, add an 'EXPORTS' header define create-mapfile-work $(ECHO) "EXPORTS" > $@.tmp diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 17e73b25685..ed961352e1d 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -50,7 +50,7 @@ ifneq ($(FDLIBM_CFLAGS), ) LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NORM) endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) BUILD_LIBJVM_ostream.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64 BUILD_LIBJVM_logFileOutput.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64 @@ -64,7 +64,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) # endif - ifeq ($(OPENJDK_TARGET_CPU), x86) + ifeq ($(call isTargetCpu, x86), true) # Performance measurements show that by compiling GC related code, we could # significantly reduce the GC pause time on 32 bit Linux/Unix platforms by # compiling without the PIC flag (-fPIC on linux). @@ -82,7 +82,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) $(foreach s, $(NONPIC_SRC), $(eval BUILD_LIBJVM_$(notdir $s)_CXXFLAGS := -fno-PIC)) endif -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) ifneq ($(DEBUG_LEVEL), slowdebug) # dev studio 12.6 workaround BUILD_LIBJVM_arguments.cpp_OPTIMIZATION := LOW @@ -96,7 +96,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) BUILD_LIBJVM_jni.cpp_CXXFLAGS := -Qoption ube -O~yz BUILD_LIBJVM_stubGenerator_$(HOTSPOT_TARGET_CPU).cpp_CXXFLAGS := -xspace - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) # Temporary until SS10 C++ compiler is fixed BUILD_LIBJVM_generateOptoStub.cpp_CXXFLAGS := -xO2 # Temporary util SS12u1 C++ compiler is fixed @@ -117,7 +117,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) BUILD_LIBJVM_bytecodeInterpreter.cpp_CXXFLAGS := +d BUILD_LIBJVM_bytecodeInterpreterWithChecks.cpp_CXXFLAGS := +d - ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86) + ifeq ($(call isTargetCpuArch, x86), true) # ube explodes on x86 BUILD_LIBJVM_bytecodeInterpreter.cpp_CXXFLAGS += -xO1 BUILD_LIBJVM_bytecodeInterpreterWithChecks.cpp_CXXFLAGS += -xO1 @@ -128,7 +128,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) # Workaround for jvmciCompilerToVM.cpp long compilation time BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_OPTIMIZATION := NONE -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) # The copied fdlibm routines in these files must not be optimized BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) @@ -155,7 +155,7 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) # endif -else ifeq ($(OPENJDK_TARGET_OS), aix) +else ifeq ($(call isTargetOs, aix), true) BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -qnoinline BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE) # Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp @@ -180,7 +180,7 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) # Disable ELF decoder on AIX (AIX uses XCOFF). JVM_EXCLUDE_PATTERNS += elf -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) JVM_PRECOMPILED_HEADER_EXCLUDE := \ bytecodeInterpreter.cpp \ bytecodeInterpreterWithChecks.cpp \ diff --git a/make/hotspot/test/GtestImage.gmk b/make/hotspot/test/GtestImage.gmk index 596b978a73b..52161e7f28f 100644 --- a/make/hotspot/test/GtestImage.gmk +++ b/make/hotspot/test/GtestImage.gmk @@ -37,7 +37,7 @@ $(foreach v, $(JVM_VARIANTS), \ $(eval TARGETS += $$(COPY_GTEST_$v)) \ ) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(foreach v, $(JVM_VARIANTS), \ $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCR_$v, \ DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ @@ -68,7 +68,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) ) endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) $(foreach v, $(JVM_VARIANTS), \ $(eval $(call SetupCopyFiles, COPY_GTEST_STLPORT_$v, \ DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ diff --git a/make/launcher/Launcher-java.base.gmk b/make/launcher/Launcher-java.base.gmk index f6d4aa28fe6..a8990dd0efc 100644 --- a/make/launcher/Launcher-java.base.gmk +++ b/make/launcher/Launcher-java.base.gmk @@ -41,7 +41,7 @@ $(eval $(call SetupBuildLauncher, java, \ OPTIMIZATION := HIGH, \ )) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupBuildLauncher, javaw, \ CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ LIBS_windows := user32.lib comctl32.lib, \ @@ -56,7 +56,7 @@ $(eval $(call SetupBuildLauncher, keytool, \ ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) $(eval $(call SetupJdkExecutable, BUILD_JEXEC, \ NAME := jexec, \ SRC := $(TOPDIR)/src/$(MODULE)/unix/native/launcher, \ @@ -75,7 +75,7 @@ endif ################################################################################ -ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix linux), ) +ifeq ($(call isTargetOs, macosx solaris aix linux), true) $(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \ NAME := jspawnhelper, \ SRC := $(TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \ diff --git a/make/launcher/Launcher-java.security.jgss.gmk b/make/launcher/Launcher-java.security.jgss.gmk index 7411e1a21c4..b57800e5c9f 100644 --- a/make/launcher/Launcher-java.security.jgss.gmk +++ b/make/launcher/Launcher-java.security.jgss.gmk @@ -25,7 +25,7 @@ include LauncherCommon.gmk -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupBuildLauncher, kinit, \ MAIN_CLASS := sun.security.krb5.internal.tools.Kinit, \ )) diff --git a/make/launcher/Launcher-jdk.accessibility.gmk b/make/launcher/Launcher-jdk.accessibility.gmk index f31d039aab4..fbf3d9493ae 100644 --- a/make/launcher/Launcher-jdk.accessibility.gmk +++ b/make/launcher/Launcher-jdk.accessibility.gmk @@ -28,7 +28,7 @@ include LauncherCommon.gmk ################################################################################ # jabswitch -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) JABSWITCH_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/jabswitch ACCESSBRIDGE_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/common @@ -98,7 +98,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endef - ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + ifeq ($(call isTargetCpuBits, 32), true) $(eval $(call SetupInspector,-32,32)) $(eval $(call SetupWalker,-32,32)) $(eval $(call SetupInspector,,LEGACY)) diff --git a/make/launcher/Launcher-jdk.pack.gmk b/make/launcher/Launcher-jdk.pack.gmk index a93fd2a9017..457251b5a57 100644 --- a/make/launcher/Launcher-jdk.pack.gmk +++ b/make/launcher/Launcher-jdk.pack.gmk @@ -45,7 +45,7 @@ ifeq ($(TOOLCHAIN_TYPE), gcc) CXXFLAGS_JDKEXE += -fvisibility=hidden LDFLAGS_JDKEXE += -Wl,--exclude-libs,ALL else ifeq ($(TOOLCHAIN_TYPE), clang) - ifneq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), false) CXXFLAGS_JDKEXE += -fvisibility=hidden endif else ifeq ($(TOOLCHAIN_TYPE), solstudio) diff --git a/make/launcher/LauncherCommon.gmk b/make/launcher/LauncherCommon.gmk index ac0e3d1b2f8..fc274577214 100644 --- a/make/launcher/LauncherCommon.gmk +++ b/make/launcher/LauncherCommon.gmk @@ -207,11 +207,11 @@ define SetupBuildLauncherBody $$(BUILD_LAUNCHER_$1): $$(BUILD_PLIST_$1) - ifeq ($(OPENJDK_TARGET_OS), aix) + ifeq ($(call isTargetOs, aix), true) $$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, jli_static) endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, java, /libjava) \ $$($1_WINDOWS_JLI_LIB) endif diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk index b3cbdf20505..282b59a76ce 100644 --- a/make/lib/Awt2dLibraries.gmk +++ b/make/lib/Awt2dLibraries.gmk @@ -44,7 +44,7 @@ BUILD_LIBMLIB_EXCLUDE_SRC_PATTERNS := unix BUILD_LIBMLIB_CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES -DMLIB_NO_LIBSUNMATH -ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) +ifeq ($(call isTargetCpuBits, 64), true) BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT endif @@ -68,7 +68,7 @@ TARGETS += $(BUILD_LIBMLIB_IMAGE) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), true) # libmlib_image_v is basically built from mlib_image sources, with some additions # and some exclusions. @@ -80,7 +80,7 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) LIBMLIB_IMAGE_V_CFLAGS := -xarch=sparcvis -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \ $(TOPDIR)/src/$(MODULE)/unix/native/libmlib_image/vis_$(OPENJDK_TARGET_CPU_BITS).il - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) LIBMLIB_IMAGE_V_CFLAGS += -DMLIB_OS64BIT endif @@ -127,11 +127,11 @@ LIBAWT_EXTRA_SRC := \ $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ # -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), true) LIBAWT_EXTRA_SRC += $(TOPDIR)/src/$(MODULE)/share/native/common/awt/medialib endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_EXTRA_SRC += \ $(TOPDIR)/src/$(MODULE)/share/native/common/awt/utility \ $(TOPDIR)/src/$(MODULE)/share/native/common/font \ @@ -140,22 +140,22 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # endif -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx aix), ) +ifeq ($(call isTargetOs, solaris linux macosx aix), true) LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBAWT_EXFILES += initIDs.c awt/image/cvutils/img_colors.c endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_EXFILES += \ java2d/d3d/D3DShaderGen.c \ awt/image/cvutils/img_colors.c \ # endif -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) LIBAWT_EXFILES += java2d/loops/MapAccelFunc.c else LIBAWT_EXCLUDES += \ @@ -182,20 +182,20 @@ LIBAWT_EXTRA_HEADER_DIRS := \ LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS) -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) LIBAWT_CFLAGS += -xarch=sparcvis -DMLIB_ADD_SUFF \ $(TOPDIR)/src/$(MODULE)/unix/native/libmlib_image/vis_$(OPENJDK_TARGET_CPU_BITS).il LIBAWT_ASFLAGS = -P -xarch=v9a endif -ifneq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), false) LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_CFLAGS += -EHsc -DUNICODE -D_UNICODE - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) LIBAWT_CFLAGS += -DMLIB_OS64BIT endif @@ -203,7 +203,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) # FIXME: This is probably not what we want to do, but keep it now for compatibility. LIBAWT_CFLAGS += $(EXPORT_ALL_SYMBOLS) endif @@ -261,7 +261,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ $(BUILD_LIBAWT): $(call FindLib, java.base, java) -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBAWT): $(BUILD_LIBMLIB_IMAGE) endif @@ -269,7 +269,7 @@ TARGETS += $(BUILD_LIBAWT) ################################################################################ -ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBAWT_XAWT_EXTRA_SRC := \ @@ -296,11 +296,11 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) $(FONTCONFIG_CFLAGS) \ $(CUPS_CFLAGS) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15 endif - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) ifeq ($(DISABLE_XRENDER), true) LIBAWT_XAWT_CFLAGS += -DDISABLE_XRENDER_BY_DEFAULT=true endif @@ -308,7 +308,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) LIBAWT_XAWT_LIBS += -lpthread endif @@ -448,7 +448,7 @@ TARGETS += $(BUILD_LIBJAVAJPEG) ################################################################################ # Mac and Windows only use the native AWT lib, do not build libawt_headless -ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) +ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_HEADLESS_EXTRA_SRC := \ common/font \ @@ -508,7 +508,7 @@ else # For use by libfontmanager: LIBFREETYPE_CFLAGS := -I$(BUILD_LIBFREETYPE_HEADER_DIRS) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) LIBFREETYPE_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfreetype/freetype.lib # freetype now requires you to manually define this (see ftconfig.h) BUILD_LIBFREETYPE_CFLAGS += -DDLL_EXPORT @@ -544,16 +544,16 @@ else LIBFONTMANAGER_EXTRA_SRC = libharfbuzz HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND # Modern HarfBuzz requires c++11; but VS does not have the flag - ifneq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), false) HARFBUZZ_CXXFLAGS := -std=c++11 HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \ -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \ -DHB_NO_PRAGMA_GCC_DIAGNOSTIC endif - ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx)) + ifeq ($(call isTargetOs, linux macosx), true) HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES endif - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) HARFBUZZ_CFLAGS += -DHAVE_SOLARIS_ATOMIC_OPS endif # hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later. @@ -602,11 +602,11 @@ ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), ) BUILD_LIBFONTMANAGER_hb-subset-plan.cc_OPTIMIZATION := SIZE endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c LIBFONTMANAGER_OPTIMIZATION := HIGHEST -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c \ fontpath.c \ @@ -660,7 +660,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \ $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt) endif @@ -672,7 +672,7 @@ TARGETS += $(BUILD_LIBFONTMANAGER) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBJAWT_CFLAGS := -EHsc -DUNICODE -D_UNICODE @@ -688,7 +688,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) java.base:libjava \ # - ifeq ($(OPENJDK_TARGET_CPU), x86) + ifeq ($(call isTargetCpu, x86), true) KERNEL32_LIB := kernel32.lib endif @@ -713,25 +713,25 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(COPY_JAWT_LIB) -else # OPENJDK_TARGET_OS not windows +else # not windows - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libjawt on macosx do not use the unix code LIBJAWT_EXCLUDE_SRC_PATTERNS := unix endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) JAWT_LIBS := -lawt_lwawt else JAWT_LIBS := - ifneq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), false) JAWT_LIBS += -lawt endif ifeq ($(ENABLE_HEADLESS_ONLY), false) JAWT_LIBS += -lawt_xawt else JAWT_LIBS += -lawt_headless - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) JAWT_CFLAGS += -DHEADLESS endif endif @@ -762,11 +762,11 @@ else # OPENJDK_TARGET_OS not windows $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_headless) endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_lwawt) endif -endif # OPENJDK_TARGET_OS +endif TARGETS += $(BUILD_LIBJAWT) @@ -818,7 +818,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBZ_DISABLED_WARNINGS_CLANG := format-nonliteral endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libsplashscreen on macosx do not use the unix code LIBSPLASHSCREEN_EXCLUDE_SRC_PATTERNS := unix endif @@ -826,13 +826,13 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \ -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_IMPLEMENTATION=0 - ifeq ($(OPENJDK_TARGET_OS), linux) - ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc) + ifeq ($(call isTargetOs, linux), true) + ifeq ($(call isTargetCpuArch, ppc), true) LIBSPLASHSCREEN_CFLAGS += -DPNG_POWERPC_VSX_OPT=0 endif endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX BUILD_LIBSPLASHSCREEN_java_awt_SplashScreen.c_CFLAGS := -x objective-c -O0 @@ -843,7 +843,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) BUILD_LIBSPLASHSCREEN_splashscreen_png.c_CFLAGS := -x objective-c -O0 BUILD_LIBSPLASHSCREEN_splashscreen_sys.m_CFLAGS := -O0 - else ifeq ($(OPENJDK_TARGET_OS), windows) + else ifeq ($(call isTargetOs, windows), true) LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32 else LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS) @@ -851,13 +851,13 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_LIBS := - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBSPLASHSCREEN_LIBS += \ $(LIBM) -lpthread -liconv -losxapp \ -framework ApplicationServices \ -framework Foundation \ -framework Cocoa - else ifeq ($(OPENJDK_TARGET_OS), windows) + else ifeq ($(call isTargetOs, windows), true) LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib else LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl @@ -897,7 +897,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) TARGETS += $(BUILD_LIBSPLASHSCREEN) - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBSPLASHSCREEN): $(call FindLib, $(MODULE), osxapp) endif @@ -905,7 +905,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBAWT_LWAWT_EXTRA_SRC := \ $(TOPDIR)/src/$(MODULE)/unix/native/common/awt \ @@ -972,7 +972,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBOSXUI, \ NAME := osxui, \ diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk index 37fed495955..6b6b5cca7fb 100644 --- a/make/lib/CoreLibraries.gmk +++ b/make/lib/CoreLibraries.gmk @@ -35,7 +35,7 @@ $(eval $(call IncludeCustomExtension, lib/CoreLibraries.gmk)) BUILD_LIBFDLIBM_OPTIMIZATION := NONE -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) BUILD_LIBFDLIBM_OPTIMIZATION := HIGH endif @@ -67,7 +67,7 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \ ########################################################################################## LIBVERIFY_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBVERIFY_OPTIMIZATION := LOW endif @@ -91,7 +91,7 @@ TARGETS += $(BUILD_LIBVERIFY) LIBJAVA_CFLAGS := -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"' -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c endif @@ -199,7 +199,7 @@ ifeq ($(LIBJLI_ALL_ERGO), $(LIBJLI_EXCLUDE_ERGO)) endif LIBJLI_EXCLUDE_FILES += $(notdir $(LIBJLI_EXCLUDE_ERGO)) -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c ergo_i586.c BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c @@ -208,7 +208,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE) # Supply the name of the C runtime lib. LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"' @@ -263,7 +263,7 @@ TARGETS += $(BUILD_LIBJLI) LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli) -ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), true) # AIX also requires a static libjli because the compiler doesn't support '-rpath' $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \ NAME := jli_static, \ diff --git a/make/lib/Lib-java.base.gmk b/make/lib/Lib-java.base.gmk index a529768f39e..4cd656a0860 100644 --- a/make/lib/Lib-java.base.gmk +++ b/make/lib/Lib-java.base.gmk @@ -96,7 +96,7 @@ $(BUILD_LIBNIO): $(BUILD_LIBNET) ################################################################################ # Create the macosx security library -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # JavaNativeFoundation framework not supported in static builds ifneq ($(STATIC_BUILD), true) @@ -126,7 +126,7 @@ endif ################################################################################ # Create the jsig library -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) ifeq ($(STATIC_BUILD), false) LIBJSIG_MAPFILE := $(wildcard $(TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS)) diff --git a/make/lib/Lib-java.desktop.gmk b/make/lib/Lib-java.desktop.gmk index 274df2b8e4c..25c328689fe 100644 --- a/make/lib/Lib-java.desktop.gmk +++ b/make/lib/Lib-java.desktop.gmk @@ -39,7 +39,7 @@ include Awt2dLibraries.gmk ################################################################################ # Create the libjsound library -ifneq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), false) LIBJSOUND_CFLAGS := \ $(ALSA_CFLAGS) \ @@ -48,14 +48,14 @@ ifneq ($(OPENJDK_TARGET_OS), aix) -DUSE_DAUDIO=TRUE \ # - ifneq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), false) LIBJSOUND_CFLAGS += \ -DUSE_PLATFORM_MIDI_OUT=TRUE \ -DUSE_PLATFORM_MIDI_IN=TRUE \ # endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX endif @@ -85,7 +85,7 @@ endif ################################################################################ # Create the macosx specific osxapp and osx libraries -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBOSXAPP, \ NAME := osxapp, \ @@ -141,4 +141,3 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) $(BUILD_LIBOSX): $(call FindLib, java.base, java) endif - diff --git a/make/lib/Lib-java.instrument.gmk b/make/lib/Lib-java.instrument.gmk index 9acde85ffd3..d5e0400e746 100644 --- a/make/lib/Lib-java.instrument.gmk +++ b/make/lib/Lib-java.instrument.gmk @@ -30,7 +30,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-java.instrument.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # equivalent of strcasecmp is stricmp on Windows LIBINSTRUMENT_CFLAGS := -Dstrcasecmp=stricmp WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib @@ -64,7 +64,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \ $(WINDOWS_JLI_LIB), \ )) -ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), true) $(BUILD_LIBINSTRUMENT): $(call FindStaticLib, java.base, jli_static) else ifeq ($(OPENJDK_TARGET_OS), windows) $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli) diff --git a/make/lib/Lib-java.management.gmk b/make/lib/Lib-java.management.gmk index a70a3ccf45a..90a61882342 100644 --- a/make/lib/Lib-java.management.gmk +++ b/make/lib/Lib-java.management.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-java.management.gmk)) ################################################################################ LIBMANAGEMENT_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_OPTIMIZATION := LOW endif @@ -57,4 +57,3 @@ TARGETS += $(BUILD_LIBMANAGEMENT) # Include custom extension post hook $(eval $(call IncludeCustomExtension, lib/Lib-java.management-post.gmk)) - diff --git a/make/lib/Lib-java.prefs.gmk b/make/lib/Lib-java.prefs.gmk index cac3b17e26a..f43897245b2 100644 --- a/make/lib/Lib-java.prefs.gmk +++ b/make/lib/Lib-java.prefs.gmk @@ -28,7 +28,7 @@ include LibCommon.gmk ################################################################################ # libprefs on macosx do not use the unix code -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBPREFS_EXCLUDE_SRC_PATTERNS := unix endif diff --git a/make/lib/Lib-java.security.jgss.gmk b/make/lib/Lib-java.security.jgss.gmk index 2daf04842db..642b3bcd415 100644 --- a/make/lib/Lib-java.security.jgss.gmk +++ b/make/lib/Lib-java.security.jgss.gmk @@ -42,7 +42,7 @@ TARGETS += $(BUILD_LIBJ2GSS) ifneq ($(BUILD_CRYPTO), false) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBW2K_LSA_AUTH, \ NAME := w2k_lsa_auth, \ OPTIMIZATION := LOW, \ @@ -68,7 +68,7 @@ ifneq ($(BUILD_CRYPTO), false) TARGETS += $(BUILD_LIBSSPI_BRIDGE) endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libosxkrb5 needs to call deprecated krb5 APIs so that java # can use the native credentials cache. $(eval $(call SetupJdkLibrary, BUILD_LIBOSXKRB5, \ diff --git a/make/lib/Lib-jdk.accessibility.gmk b/make/lib/Lib-jdk.accessibility.gmk index cdf3a7ced8f..667ac83dbd4 100644 --- a/make/lib/Lib-jdk.accessibility.gmk +++ b/make/lib/Lib-jdk.accessibility.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) ROOT_SRCDIR := $(TOPDIR)/src/jdk.accessibility/windows/native @@ -100,7 +100,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endef - ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + ifeq ($(call isTargetCpuBits, 32), true) $(eval $(call SetupAccessBridgeSysInfo)) $(eval $(call SetupJavaDLL,-32,32)) $(eval $(call SetupJavaDLL,,LEGACY)) diff --git a/make/lib/Lib-jdk.attach.gmk b/make/lib/Lib-jdk.attach.gmk index 1c24e554037..2a3a3b162e7 100644 --- a/make/lib/Lib-jdk.attach.gmk +++ b/make/lib/Lib-jdk.attach.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate # a binary that is compatible with windows versions older than 7/2008R2. # See MSDN documentation for GetProcessMemoryInfo for more information. diff --git a/make/lib/Lib-jdk.crypto.mscapi.gmk b/make/lib/Lib-jdk.crypto.mscapi.gmk index 88a3270cfbb..e8e92dca3bc 100644 --- a/make/lib/Lib-jdk.crypto.mscapi.gmk +++ b/make/lib/Lib-jdk.crypto.mscapi.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBSUNMSCAPI, \ NAME := sunmscapi, \ diff --git a/make/lib/Lib-jdk.crypto.ucrypto.gmk b/make/lib/Lib-jdk.crypto.ucrypto.gmk index c00e543737b..1be9af45583 100644 --- a/make/lib/Lib-jdk.crypto.ucrypto.gmk +++ b/make/lib/Lib-jdk.crypto.ucrypto.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) $(eval $(call SetupJdkLibrary, BUILD_LIBJ2UCRYPTO, \ NAME := j2ucrypto, \ diff --git a/make/lib/Lib-jdk.hotspot.agent.gmk b/make/lib/Lib-jdk.hotspot.agent.gmk index e137a4f1017..07bd7d74274 100644 --- a/make/lib/Lib-jdk.hotspot.agent.gmk +++ b/make/lib/Lib-jdk.hotspot.agent.gmk @@ -29,19 +29,19 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/Lib-jdk.hotspot.agent.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) SA_CFLAGS := -D_FILE_OFFSET_BITS=64 -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) SA_LDFLAGS := -mt -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) SA_CFLAGS := -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \ -mstack-alignment=16 -fPIC LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) SA_CFLAGS := -D_WINDOWS -D_DEBUG -D_CONSOLE -D_MBCS -EHsc - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) SA_CXXFLAGS := -DWIN64 else # Only add /RTC1 flag for debug builds as it's diff --git a/make/lib/Lib-jdk.internal.le.gmk b/make/lib/Lib-jdk.internal.le.gmk index 0aa7bb273f5..785542f6247 100644 --- a/make/lib/Lib-jdk.internal.le.gmk +++ b/make/lib/Lib-jdk.internal.le.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBLE, \ NAME := le, \ @@ -39,6 +39,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(BUILD_LIBLE) -endif # OPENJDK_TARGET_OS +endif ################################################################################ diff --git a/make/lib/Lib-jdk.jdi.gmk b/make/lib/Lib-jdk.jdi.gmk index 197b95c2e20..354ccb32e6a 100644 --- a/make/lib/Lib-jdk.jdi.gmk +++ b/make/lib/Lib-jdk.jdi.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBDT_SHMEM, \ NAME := dt_shmem, \ @@ -42,6 +42,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(BUILD_LIBDT_SHMEM) -endif # OPENJDK_TARGET_OS +endif ################################################################################ diff --git a/make/lib/Lib-jdk.management.gmk b/make/lib/Lib-jdk.management.gmk index 29bfc7a5aa2..a164707db4a 100644 --- a/make/lib/Lib-jdk.management.gmk +++ b/make/lib/Lib-jdk.management.gmk @@ -30,7 +30,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-jdk.management.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate # a binary that is compatible with windows versions older than 7/2008R2. # See MSDN documentation for GetProcessMemoryInfo for more information. @@ -38,7 +38,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endif LIBMANAGEMENT_EXT_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_EXT_OPTIMIZATION := LOW endif @@ -64,4 +64,3 @@ TARGETS += $(BUILD_LIBMANAGEMENT_EXT) # Include custom extension post hook $(eval $(call IncludeCustomExtension, lib/Lib-jdk.management-post.gmk)) - diff --git a/make/lib/Lib-jdk.net.gmk b/make/lib/Lib-jdk.net.gmk index b202c6373f7..7e828018950 100644 --- a/make/lib/Lib-jdk.net.gmk +++ b/make/lib/Lib-jdk.net.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx), ) +ifeq ($(call isTargetOs, solaris linux macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \ NAME := extnet, \ diff --git a/make/lib/Lib-jdk.sctp.gmk b/make/lib/Lib-jdk.sctp.gmk index 2676102021e..58fbff4a135 100644 --- a/make/lib/Lib-jdk.sctp.gmk +++ b/make/lib/Lib-jdk.sctp.gmk @@ -27,9 +27,9 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) - ifeq ($(filter $(OPENJDK_TARGET_OS), macosx aix), ) + ifeq ($(call isTargetOs, macosx aix), false) $(eval $(call SetupJdkLibrary, BUILD_LIBSCTP, \ NAME := sctp, \ OPTIMIZATION := LOW, \ diff --git a/make/test/BuildFailureHandler.gmk b/make/test/BuildFailureHandler.gmk index 0dca6f3663d..8433a5cc866 100644 --- a/make/test/BuildFailureHandler.gmk +++ b/make/test/BuildFailureHandler.gmk @@ -61,7 +61,7 @@ TARGETS += $(BUILD_FAILURE_HANDLER) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupNativeCompilation, BUILD_LIBTIMEOUT_HANDLER, \ NAME := timeoutHandler, \ @@ -99,7 +99,7 @@ IMAGES_TARGETS += $(COPY_FH) # RUN_DIR := $(FH_SUPPORT)/test # Add the dir of the dll to the path on windows -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) export PATH := $(PATH);$(FH_SUPPORT) endif diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 016be08ac90..faa09baca13 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -140,7 +140,7 @@ NSK_AOD_INCLUDES := \ -I$(VM_TESTBASE_DIR)/nsk/share/jni NO_FRAMEPOINTER_CFLAGS := -ifeq ($(OPENJDK_TARGET_OS),linux) +ifeq ($(call isTargetOs, linux), true) NO_FRAMEPOINTER_CFLAGS := -fomit-frame-pointer endif @@ -849,11 +849,11 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libVirtualMachine09agent00 := $(NSK_AOD_INC ################################################################################ # Platform specific setup -ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), false) BUILD_HOTSPOT_JTREG_EXCLUDE += liboverflow.c exeThreadSignalMask.c endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rw := -z noexecstack BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rwx := -z execstack BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libstepBreakPopReturn := -lpthread @@ -870,11 +870,11 @@ endif BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exesigtest := -ljvm -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) BUILD_HOTSPOT_JTREG_EXCLUDE += libterminatedThread.c endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit := jvm.lib diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 07456060918..bb544026f00 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -55,7 +55,7 @@ BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeJliLaunchTest := \ -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" # Platform specific setup -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib @@ -65,9 +65,9 @@ ifeq ($(OPENJDK_TARGET_OS), windows) else BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava - else ifeq ($(OPENJDK_TARGET_OS), solaris) + else ifeq ($(call isTargetOs, solaris), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava endif UNIX_LDFLAGS_JLI := -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli @@ -75,7 +75,7 @@ else BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJliLaunchTest := -ljli endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := \ -framework Cocoa BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestDynamicStore := \ diff --git a/test/make/TestMakeBase.gmk b/test/make/TestMakeBase.gmk index 4392d84c3d7..ccd0a89cd11 100644 --- a/test/make/TestMakeBase.gmk +++ b/test/make/TestMakeBase.gmk @@ -102,6 +102,28 @@ ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), ) $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal) endif +################################################################################ +# Test boolean operators + +$(eval $(call assert-equals, $(call And, true true true ), true)) +$(eval $(call assert-equals, $(call And, true false true ), false)) +$(eval $(call assert-equals, $(call And, false false false ), false)) +$(eval $(call assert-equals, $(call And, true), true)) +$(eval $(call assert-equals, $(call And, false), false)) +$(eval $(call assert-equals, $(call And, ), true)) + +$(eval $(call assert-equals, $(call Or, true true true ), true)) +$(eval $(call assert-equals, $(call Or, true false true ), true)) +$(eval $(call assert-equals, $(call Or, false false false ), false)) +$(eval $(call assert-equals, $(call Or, true), true)) +$(eval $(call assert-equals, $(call Or, false), false)) +$(eval $(call assert-equals, $(call Or, ), false)) + +# We cannot catch $(error) while testing, but you can enable this manually +# by uncommenting and watch make fails. +#$(eval $(call assert-equals, $(call And, non-boolean ), $(error ...))) +#$(eval $(call assert-equals, $(call Or, non-boolean ), $(error ...))) + ################################################################################ # Test remove-prefixes diff --git a/test/make/UtilsForTests.gmk b/test/make/UtilsForTests.gmk index 0c50cb8c3c0..180d6e380bd 100644 --- a/test/make/UtilsForTests.gmk +++ b/test/make/UtilsForTests.gmk @@ -42,6 +42,6 @@ CreateFile = $(shell $(MKDIR) -p $(call ShellQuote, $(dir $1)) \ # On macosx, file system timestamps only have 1 second resultion so must add # sleeps to properly test dependencies. -ifeq ($(OPENJDK_BUILD_OS), macosx) +ifeq ($(call isBuildOs, macosx), true) SLEEP_ON_MAC := sleep 1 endif From ebac392d65ab085369ae1b33cc7601d574778d0f Mon Sep 17 00:00:00 2001 From: Kimura Yukihiro Date: Mon, 6 Feb 2023 13:38:45 +0000 Subject: [PATCH 111/205] 8300742: jstat's CGCT is 5 percent higher than the pause time in -Xlog:gc. Reviewed-by: rrich --- src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp index c98691ea7a9..3dc29c7a57f 100644 --- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, 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 @@ -5535,17 +5535,18 @@ void CMSCollector::reset_stw() { void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) { GCTraceCPUTime tcpu; - TraceCollectorStats tcs_cgc(cgc_counters()); switch (op) { case CMS_op_checkpointRootsInitial: { GCTraceTime(Info, gc) t("Pause Initial Mark", NULL, GCCause::_no_gc, true); + TraceCollectorStats tcs_cgc(cgc_counters()); SvcGCMarker sgcm(SvcGCMarker::CONCURRENT); checkpointRootsInitial(); break; } case CMS_op_checkpointRootsFinal: { GCTraceTime(Info, gc) t("Pause Remark", NULL, GCCause::_no_gc, true); + TraceCollectorStats tcs_cgc(cgc_counters()); SvcGCMarker sgcm(SvcGCMarker::CONCURRENT); checkpointRootsFinal(); break; From 7e74421cbc768a27253037176fce11fa308bd483 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Feb 2023 16:01:26 +0000 Subject: [PATCH 112/205] 8286962: java/net/httpclient/ServerCloseTest.java failed once with ConnectException Backport-of: 13d4ddc35b1a64e2d882c7dcd554b5aee2720c53 --- .../java/net/httpclient/ServerCloseTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/test/jdk/java/net/httpclient/ServerCloseTest.java b/test/jdk/java/net/httpclient/ServerCloseTest.java index aa1ca9dcaad..5bb040de825 100644 --- a/test/jdk/java/net/httpclient/ServerCloseTest.java +++ b/test/jdk/java/net/httpclient/ServerCloseTest.java @@ -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 @@ -287,14 +287,12 @@ public void run() { try { while(!stopped) { Socket clientConnection = ss.accept(); - connections.add(clientConnection); System.out.println(now() + getName() + ": Client accepted"); StringBuilder headers = new StringBuilder(); - Socket targetConnection = null; InputStream ccis = clientConnection.getInputStream(); OutputStream ccos = clientConnection.getOutputStream(); Writer w = new OutputStreamWriter( - clientConnection.getOutputStream(), "UTF-8"); + clientConnection.getOutputStream(), UTF_8); PrintWriter pw = new PrintWriter(w); System.out.println(now() + getName() + ": Reading request line"); String requestLine = readLine(ccis); @@ -302,20 +300,32 @@ public void run() { StringTokenizer tokenizer = new StringTokenizer(requestLine); String method = tokenizer.nextToken(); - assert method.equalsIgnoreCase("POST") - || method.equalsIgnoreCase("GET"); + if (!method.equals("GET") && !method.equals("POST")) { + System.err.println(now() + getName() + ": Unexpected request method. Method: " + method); + clientConnection.close(); + continue; + } + String path = tokenizer.nextToken(); + if (!path.contains("/dummy/x")) { + System.err.println(now() + getName() + ": Unexpected request path. Path: " + path); + clientConnection.close(); + continue; + } + URI uri; try { String hostport = serverAuthority(); - uri = new URI((secure ? "https" : "http") +"://" + hostport + path); + uri = new URI((secure ? "https" : "http") + "://" + hostport + path); } catch (Throwable x) { - System.err.printf("Bad target address: \"%s\" in \"%s\"%n", + System.err.printf(now() + getName() + ": Bad target address: \"%s\" in \"%s\"%n", path, requestLine); clientConnection.close(); continue; } + // Method, path and URI are valid. Add to connections list + connections.add(clientConnection); // Read all headers until we find the empty line that // signals the end of all headers. String line = requestLine; From 65180f10d2cb28afb30295f5b2df73589cce7f8e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Feb 2023 16:04:08 +0000 Subject: [PATCH 113/205] 8290920: sspi_bridge.dll not built if BUILD_CRYPTO is false Reviewed-by: phh Backport-of: 5e1e449c116d44fb77a21ce4cd5187cfc55263f2 --- make/lib/Lib-java.security.jgss.gmk | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/make/lib/Lib-java.security.jgss.gmk b/make/lib/Lib-java.security.jgss.gmk index 642b3bcd415..ea96d2b585e 100644 --- a/make/lib/Lib-java.security.jgss.gmk +++ b/make/lib/Lib-java.security.jgss.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,19 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJ2GSS, \ TARGETS += $(BUILD_LIBJ2GSS) +ifeq ($(call isTargetOs, windows), true) + $(eval $(call SetupJdkLibrary, BUILD_LIBSSPI_BRIDGE, \ + NAME := sspi_bridge, \ + OPTIMIZATION := LOW, \ + CFLAGS := $(CFLAGS_JDKLIB) \ + -I$(TOPDIR)/src/java.security.jgss/share/native/libj2gss, \ + LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(call SET_SHARED_LIBRARY_ORIGIN) \ + )) + + TARGETS += $(BUILD_LIBSSPI_BRIDGE) +endif + ################################################################################ ifneq ($(BUILD_CRYPTO), false) @@ -55,17 +68,6 @@ ifneq ($(BUILD_CRYPTO), false) )) TARGETS += $(BUILD_LIBW2K_LSA_AUTH) - - $(eval $(call SetupJdkLibrary, BUILD_LIBSSPI_BRIDGE, \ - NAME := sspi_bridge, \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(TOPDIR)/src/java.security.jgss/share/native/libj2gss, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN) \ - )) - - TARGETS += $(BUILD_LIBSSPI_BRIDGE) endif ifeq ($(call isTargetOs, macosx), true) From 9d7bb60136a3d565b59ac861ba9fc433de88a8da Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Feb 2023 16:05:50 +0000 Subject: [PATCH 114/205] 8296912: C2: CreateExNode::Identity fails with assert(i < _max) failed: oob: i=1, _max=1 Reviewed-by: rrich Backport-of: 502fa3eeea849cfcc50436602be1654695ef4e26 --- src/hotspot/share/opto/cfgnode.cpp | 5 ++-- .../jtreg/compiler/c2/TestDeadDataLoop.java | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/opto/cfgnode.cpp b/src/hotspot/share/opto/cfgnode.cpp index 0a0c2dd697b..3b458da2ace 100644 --- a/src/hotspot/share/opto/cfgnode.cpp +++ b/src/hotspot/share/opto/cfgnode.cpp @@ -2439,9 +2439,8 @@ Node* CreateExNode::Identity(PhaseGVN* phase) { // exception oop through. CallNode *call = in(1)->in(0)->as_Call(); - return ( in(0)->is_CatchProj() && in(0)->in(0)->in(1) == in(1) ) - ? this - : call->in(TypeFunc::Parms); + return (in(0)->is_CatchProj() && in(0)->in(0)->is_Catch() && + in(0)->in(0)->in(1) == in(1)) ? this : call->in(TypeFunc::Parms); } //============================================================================= diff --git a/test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java b/test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java index fac1f389389..23bec1076e5 100644 --- a/test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java +++ b/test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java @@ -23,11 +23,11 @@ /* * @test - * @bug 8284358 + * @bug 8284358 8296912 * @summary An unreachable loop is not removed, leading to a broken graph. * @requires vm.compiler2.enabled * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions - * -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined + * -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined* * compiler.c2.TestDeadDataLoop */ @@ -210,10 +210,29 @@ static void test10() { } } + static long l; + + static void test11(boolean never) { + float f = 1; + boolean b; + for (int i = 0; i < 5; ++i) { + b = (never || l < 0); + l = notInlined2(); + if (!never) { + f += i; + } + } + l += f; + } + public static boolean notInlined() { return false; } + public static int notInlined2() { + return 42; + } + public static void main(String[] args) { // Make sure classes are initialized Integer i = 42; @@ -228,6 +247,7 @@ public static void main(String[] args) { test8(); test9(); test10(); + test11(false); } } From b88cd771f012f040ba1a000e3a4805a92852c1eb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Feb 2023 16:07:41 +0000 Subject: [PATCH 115/205] 8298073: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java causes test task timeout on macosx 8241293: CompressedClassSpaceSizeInJmapHeap.java time out after 8 minutes Reviewed-by: phh Backport-of: 99a6c47855ad82e81a80726cf3aa4522c547716d --- .../metaspace/CompressedClassSpaceSizeInJmapHeap.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java index b9e808601d6..53da8dbd2b5 100644 --- a/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java +++ b/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.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 @@ -32,11 +32,12 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m gc.metaspace.CompressedClassSpaceSizeInJmapHeap + * @run main/timeout=240 gc.metaspace.CompressedClassSpaceSizeInJmapHeap */ import jdk.test.lib.JDKToolLauncher; import jdk.test.lib.Platform; +import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.SA.SATestUtils; @@ -55,7 +56,9 @@ public static void main(String[] args) throws Exception { return; } - String pid = Long.toString(ProcessTools.getProcessId()); + LingeredApp theApp = new LingeredApp(); + LingeredApp.startApp(List.of("-XX:CompressedClassSpaceSize=50m"), theApp); + String pid = Long.toString(theApp.getPid()); JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb") .addToolArg("jmap") @@ -75,6 +78,8 @@ public static void main(String[] args) throws Exception { OutputAnalyzer output = new OutputAnalyzer(read(out)); output.shouldContain("CompressedClassSpaceSize = 52428800 (50.0MB)"); out.delete(); + + LingeredApp.stopApp(theApp); } private static void run(ProcessBuilder pb) throws Exception { From faabe54e714f65ddb461ce4d78d15b9802f68867 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Fri, 10 Feb 2023 07:54:26 +0000 Subject: [PATCH 116/205] 8301760: Fix possible leak in SpNegoContext dispose Backport-of: 3f3356bcbd2b2fbc545263dc70a48ee931a4e56b --- .../classes/sun/security/jgss/spnego/SpNegoContext.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoContext.java b/src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoContext.java index 143fbe137fd..f06fdb6fe5c 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoContext.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoContext.java @@ -242,8 +242,11 @@ public final Provider getProvider() { } public final void dispose() throws GSSException { - mechContext = null; state = STATE_DELETED; + if (mechContext != null) { + mechContext.dispose(); + mechContext = null; + } } /** From 08f86131bd3cec34e7e50097dd80e3116b052ed1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 10 Feb 2023 08:43:49 +0000 Subject: [PATCH 117/205] 8296675: Exclude linux-aarch64 in NSS tests Backport-of: fa8a8668a6656046d713a6b09244adfc81556d63 --- test/jdk/sun/security/pkcs11/PKCS11Test.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java index 7ae0b684017..5d4ee095f79 100644 --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, 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 @@ -739,10 +739,12 @@ private static Map getOsMap() { osMap.put("Linux-arm-32", new String[] { "/usr/lib/arm-linux-gnueabi/nss/", "/usr/lib/arm-linux-gnueabihf/nss/" }); - osMap.put("Linux-aarch64-64", new String[] { - "/usr/lib/aarch64-linux-gnu/", - "/usr/lib/aarch64-linux-gnu/nss/", - "/usr/lib64/" }); + // 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[] { +// "/usr/lib/aarch64-linux-gnu/", +// "/usr/lib/aarch64-linux-gnu/nss/", +// "/usr/lib64/" }); return osMap; } From 0c42ee469051efe7efe1242e672cdc27114bd4da Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sun, 12 Feb 2023 19:08:16 +0000 Subject: [PATCH 118/205] 8295774: Write a test to verify List sends ItemEvent/ActionEvent Backport-of: 2a79dfc1f9c419e92aac99f92ef4e40a3471695b --- .../ComponentEvent/ListItemEventsTest.java | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 test/jdk/java/awt/event/ComponentEvent/ListItemEventsTest.java diff --git a/test/jdk/java/awt/event/ComponentEvent/ListItemEventsTest.java b/test/jdk/java/awt/event/ComponentEvent/ListItemEventsTest.java new file mode 100644 index 00000000000..47e3a12a229 --- /dev/null +++ b/test/jdk/java/awt/event/ComponentEvent/ListItemEventsTest.java @@ -0,0 +1,175 @@ +/* + * 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.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; + +/* + * @test + * @key headful + * @bug 8295774 + * @summary Verify that List Item selection via mouse/keys generates ItemEvent/ActionEvent appropriately. + * @run main ListItemEventsTest + */ +public class ListItemEventsTest { + + private static final int MOUSE_DELAY = 100; + private static final int KEYBOARD_DELAY = 1000; + + private static Frame frame; + private volatile static List list; + private volatile static boolean actionPerformed = false; + private volatile static boolean itemStateChanged = false; + private static Robot robot; + + public static void initializeGUI() { + frame = new Frame("Test Frame"); + frame.setLayout(new FlowLayout()); + list = new List(); + list.add("One"); + list.add("Two"); + list.add("Three"); + list.add("Four"); + list.add("Five"); + list.addItemListener((event) -> { + System.out.println("Got an ItemEvent: " + event); + itemStateChanged = true; + }); + list.addActionListener((event) -> { + System.out.println("Got an ActionEvent: " + event); + actionPerformed = true; + }); + + frame.add(list); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] s) throws Exception { + robot = new Robot(); + try { + robot.setAutoDelay(MOUSE_DELAY); + robot.setAutoWaitForIdle(true); + + EventQueue.invokeLater(ListItemEventsTest::initializeGUI); + robot.waitForIdle(); + + Point listAt = list.getLocationOnScreen(); + Dimension listSize = list.getSize(); + robot.mouseMove(listAt.x + listSize.width / 2, + listAt.y + listSize.height / 2); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (!itemStateChanged) { + throw new RuntimeException( + "FAIL: List did not trigger ItemEvent when item selected!"); + } + + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + + if (!actionPerformed) { + throw new RuntimeException( + "FAIL: List did not trigger ActionEvent when double" + + " clicked!"); + } + + itemStateChanged = false; + actionPerformed = false; + + EventQueue.invokeAndWait(() -> list.select(0)); + robot.waitForIdle(); + + if (itemStateChanged) { + throw new RuntimeException( + "FAIL: List triggered ItemEvent when item selected by " + + "calling the API!"); + } + + robot.setAutoDelay(KEYBOARD_DELAY); + + itemStateChanged = false; + typeKey(KeyEvent.VK_DOWN); + + if (!itemStateChanged) { + throw new RuntimeException( + "FAIL: List did not trigger ItemEvent when item selected by" + + " down arrow key!"); + } + + itemStateChanged = false; + typeKey(KeyEvent.VK_UP); + + if (!itemStateChanged) { + throw new RuntimeException( + "FAIL: List did not trigger ItemEvent when item selected by" + + " up arrow key!"); + } + + if (actionPerformed) { + throw new RuntimeException( + "FAIL: List triggerd ActionEvent unnecessarily. Action generated" + + " when item selected using API or UP/DOWN keys!"); + } + + actionPerformed = false; + typeKey(KeyEvent.VK_ENTER); + + if (!actionPerformed) { + throw new RuntimeException( + "FAIL: List did not trigger ActionEvent when enter" + + " key typed!"); + } + + System.out.println("Test passed!"); + + } finally { + EventQueue.invokeAndWait(ListItemEventsTest::disposeFrame); + } + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + frame = null; + } + } + + private static void typeKey(int key) throws Exception { + robot.keyPress(key); + robot.keyRelease(key); + } +} From 816e53bad5771d29db941bba830476a5a16cbc1f Mon Sep 17 00:00:00 2001 From: Ekaterina Vergizova Date: Mon, 13 Feb 2023 11:48:06 +0000 Subject: [PATCH 119/205] 8298129: Let checkpoint event sizes grow beyond u4 limit Reviewed-by: phh Backport-of: ea108f504ccb63fc9651e804e3bbba1c108dcead --- .../checkpoint/jfrCheckpointManager.cpp | 70 +++++++++++-------- src/hotspot/share/jfr/writers/jfrEncoders.hpp | 49 ++++++++++++- src/hotspot/share/jfr/writers/jfrEncoding.hpp | 5 ++ .../share/jfr/writers/jfrWriterHost.hpp | 2 + .../jfr/writers/jfrWriterHost.inline.hpp | 6 ++ .../classes/jdk/jfr/consumer/ChunkParser.java | 4 +- 6 files changed, 102 insertions(+), 34 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp index ddce119b8c2..e390dd4783f 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp @@ -214,64 +214,72 @@ BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t request } // offsets into the JfrCheckpointEntry -static const juint starttime_offset = sizeof(jlong); -static const juint duration_offset = starttime_offset + sizeof(jlong); -static const juint flushpoint_offset = duration_offset + sizeof(jlong); -static const juint types_offset = flushpoint_offset + sizeof(juint); -static const juint payload_offset = types_offset + sizeof(juint); +static const size_t starttime_offset = sizeof(int64_t); +static const size_t duration_offset = starttime_offset + sizeof(int64_t); +static const size_t flushpoint_offset = duration_offset + sizeof(int64_t); +static const size_t types_offset = flushpoint_offset + sizeof(uint32_t); +static const size_t payload_offset = types_offset + sizeof(uint32_t); template static Return read_data(const u1* data) { return JfrBigEndian::read(data); } -static jlong total_size(const u1* data) { - return read_data(data); +static size_t total_size(const u1* data) { + const int64_t size = read_data(data); + assert(size > 0, "invariant"); + return static_cast(size); } -static jlong starttime(const u1* data) { - return read_data(data + starttime_offset); +static int64_t starttime(const u1* data) { + return read_data(data + starttime_offset); } -static jlong duration(const u1* data) { - return read_data(data + duration_offset); +static int64_t duration(const u1* data) { + return read_data(data + duration_offset); } static bool is_flushpoint(const u1* data) { - return read_data(data + flushpoint_offset) == (juint)1; + return read_data(data + flushpoint_offset) == (uint32_t)1; } -static juint number_of_types(const u1* data) { - return read_data(data + types_offset); +static uint32_t number_of_types(const u1* data) { + return read_data(data + types_offset); } -static void write_checkpoint_header(JfrChunkWriter& cw, int64_t offset_prev_cp_event, const u1* data) { - cw.reserve(sizeof(u4)); - cw.write(EVENT_CHECKPOINT); - cw.write(starttime(data)); - cw.write(duration(data)); - cw.write(offset_prev_cp_event); - cw.write(is_flushpoint(data)); - cw.write(number_of_types(data)); +static size_t payload_size(const u1* data) { + return total_size(data) - sizeof(JfrCheckpointEntry); } -static void write_checkpoint_content(JfrChunkWriter& cw, const u1* data, size_t size) { +static uint64_t calculate_event_size_bytes(JfrChunkWriter& cw, const u1* data, int64_t event_begin, int64_t delta_to_last_checkpoint) { assert(data != NULL, "invariant"); - cw.write_unbuffered(data + payload_offset, size - sizeof(JfrCheckpointEntry)); + size_t bytes = cw.size_in_bytes(EVENT_CHECKPOINT); + bytes += cw.size_in_bytes(starttime(data)); + bytes += cw.size_in_bytes(duration(data)); + bytes += cw.size_in_bytes(delta_to_last_checkpoint); + bytes += cw.size_in_bytes(is_flushpoint(data)); + bytes += cw.size_in_bytes(number_of_types(data)); + bytes += payload_size(data); // in bytes already. + return bytes + cw.size_in_bytes(bytes + cw.size_in_bytes(bytes)); } static size_t write_checkpoint_event(JfrChunkWriter& cw, const u1* data) { assert(data != NULL, "invariant"); const int64_t event_begin = cw.current_offset(); const int64_t last_checkpoint_event = cw.last_checkpoint_offset(); - const int64_t delta = last_checkpoint_event == 0 ? 0 : last_checkpoint_event - event_begin; - const int64_t checkpoint_size = total_size(data); - write_checkpoint_header(cw, delta, data); - write_checkpoint_content(cw, data, checkpoint_size); - const int64_t event_size = cw.current_offset() - event_begin; - cw.write_padded_at_offset(event_size, event_begin); cw.set_last_checkpoint_offset(event_begin); - return (size_t)checkpoint_size; + const int64_t delta_to_last_checkpoint = last_checkpoint_event == 0 ? 0 : last_checkpoint_event - event_begin; + const uint64_t event_size = calculate_event_size_bytes(cw, data, event_begin, delta_to_last_checkpoint); + cw.write(event_size); + cw.write(EVENT_CHECKPOINT); + cw.write(starttime(data)); + cw.write(duration(data)); + cw.write(delta_to_last_checkpoint); + cw.write(is_flushpoint(data)); + cw.write(number_of_types(data)); + cw.write_unbuffered(data + payload_offset, payload_size(data)); + assert(static_cast(cw.current_offset() - event_begin) == event_size, "invariant"); + return total_size(data); } static size_t write_checkpoints(JfrChunkWriter& cw, const u1* data, size_t size) { diff --git a/src/hotspot/share/jfr/writers/jfrEncoders.hpp b/src/hotspot/share/jfr/writers/jfrEncoders.hpp index 0fe08840b35..f0e1a2b0587 100644 --- a/src/hotspot/share/jfr/writers/jfrEncoders.hpp +++ b/src/hotspot/share/jfr/writers/jfrEncoders.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, 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 @@ -63,6 +63,9 @@ class BigEndianEncoderImpl { template static size_t encode_padded(const T* src, size_t len, u1* dest); + template + static size_t size_in_bytes(T value); + }; template @@ -129,6 +132,17 @@ inline size_t BigEndianEncoderImpl::encode_padded(const T* src, size_t len, u1* return size; } +template +inline size_t BigEndianEncoderImpl::size_in_bytes(T value) { + switch (sizeof(T)) { + case 1: return 1; + case 2: return 2; + case 4: return 4; + case 8:return 8; + } + ShouldNotReachHere(); + return 0; +} // The Varint128 encoder implements encoding according to // msb(it) 128bit encoding (1 encode bit | 7 value bits), @@ -160,6 +174,9 @@ class Varint128EncoderImpl { template static size_t encode_padded(const T* src, size_t len, u1* dest); + template + static size_t size_in_bytes(T value); + }; template @@ -295,4 +312,34 @@ inline size_t Varint128EncoderImpl::encode_padded(const T* src, size_t len, u1* return size; } +template +inline size_t Varint128EncoderImpl::size_in_bytes(T value) { + const u8 v = to_u8(value); + if (LESS_THAN_128(v)) { + return 1; + } + if (LESS_THAN_128(v >> 7)) { + return 2; + } + if (LESS_THAN_128(v >> 14)) { + return 3; + } + if (LESS_THAN_128(v >> 21)) { + return 4; + } + if (LESS_THAN_128(v >> 28)) { + return 5; + } + if (LESS_THAN_128(v >> 35)) { + return 6; + } + if (LESS_THAN_128(v >> 42)) { + return 7; + } + if (LESS_THAN_128(v >> 49)) { + return 8; + } + return 9; +} + #endif // SHARE_VM_JFR_WRITERS_JFRENCODERS_HPP diff --git a/src/hotspot/share/jfr/writers/jfrEncoding.hpp b/src/hotspot/share/jfr/writers/jfrEncoding.hpp index 37f0b8d4adc..0d24b928a70 100644 --- a/src/hotspot/share/jfr/writers/jfrEncoding.hpp +++ b/src/hotspot/share/jfr/writers/jfrEncoding.hpp @@ -69,6 +69,11 @@ class EncoderHost : public AllStatic { return pos + IntegerEncoder::encode_padded(value, len, pos); } + template + static size_t size_in_bytes(T value) { + return IntegerEncoder::size_in_bytes(value); + } + template static u1* write(T value, u1* pos) { return write(&value, 1, pos); diff --git a/src/hotspot/share/jfr/writers/jfrWriterHost.hpp b/src/hotspot/share/jfr/writers/jfrWriterHost.hpp index b54b751f75e..85b06f2b861 100644 --- a/src/hotspot/share/jfr/writers/jfrWriterHost.hpp +++ b/src/hotspot/share/jfr/writers/jfrWriterHost.hpp @@ -97,6 +97,8 @@ class WriterHost : public WriterPolicyImpl { template void write_be_at_offset(T value, int64_t offset); int64_t reserve(size_t size); + template + size_t size_in_bytes(T value); }; #endif // SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP diff --git a/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp b/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp index 6f34aaae764..29a0457f71f 100644 --- a/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp +++ b/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp @@ -361,5 +361,11 @@ inline void WriterHost::write_be_at_offset(T value, in } } +template +template +inline size_t WriterHost::size_in_bytes(T value) { + return IE::size_in_bytes(value); +} + #endif // SHARE_VM_JFR_WRITERS_JFRWRITERHOST_INLINE_HPP diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java index ee6e00d6ecd..c38c83e6de9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java @@ -79,7 +79,7 @@ private ChunkParser(ChunkHeader header) throws IOException { public RecordedEvent readEvent() throws IOException { while (input.position() < absoluteChunkEnd) { long pos = input.position(); - int size = input.readInt(); + long size = input.readLong(); if (size == 0) { throw new IOException("Event can't have zero size"); } @@ -102,7 +102,7 @@ private void fillConstantPools(LongMap typeParser, LongMap nextCP += deltaToNext; input.position(nextCP); final long position = nextCP; - int size = input.readInt(); // size + long size = input.readLong(); // size long typeId = input.readLong(); if (typeId != CONSTANT_POOL_TYPE_ID) { throw new IOException("Expected check point event (id = 1) at position " + nextCP + ", but found type id = " + typeId); From 2c47c45f0747e86a3b97384bea48107627ffd040 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 13 Feb 2023 14:19:17 +0000 Subject: [PATCH 120/205] 8273497: building.md should link to both md and html Backport-of: a10bb08a4c187c6c0b21cafb25877895d885427e --- doc/building.html | 4 ++-- doc/building.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/building.html b/doc/building.html index 79596224748..a117465c340 100644 --- a/doc/building.html +++ b/doc/building.html @@ -562,7 +562,7 @@

General Make Control Variables

  • CONF and CONF_NAME - Selecting the configuration(s) to use. See Using Multiple Configurations
  • Test Make Control Variables

    -

    These make control variables only make sense when running tests. Please see Testing the JDK for details.

    +

    These make control variables only make sense when running tests. Please see Testing the JDK (html, markdown) for details.

    • TEST
    • TEST_JOBS
    • @@ -582,7 +582,7 @@

      Running Tests

      The Adoption Group provides recent builds of jtreg here. Download the latest .tar.gz file, unpack it, and point --with-jtreg to the jtreg directory that you just unpacked.

      To execute the most basic tests (tier 1), use:

      make run-test-tier1
      -

      For more details on how to run tests, please see the Testing the JDK document.

      +

      For more details on how to run tests, please see Testing the JDK (html, markdown).

      Cross-compiling

      Cross-compiling means using one platform (the build platform) to generate output that can ran on another platform (the target platform).

      The typical reason for cross-compiling is that the build is performed on a more powerful desktop computer, but the resulting binaries will be able to run on a different, typically low-performing system. Most of the complications that arise when building for embedded is due to this separation of build and target systems.

      diff --git a/doc/building.md b/doc/building.md index dc17138ac74..24c09bd04e3 100644 --- a/doc/building.md +++ b/doc/building.md @@ -835,7 +835,7 @@ configuration, as opposed to the "configure time" configuration. #### Test Make Control Variables These make control variables only make sense when running tests. Please see -[Testing the JDK](testing.html) for details. +**Testing the JDK** ([html](testing.html), [markdown](testing.md)) for details. * `TEST` * `TEST_JOBS` @@ -873,8 +873,8 @@ To execute the most basic tests (tier 1), use: make run-test-tier1 ``` -For more details on how to run tests, please see the [Testing -the JDK](testing.html) document. +For more details on how to run tests, please see **Testing the JDK** +([html](testing.html), [markdown](testing.md)). ## Cross-compiling From d0984dfce494de41f2bb5abdcaa8c05d7a0f1f42 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 13 Feb 2023 14:37:20 +0000 Subject: [PATCH 121/205] 8223716: sun/net/www/http/HttpClient/MultiThreadTest.java should be more resilient to unexpected traffic Backport-of: e0a87ef8fcf35df77c3a4578723611cab32db07d --- .../www/http/HttpClient/MultiThreadTest.java | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java b/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java index 2546698264f..c4b80809258 100644 --- a/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java +++ b/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java @@ -42,6 +42,7 @@ import java.time.Duration; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicInteger; public class MultiThreadTest extends Thread { @@ -60,13 +61,11 @@ static void debug(String msg) { System.out.println(msg); } - static int reqnum = 0; + static final AtomicInteger reqnum = new AtomicInteger(); void doRequest(String uri) throws Exception { - URL url = new URL(uri + "?foo="+reqnum); - reqnum ++; + URL url = new URL(uri + "?foo="+reqnum.getAndIncrement()); HttpURLConnection http = (HttpURLConnection)url.openConnection(); - InputStream in = http.getInputStream(); byte b[] = new byte[100]; int total = 0; @@ -157,12 +156,37 @@ public static void main(String args[]) throws Exception { int reqs = Worker.getRequests (); MultiThreadTest.debug("Requests = " + reqs); System.out.println ("Connection count = " + cnt + " Request count = " + reqs); - if (cnt > threads) { // could be less - throw new RuntimeException ("Expected "+threads + " connections: used " +cnt); + + // We may have received traffic from something else than + // our client. We should only count those workers for which + // the expected header has been found. + int validConnections = 0; + for (Worker w : svr.workers()) { + if (w.headerFound) validConnections++; + } + + if (validConnections > threads + 1 || validConnections == 0) { // could be less + throw new RuntimeException ("Expected " + threads + " connections: used " + validConnections); } - if (reqs != threads*requests) { + + // Sometimes the client drops a connection after a while and + // spawns a new one. Why this is happening is not clear, + // and JDK-8223783 is logged to follow up on this. For the sake + // of test stabilization we don't fail on `threads + 1` connections + // but log a warning instead. + if (validConnections == threads + 1) { + debug("WARNING: " + validConnections + + " have been used, where only " + threads + + " were expected!"); + } + + if (validConnections != cnt) { + debug("WARNING: got " + (cnt - validConnections) + " unexpected connections!"); + } + if (validConnections == cnt && reqs != threads*requests) { throw new RuntimeException ("Expected "+ threads*requests+ " requests: got " +reqs); } + for (Thread worker : svr.workers()) { worker.join(60_000); } @@ -179,7 +203,7 @@ class Server extends Thread { ServerSocket ss; int connectionCount; boolean shutdown = false; - private Queue workers = new ConcurrentLinkedQueue<>(); + private final Queue workers = new ConcurrentLinkedQueue<>(); Server(ServerSocket ss) { this.ss = ss; @@ -246,8 +270,10 @@ public void run() { class Worker extends Thread { Socket s; int id; + volatile boolean headerFound; Worker(Socket s, int id) { + super("Worker-" + id); this.s = s; this.id = id; } @@ -260,18 +286,20 @@ public static int getRequests () { return requests; } } + public static void incRequests () { synchronized (rlock) { requests++; } } - int readUntil(InputStream in, char[] seq) throws IOException { + int readUntil(InputStream in, StringBuilder headers, char[] seq) throws IOException { int i=0, count=0; while (true) { int c = in.read(); if (c == -1) return -1; + headers.append((char)c); count++; if (c == seq[i]) { i++; @@ -300,14 +328,18 @@ public void run() { // read entire request from client int n=0; - - n = readUntil(in, new char[] {'\r','\n', '\r','\n'}); - + StringBuilder headers = new StringBuilder(); + n = readUntil(in, headers, new char[] {'\r','\n', '\r','\n'}); if (n <= 0) { MultiThreadTest.debug("worker: " + id + ": Shutdown"); s.close(); return; } + if (headers.toString().contains("/foo.html?foo=")) { + headerFound = true; + } else { + MultiThreadTest.debug("worker: " + id + ": Unexpected request received: " + headers); + } MultiThreadTest.debug("worker " + id + ": Read request from client " + From 43a0015f22b61d001e05915a623067f1f8db20cb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 13 Feb 2023 14:39:11 +0000 Subject: [PATCH 122/205] 8297489: Modify TextAreaTextEventTest.java as to verify the content change of TextComponent sends TextEvent Backport-of: 7d20a60a983e459ea1c4e843fbde70fb796c6249 --- .../ComponentEvent/TextAreaTextEventTest.java | 141 --------------- .../TextComponentTextEventTest.java | 161 ++++++++++++++++++ 2 files changed, 161 insertions(+), 141 deletions(-) delete mode 100644 test/jdk/java/awt/event/ComponentEvent/TextAreaTextEventTest.java create mode 100644 test/jdk/java/awt/event/ComponentEvent/TextComponentTextEventTest.java diff --git a/test/jdk/java/awt/event/ComponentEvent/TextAreaTextEventTest.java b/test/jdk/java/awt/event/ComponentEvent/TextAreaTextEventTest.java deleted file mode 100644 index 1825244d0b0..00000000000 --- a/test/jdk/java/awt/event/ComponentEvent/TextAreaTextEventTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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 - * 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.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.InputEvent; -import java.awt.event.KeyEvent; - -/* - * @test - * @key headful - * @bug 8296632 - * @summary Verify the content changes of a TextArea via TextListener. - * @run main TextAreaTextEventTest - */ -public class TextAreaTextEventTest { - - private static Frame frame; - private volatile static TextArea textArea; - private volatile static boolean textChanged = false; - private volatile static Point textAreaAt; - private volatile static Dimension textAreaSize; - private static Robot robot = null; - - public static void main(String[] args) throws Exception { - try { - EventQueue.invokeAndWait(TextAreaTextEventTest::initializeGUI); - - robot = new Robot(); - robot.setAutoDelay(100); - - robot.waitForIdle(); - EventQueue.invokeAndWait(() -> { - textAreaAt = textArea.getLocationOnScreen(); - textAreaSize = textArea.getSize(); - }); - robot.mouseMove(textAreaAt.x + textAreaSize.width / 2, - textAreaAt.y + textAreaSize.height / 2); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - typeKey(KeyEvent.VK_T); - - robot.waitForIdle(); - if (!textChanged) { - throw new RuntimeException( - "FAIL: TextEvent not triggered when key 'T' typed on TextArea"); - } - - typeKey(KeyEvent.VK_E); - typeKey(KeyEvent.VK_S); - typeKey(KeyEvent.VK_T); - - textChanged = false; - typeKey(KeyEvent.VK_ENTER); - - robot.waitForIdle(); - if (!textChanged) { - throw new RuntimeException( - "FAIL: TextEvent not triggered when Enter pressed on TextArea"); - } - - textChanged = false; - robot.mouseMove(textAreaAt.x + 4, textAreaAt.y + 10); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - for (int i = 0; i < textAreaSize.width / 2; i++) { - robot.mouseMove(textAreaAt.x + 4 + i, textAreaAt.y + 10); - } - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - - robot.waitForIdle(); - if (textChanged) { - throw new RuntimeException( - "FAIL: TextEvent triggered when text is selected on TextArea!"); - } - - textChanged = false; - typeKey(KeyEvent.VK_F3); - - robot.waitForIdle(); - if (textChanged) { - throw new RuntimeException( - "FAIL: TextEvent triggered when special key F3 is pressed on TextArea!"); - } - System.out.println("Test passed!"); - } finally { - EventQueue.invokeAndWait(TextAreaTextEventTest::disposeFrame); - } - } - - private static void initializeGUI() { - frame = new Frame("Test Frame"); - frame.setLayout(new FlowLayout()); - textArea = new TextArea(5, 15); - textArea.addTextListener((event) -> { - System.out.println("Got a text event: " + event); - textChanged = true; - }); - frame.add(textArea); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - } - - public static void disposeFrame() { - if (frame != null) { - frame.dispose(); - } - } - - private static void typeKey(int key) throws Exception { - robot.keyPress(key); - robot.keyRelease(key); - } -} diff --git a/test/jdk/java/awt/event/ComponentEvent/TextComponentTextEventTest.java b/test/jdk/java/awt/event/ComponentEvent/TextComponentTextEventTest.java new file mode 100644 index 00000000000..8ffd151fde2 --- /dev/null +++ b/test/jdk/java/awt/event/ComponentEvent/TextComponentTextEventTest.java @@ -0,0 +1,161 @@ +/* + * 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 + * 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.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.TextComponent; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +/* + * @test + * @key headful + * @bug 8297489 8296632 + * @summary Verify the content changes of a TextComponent via TextListener. + * @run main TextComponentTextEventTest + */ +public class TextComponentTextEventTest { + + private static Frame frame; + private static Robot robot = null; + private volatile static TextComponent[] components; + private volatile static boolean textChanged = false; + private volatile static Point textCompAt; + private volatile static Dimension textCompSize; + + private static void initializeGUI() { + TextField textField = new TextField(20); + textField.addTextListener((event) -> { + textChanged = true; + System.out.println("TextField got a text event: " + event); + }); + + TextArea textArea = new TextArea(5, 15); + textArea.addTextListener((event) -> { + System.out.println("TextArea got a text event: " + event); + textChanged = true; + }); + + components = new TextComponent[] { textField, textArea }; + + frame = new Frame("Test Frame"); + frame.setLayout(new FlowLayout()); + for (TextComponent textComp : components) { + frame.add(textComp); + } + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(TextComponentTextEventTest::initializeGUI); + robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + + for (TextComponent textComp : components) { + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> { + textCompAt = textComp.getLocationOnScreen(); + textCompSize = textComp.getSize(); + }); + + robot.mouseMove(textCompAt.x + textCompSize.width / 2, + textCompAt.y + textCompSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + typeKey(KeyEvent.VK_T); + + robot.waitForIdle(); + if (!textChanged) { + throw new RuntimeException( + "FAIL: TextEvent not triggered when text entered in " + textComp); + } + + typeKey(KeyEvent.VK_E); + typeKey(KeyEvent.VK_S); + typeKey(KeyEvent.VK_T); + + textChanged = false; + typeKey(KeyEvent.VK_ENTER); + + robot.waitForIdle(); + if (textComp instanceof TextField && textChanged) { + throw new RuntimeException( + "FAIL: TextEvent triggered when Enter pressed on " + textComp); + } else if (textComp instanceof TextArea && !textChanged) { + throw new RuntimeException( + "FAIL: TextEvent not triggered when Enter pressed on " + textComp); + } + + textChanged = false; + robot.mouseMove(textCompAt.x + 4, textCompAt.y + 10); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int i = 0; i < textCompSize.width / 2; i++) { + robot.mouseMove(textCompAt.x + 4 + i, textCompAt.y + 10); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (textChanged) { + throw new RuntimeException( + "FAIL: TextEvent triggered when selection made in " + textComp); + } + + textChanged = false; + typeKey(KeyEvent.VK_F3); + + robot.waitForIdle(); + if (textChanged) { + throw new RuntimeException( + "FAIL: TextEvent triggered when F3 pressed on " + textComp); + } + } + System.out.println("Test passed!"); + } finally { + EventQueue.invokeAndWait(TextComponentTextEventTest::disposeFrame); + } + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + } + + private static void typeKey(int key) { + robot.keyPress(key); + robot.keyRelease(key); + } +} From c58a06666d93d7c339f9ce3133555083f30ca0e5 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 09:33:43 +0000 Subject: [PATCH 123/205] 8286030: Avoid JVM crash when containers share the same /tmp dir Reviewed-by: phh Backport-of: d52e18c92d307f5f6e9e649d410a54bef3a910da --- src/hotspot/os/aix/perfMemory_aix.cpp | 103 +++++------ src/hotspot/os/bsd/perfMemory_bsd.cpp | 105 ++++++----- src/hotspot/os/linux/perfMemory_linux.cpp | 167 ++++++++++++------ .../jtreg/containers/docker/ShareTmpDir.java | 132 ++++++++++++++ .../containers/docker/WaitForFlagFile.java | 43 +++++ 5 files changed, 387 insertions(+), 163 deletions(-) create mode 100644 test/hotspot/jtreg/containers/docker/ShareTmpDir.java create mode 100644 test/hotspot/jtreg/containers/docker/WaitForFlagFile.java diff --git a/src/hotspot/os/aix/perfMemory_aix.cpp b/src/hotspot/os/aix/perfMemory_aix.cpp index a5a2135ad46..7c2ceba1c69 100644 --- a/src/hotspot/os/aix/perfMemory_aix.cpp +++ b/src/hotspot/os/aix/perfMemory_aix.cpp @@ -74,18 +74,6 @@ static char* create_standard_memory(size_t size) { return mapAddress; } -// delete the PerfData memory region -// -static void delete_standard_memory(char* addr, size_t size) { - - // there are no persistent external resources to cleanup for standard - // memory. since DestroyJavaVM does not support unloading of the JVM, - // cleanup of the memory resource is not performed. The memory will be - // reclaimed by the OS upon termination of the process. - // - return; -} - // save the specified memory region to the given file // // Note: this function might be called from signal handler (by os::abort()), @@ -749,15 +737,15 @@ static void remove_file(const char* path) { } } -// Cleanup stale shared memory resources +// Cleanup stale shared memory files // // This method attempts to remove all stale shared memory files in // the named user temporary directory. It scans the named directory -// for files matching the pattern ^$[0-9]*$. For each file found, the -// process id is extracted from the file name and a test is run to -// determine if the process is alive. If the process is not alive, -// any stale file resources are removed. -static void cleanup_sharedmem_resources(const char* dirname) { +// for files matching the pattern ^$[0-9]*$. +// +// This directory should be used only by JVM processes owned by the +// current user to store PerfMemory files. Any other files found +static void cleanup_sharedmem_files(const char* dirname) { int saved_cwd_fd; // Open the directory. @@ -768,47 +756,54 @@ static void cleanup_sharedmem_resources(const char* dirname) { } // For each entry in the directory that matches the expected file - // name pattern, determine if the file resources are stale and if - // so, remove the file resources. Note, instrumented HotSpot processes - // for this user may start and/or terminate during this search and - // remove or create new files in this directory. The behavior of this - // loop under these conditions is dependent upon the implementation of - // opendir/readdir. + // name pattern, remove the file if it's determine to be stale + // Note, instrumented HotSpot processes for this user may start and/or + // terminate during this search and remove or create new files in this + // directory. The behavior of this loop under these conditions is dependent + // upon the implementation of opendir/readdir. struct dirent* entry; errno = 0; while ((entry = os::readdir(dirp)) != NULL) { - pid_t pid = filename_to_pid(entry->d_name); + const char* filename = entry->d_name; + pid_t pid = filename_to_pid(filename); if (pid == 0) { - if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { + if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) { // Attempt to remove all unexpected files, except "." and "..". - unlink(entry->d_name); + unlink(filename); } errno = 0; continue; } - // We now have a file name that converts to a valid integer - // that could represent a process id . if this process id - // matches the current process id or the process is not running, - // then remove the stale file resources. - // - // Process liveness is detected by sending signal number 0 to - // the process id (see kill(2)). if kill determines that the - // process does not exist, then the file resources are removed. - // if kill determines that that we don't have permission to - // signal the process, then the file resources are assumed to - // be stale and are removed because the resources for such a - // process should be in a different user specific directory. - if ((pid == os::current_process_id()) || - (kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) { - - unlink(entry->d_name); + // The following code assumes that pid must be in the same + // namespace as the current process. + bool stale = false; + + if (pid == os::current_process_id()) { + // The file was created by a terminated process that happened + // to have the same pid as the current process. + stale = true; + } else if (kill(pid, 0) == OS_ERR) { + if (errno == ESRCH) { + // The target process does not exist. + stale = true; + } else if (errno == EPERM) { + // The file was created by a terminated process that happened + // to have the same pid as a process not owned by the current user. + stale = true; + } + } + + if (stale) { + log_info(perf, memops)("Remove stale file %s/%s", dirname, filename); + unlink(filename); } + errno = 0; } @@ -851,13 +846,13 @@ static bool make_user_tmp_dir(const char* dirname) { return true; } -// create the shared memory file resources +// create the shared memory file // // This method creates the shared memory file with the given size // This method also creates the user specific temporary directory, if // it does not yet exist. // -static int create_sharedmem_resources(const char* dirname, const char* filename, size_t size) { +static int create_sharedmem_file(const char* dirname, const char* filename, size_t size) { // make the user temporary directory if (!make_user_tmp_dir(dirname)) { @@ -1013,12 +1008,13 @@ static char* mmap_create_shared(size_t size) { } // cleanup any stale shared memory files - cleanup_sharedmem_resources(dirname); + cleanup_sharedmem_files(dirname); assert(((size > 0) && (size % os::vm_page_size() == 0)), "unexpected PerfMemory region size"); - fd = create_sharedmem_resources(dirname, short_filename, size); + log_info(perf, memops)("Trying to open %s/%s", dirname, short_filename); + fd = create_sharedmem_file(dirname, short_filename, size); FREE_C_HEAP_ARRAY(char, user_name); FREE_C_HEAP_ARRAY(char, dirname); @@ -1051,6 +1047,8 @@ static char* mmap_create_shared(size_t size) { // It does not go through os api, the operation has to record from here. MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC, mtInternal); + log_info(perf, memops)("Successfully opened"); + return mapAddress; } @@ -1076,10 +1074,10 @@ static char* create_shared_memory(size_t size) { // static void delete_shared_memory(char* addr, size_t size) { - // cleanup the persistent shared memory resources. since DestroyJavaVM does - // not support unloading of the JVM, unmapping of the memory resource is + // Remove the shared memory file. Since DestroyJavaVM does + // not support unloading of the JVM, unmapping of the memory region is // not performed. The memory will be reclaimed by the OS upon termination of - // the process. The backing store file is deleted from the file system. + // the process. assert(!PerfDisableSharedMem, "shouldn't be here"); @@ -1290,10 +1288,7 @@ void PerfMemory::delete_memory_region() { save_memory_to_file(start(), capacity()); } - if (PerfDisableSharedMem) { - delete_standard_memory(start(), capacity()); - } - else { + if (!PerfDisableSharedMem) { delete_shared_memory(start(), capacity()); } } diff --git a/src/hotspot/os/bsd/perfMemory_bsd.cpp b/src/hotspot/os/bsd/perfMemory_bsd.cpp index 0a52bc43d52..95296937b77 100644 --- a/src/hotspot/os/bsd/perfMemory_bsd.cpp +++ b/src/hotspot/os/bsd/perfMemory_bsd.cpp @@ -73,18 +73,6 @@ static char* create_standard_memory(size_t size) { return mapAddress; } -// delete the PerfData memory region -// -static void delete_standard_memory(char* addr, size_t size) { - - // there are no persistent external resources to cleanup for standard - // memory. since DestroyJavaVM does not support unloading of the JVM, - // cleanup of the memory resource is not performed. The memory will be - // reclaimed by the OS upon termination of the process. - // - return; -} - // save the specified memory region to the given file // // Note: this function might be called from signal handler (by os::abort()), @@ -656,16 +644,17 @@ static void remove_file(const char* path) { } -// cleanup stale shared memory resources +// cleanup stale shared memory files // // This method attempts to remove all stale shared memory files in // the named user temporary directory. It scans the named directory -// for files matching the pattern ^$[0-9]*$. For each file found, the -// process id is extracted from the file name and a test is run to -// determine if the process is alive. If the process is not alive, -// any stale file resources are removed. +// for files matching the pattern ^$[0-9]*$. // -static void cleanup_sharedmem_resources(const char* dirname) { +// This directory should be used only by JVM processes owned by the +// current user to store PerfMemory files. Any other files found +// in this directory may be removed. +// +static void cleanup_sharedmem_files(const char* dirname) { int saved_cwd_fd; // open the directory and set the current working directory to it @@ -675,50 +664,56 @@ static void cleanup_sharedmem_resources(const char* dirname) { return; } - // for each entry in the directory that matches the expected file - // name pattern, determine if the file resources are stale and if - // so, remove the file resources. Note, instrumented HotSpot processes - // for this user may start and/or terminate during this search and - // remove or create new files in this directory. The behavior of this - // loop under these conditions is dependent upon the implementation of - // opendir/readdir. + // For each entry in the directory that matches the expected file + // name pattern, remove the file if it's determine to be stale + // Note, instrumented HotSpot processes for this user may start and/or + // terminate during this search and remove or create new files in this + // directory. The behavior of this loop under these conditions is dependent + // upon the implementation of opendir/readdir. // struct dirent* entry; errno = 0; while ((entry = os::readdir(dirp)) != NULL) { - pid_t pid = filename_to_pid(entry->d_name); + const char* filename = entry->d_name; + pid_t pid = filename_to_pid(filename); if (pid == 0) { - if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { + if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) { // attempt to remove all unexpected files, except "." and ".." - unlink(entry->d_name); + unlink(filename); } errno = 0; continue; } - // we now have a file name that converts to a valid integer - // that could represent a process id . if this process id - // matches the current process id or the process is not running, - // then remove the stale file resources. - // - // process liveness is detected by sending signal number 0 to - // the process id (see kill(2)). if kill determines that the - // process does not exist, then the file resources are removed. - // if kill determines that that we don't have permission to - // signal the process, then the file resources are assumed to - // be stale and are removed because the resources for such a - // process should be in a different user specific directory. - // - if ((pid == os::current_process_id()) || - (kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) { + // The following code assumes that pid must be in the same + // namespace as the current process. + bool stale = false; + + if (pid == os::current_process_id()) { + // The file was created by a terminated process that happened + // to have the same pid as the current process. + stale = true; + } else if (kill(pid, 0) == OS_ERR) { + if (errno == ESRCH) { + // The target process does not exist. + stale = true; + } else if (errno == EPERM) { + // The file was created by a terminated process that happened + // to have the same pid as a process not owned by the current user. + stale = true; + } + } - unlink(entry->d_name); + if (stale) { + log_info(perf, memops)("Remove stale file %s/%s", dirname, filename); + unlink(filename); } + errno = 0; } @@ -764,13 +759,13 @@ static bool make_user_tmp_dir(const char* dirname) { return true; } -// create the shared memory file resources +// create the shared memory file // // This method creates the shared memory file with the given size // This method also creates the user specific temporary directory, if // it does not yet exist. // -static int create_sharedmem_resources(const char* dirname, const char* filename, size_t size) { +static int create_sharedmem_file(const char* dirname, const char* filename, size_t size) { // make the user temporary directory if (!make_user_tmp_dir(dirname)) { @@ -934,12 +929,13 @@ static char* mmap_create_shared(size_t size) { } // cleanup any stale shared memory files - cleanup_sharedmem_resources(dirname); + cleanup_sharedmem_files(dirname); assert(((size > 0) && (size % os::vm_page_size() == 0)), "unexpected PerfMemory region size"); - fd = create_sharedmem_resources(dirname, short_filename, size); + log_info(perf, memops)("Trying to open %s/%s", dirname, short_filename); + fd = create_sharedmem_file(dirname, short_filename, size); FREE_C_HEAP_ARRAY(char, user_name); FREE_C_HEAP_ARRAY(char, dirname); @@ -972,6 +968,8 @@ static char* mmap_create_shared(size_t size) { // it does not go through os api, the operation has to record from here MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); + log_info(perf, memops)("Successfully opened"); + return mapAddress; } @@ -993,10 +991,10 @@ static char* create_shared_memory(size_t size) { // static void delete_shared_memory(char* addr, size_t size) { - // cleanup the persistent shared memory resources. since DestroyJavaVM does - // not support unloading of the JVM, unmapping of the memory resource is + // Remove the shared memory file. Since DestroyJavaVM does + // not support unloading of the JVM, unmapping of the memory region is // not performed. The memory will be reclaimed by the OS upon termination of - // the process. The backing store file is deleted from the file system. + // the process. assert(!PerfDisableSharedMem, "shouldn't be here"); @@ -1196,10 +1194,7 @@ void PerfMemory::delete_memory_region() { save_memory_to_file(start(), capacity()); } - if (PerfDisableSharedMem) { - delete_standard_memory(start(), capacity()); - } - else { + if (!PerfDisableSharedMem) { delete_shared_memory(start(), capacity()); } } diff --git a/src/hotspot/os/linux/perfMemory_linux.cpp b/src/hotspot/os/linux/perfMemory_linux.cpp index 991d0896ce8..b3f637811fb 100644 --- a/src/hotspot/os/linux/perfMemory_linux.cpp +++ b/src/hotspot/os/linux/perfMemory_linux.cpp @@ -41,6 +41,7 @@ # include # include # include +# include # include # include # include @@ -73,18 +74,6 @@ static char* create_standard_memory(size_t size) { return mapAddress; } -// delete the PerfData memory region -// -static void delete_standard_memory(char* addr, size_t size) { - - // there are no persistent external resources to cleanup for standard - // memory. since DestroyJavaVM does not support unloading of the JVM, - // cleanup of the memory resource is not performed. The memory will be - // reclaimed by the OS upon termination of the process. - // - return; -} - // save the specified memory region to the given file // // Note: this function might be called from signal handler (by os::abort()), @@ -737,16 +726,17 @@ static void remove_file(const char* path) { } -// cleanup stale shared memory resources +// cleanup stale shared memory files // // This method attempts to remove all stale shared memory files in // the named user temporary directory. It scans the named directory -// for files matching the pattern ^$[0-9]*$. For each file found, the -// process id is extracted from the file name and a test is run to -// determine if the process is alive. If the process is not alive, -// any stale file resources are removed. +// for files matching the pattern ^$[0-9]*$. // -static void cleanup_sharedmem_resources(const char* dirname) { +// This directory should be used only by JVM processes owned by the +// current user to store PerfMemory files. Any other files found +// in this directory may be removed. +// +static void cleanup_sharedmem_files(const char* dirname) { int saved_cwd_fd; // open the directory @@ -756,48 +746,93 @@ static void cleanup_sharedmem_resources(const char* dirname) { return; } - // for each entry in the directory that matches the expected file - // name pattern, determine if the file resources are stale and if - // so, remove the file resources. Note, instrumented HotSpot processes - // for this user may start and/or terminate during this search and - // remove or create new files in this directory. The behavior of this - // loop under these conditions is dependent upon the implementation of - // opendir/readdir. + // For each entry in the directory that matches the expected file + // name pattern, remove the file if it's determine to be stale + // Note, instrumented HotSpot processes for this user may start and/or + // terminate during this search and remove or create new files in this + // directory. The behavior of this loop under these conditions is dependent + // upon the implementation of opendir/readdir. // struct dirent* entry; errno = 0; while ((entry = os::readdir(dirp)) != NULL) { - pid_t pid = filename_to_pid(entry->d_name); + const char* filename = entry->d_name; + pid_t pid = filename_to_pid(filename); if (pid == 0) { - if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { + if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) { // attempt to remove all unexpected files, except "." and ".." - unlink(entry->d_name); + unlink(filename); } errno = 0; continue; } - // we now have a file name that converts to a valid integer - // that could represent a process id . if this process id - // matches the current process id or the process is not running, - // then remove the stale file resources. - // - // process liveness is detected by sending signal number 0 to - // the process id (see kill(2)). if kill determines that the - // process does not exist, then the file resources are removed. - // if kill determines that that we don't have permission to - // signal the process, then the file resources are assumed to - // be stale and are removed because the resources for such a - // process should be in a different user specific directory. + // Special case on Linux, if multiple containers share the + // same /tmp directory: // - if ((pid == os::current_process_id()) || - (kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) { - unlink(entry->d_name); + // - All the JVMs must have the JDK-8286030 fix, or the behavior + // is undefined. + // - We cannot rely on the values of the pid, because it could + // be a process in a different namespace. We must use the flock + // protocol to determine if a live process is using this file. + // See create_sharedmem_file(). + int fd; + RESTARTABLE(os::open(filename, O_RDONLY, 0), fd); + if (fd == OS_ERR) { + // Something wrong happened. Ignore the error and don't try to remove the + // file. + log_debug(perf, memops)("os::open() for stale file check failed for %s/%s", dirname, filename); + errno = 0; + continue; + } + + int n; + RESTARTABLE(::flock(fd, LOCK_EX|LOCK_NB), n); + if (n != 0) { + // Either another process holds the exclusive lock on this file, or + // something wrong happened. Ignore the error and don't try to remove the + // file. + log_debug(perf, memops)("flock for stale file check failed for %s/%s", dirname, filename); + ::close(fd); + errno = 0; + continue; + } + // We are able to lock the file, but this file might have been created + // by an older JVM that doesn't use the flock prototol, so we must do + // the folowing checks (which are also done by older JVMs). + + // The following code assumes that pid must be in the same + // namespace as the current process. + bool stale = false; + + if (pid == os::current_process_id()) { + // The file was created by a terminated process that happened + // to have the same pid as the current process. + stale = true; + } else if (kill(pid, 0) == OS_ERR) { + if (errno == ESRCH) { + // The target process does not exist. + stale = true; + } else if (errno == EPERM) { + // The file was created by a terminated process that happened + // to have the same pid as a process not owned by the current user. + stale = true; + } } + + if (stale) { + log_info(perf, memops)("Remove stale file %s/%s", dirname, filename); + unlink(filename); + } + + // Hold the lock until here to prevent other JVMs from using this file + // while we were in the middle of deleting it. + ::close(fd); + errno = 0; } @@ -843,13 +878,13 @@ static bool make_user_tmp_dir(const char* dirname) { return true; } -// create the shared memory file resources +// create the shared memory file // // This method creates the shared memory file with the given size // This method also creates the user specific temporary directory, if // it does not yet exist. // -static int create_sharedmem_resources(const char* dirname, const char* filename, size_t size) { +static int create_sharedmem_file(const char* dirname, const char* filename, size_t size) { // make the user temporary directory if (!make_user_tmp_dir(dirname)) { @@ -897,6 +932,30 @@ static int create_sharedmem_resources(const char* dirname, const char* filename, return -1; } + // On Linux, different containerized processes that share the same /tmp + // directory (e.g., with "docker --volume ...") may have the same pid and + // try to use the same file. To avoid conflicts among such + // processes, we allow only one of them (the winner of the flock() call) + // to write to the file. All the other processes will give up and will + // have perfdata disabled. + // + // Note that the flock will be automatically given up when the winner + // process exits. + // + // The locking protocol works only with other JVMs that have the JDK-8286030 + // fix. If you are sharing the /tmp difrectory among different containers, + // do not use older JVMs that don't have this fix, or the behavior is undefined. + int n; + RESTARTABLE(::flock(fd, LOCK_EX|LOCK_NB), n); + if (n != 0) { + log_warning(perf, memops)("Cannot use file %s/%s because %s (errno = %d)", dirname, filename, + (errno == EWOULDBLOCK) ? + "it is locked by another process" : + "flock() failed", errno); + ::close(fd); + return -1; + } + // truncate the file to get rid of any existing data RESTARTABLE(::ftruncate(fd, (off_t)0), result); if (result == OS_ERR) { @@ -1013,12 +1072,13 @@ static char* mmap_create_shared(size_t size) { } // cleanup any stale shared memory files - cleanup_sharedmem_resources(dirname); + cleanup_sharedmem_files(dirname); assert(((size > 0) && (size % os::vm_page_size() == 0)), "unexpected PerfMemory region size"); - fd = create_sharedmem_resources(dirname, short_filename, size); + log_info(perf, memops)("Trying to open %s/%s", dirname, short_filename); + fd = create_sharedmem_file(dirname, short_filename, size); FREE_C_HEAP_ARRAY(char, user_name); FREE_C_HEAP_ARRAY(char, dirname); @@ -1051,6 +1111,8 @@ static char* mmap_create_shared(size_t size) { // it does not go through os api, the operation has to record from here MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); + log_info(perf, memops)("Successfully opened"); + return mapAddress; } @@ -1072,10 +1134,10 @@ static char* create_shared_memory(size_t size) { // static void delete_shared_memory(char* addr, size_t size) { - // cleanup the persistent shared memory resources. since DestroyJavaVM does - // not support unloading of the JVM, unmapping of the memory resource is + // Remove the shared memory file. Since DestroyJavaVM does + // not support unloading of the JVM, unmapping of the memory region is // not performed. The memory will be reclaimed by the OS upon termination of - // the process. The backing store file is deleted from the file system. + // the process. assert(!PerfDisableSharedMem, "shouldn't be here"); @@ -1284,10 +1346,7 @@ void PerfMemory::delete_memory_region() { save_memory_to_file(start(), capacity()); } - if (PerfDisableSharedMem) { - delete_standard_memory(start(), capacity()); - } - else { + if (!PerfDisableSharedMem) { delete_shared_memory(start(), capacity()); } } diff --git a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java new file mode 100644 index 00000000000..08493a75398 --- /dev/null +++ b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java @@ -0,0 +1,132 @@ +/* + * 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 8286030 + * @key cgroups + * @summary Test for hsperfdata file name conflict when two containers share the same /tmp directory + * @requires docker.support + * @library /test/lib + * @build WaitForFlagFile + * @run driver ShareTmpDir + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.containers.docker.Common; +import jdk.test.lib.containers.docker.DockerRunOptions; +import jdk.test.lib.containers.docker.DockerTestUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; + +public class ShareTmpDir { + private static final String imageName = Common.imageName("sharetmpdir"); + + public static void main(String[] args) throws Exception { + if (!DockerTestUtils.canTestDocker()) { + return; + } + + DockerTestUtils.buildJdkContainerImage(imageName); + + try { + test(); + } finally { + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { + DockerTestUtils.removeDockerImage(imageName); + } + } + } + + static OutputAnalyzer out1, out2; + + private static void test() throws Exception { + File sharedtmpdir = new File("sharedtmpdir"); + File flag = new File(sharedtmpdir, "flag"); + File started = new File(sharedtmpdir, "started"); + sharedtmpdir.mkdir(); + flag.delete(); + started.delete(); + DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "WaitForFlagFile"); + opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); + opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp/"); + opts.addJavaOpts("-Xlog:os+container=trace", "-Xlog:perf+memops=debug", "-cp", "/test-classes/"); + + Thread t1 = new Thread() { + public void run() { + try { out1 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } + } + }; + t1.start(); + + Thread t2 = new Thread() { + public void run() { + try { out2 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } + } + }; + t2.start(); + + while (!started.exists()) { + System.out.println("Wait for at least one JVM to start"); + Thread.sleep(1000); + } + + // Set the flag for the two JVMs to exit + FileOutputStream fout = new FileOutputStream(flag); + fout.close(); + + t1.join(); + t2.join(); + + Pattern pattern = Pattern.compile("perf,memops.*Trying to open (/tmp/hsperfdata_[a-z0-9]*/[0-9]*)"); + Matcher matcher; + + matcher = pattern.matcher(out1.getStdout()); + Asserts.assertTrue(matcher.find()); + String file1 = matcher.group(1); + + matcher = pattern.matcher(out2.getStdout()); + Asserts.assertTrue(matcher.find()); + String file2 = matcher.group(1); + + Asserts.assertTrue(file1 != null); + Asserts.assertTrue(file2 != null); + + if (file1.equals(file2)) { + // This should be the common case -- the first started process in a container should + // have pid==1. + // One of the two containers must fail to create the hsperf file. + String s = "Cannot use file " + file1 + " because it is locked by another process"; + Asserts.assertTrue(out1.getStdout().contains(s) || + out2.getStdout().contains(s)); + } else { + throw new SkippedException("Java in the two containers don't have the same pid: " + file1 + " vs " + file2); + } + } +} diff --git a/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java new file mode 100644 index 00000000000..64596830a3f --- /dev/null +++ b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java @@ -0,0 +1,43 @@ +/* + * 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.io.File; +import java.io.FileOutputStream; + +public class WaitForFlagFile { + public static void main(String[] args) throws Exception { + System.out.println("WaitForFlagFile: Entering"); + + File started = new File("/tmp/started"); + FileOutputStream fout = new FileOutputStream(started); + fout.close(); + + File flag = new File("/tmp/flag"); + while (!flag.exists()) { + System.out.println("WaitForFlagFile: Waiting"); + Thread.sleep(500); + } + System.out.println("WaitForFlagFile: Exiting"); + + } +} From 7d7aa61eb0be91491259c241f069aca05980ef7f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:01:20 +0000 Subject: [PATCH 124/205] 8218133: sun/net/www/protocol/http/ProtocolRedirect.java failed with "java.net.ConnectException" Changed the test to use the loopback interface. Backport-of: d176e208985f55745a60fc806dfb369a2cce0781 --- .../www/protocol/http/ProtocolRedirect.java | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/test/jdk/sun/net/www/protocol/http/ProtocolRedirect.java b/test/jdk/sun/net/www/protocol/http/ProtocolRedirect.java index e961082ff0a..5f9723abea3 100644 --- a/test/jdk/sun/net/www/protocol/http/ProtocolRedirect.java +++ b/test/jdk/sun/net/www/protocol/http/ProtocolRedirect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -31,24 +31,30 @@ public class ProtocolRedirect { public static void main(String [] args) throws Exception { - int localPort; - new Thread(new Redirect()).start(); - while ((localPort = Redirect.listenPort) == -1) { - Thread.sleep(1000); - } + try (Redirect server = new Redirect(new ServerSocket())) { + ServerSocket ss = server.ssock; + ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); + new Thread(server).start(); - String page = "http://localhost:"+localPort+"/"; - URL url = new URL(page); - HttpURLConnection conn = (HttpURLConnection)url.openConnection(); - conn.connect(); - if (conn.getResponseCode() != 302) { - throw new RuntimeException("Test failed. Should get RespCode: 302. Got:"+conn.getResponseCode()); + URL url = new URL("http", ss.getInetAddress().getHostAddress(), ss.getLocalPort(), "/"); + String page = url.toString(); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.connect(); + if (conn.getResponseCode() != 302) { + System.err.println("Bad response code received from: " + page); + throw new RuntimeException("Test failed. Should get RespCode: 302. Got:" + conn.getResponseCode()); + } + System.out.println("Received expected response code from: " + page); } } } -class Redirect implements Runnable { - public static int listenPort = -1; // port to listen for connections on +class Redirect implements Runnable, Closeable { + final ServerSocket ssock; + volatile boolean stopped; + Redirect(ServerSocket ss) { + ssock = ss; + } // Send a header redirect to the peer telling it to go to the // https server on the host it sent the connection request to. @@ -61,18 +67,31 @@ private void sendReply() throws IOException { out.write(reply.toString().getBytes()); } - Socket sock; + volatile Socket sock; public void run() { try { - ServerSocket ssock = new ServerSocket(); - ssock.bind(null); - listenPort = ssock.getLocalPort(); - sock = ssock.accept(); - sock.setTcpNoDelay(true); + Socket s = sock = ssock.accept(); + s.setTcpNoDelay(true); sendReply(); - sock.shutdownOutput(); - } catch(IOException io) { - throw new RuntimeException(io.getCause()); + s.shutdownOutput(); + } catch(Throwable t) { + if (!stopped) { + t.printStackTrace(); + throw new RuntimeException(String.valueOf(t), t); + } + } + } + + public void close() { + Socket s = sock; + boolean done = stopped; + if (done) return; + stopped = true; + try { + if (s != null) s.close(); + } catch (Throwable x) { + } finally { + try { ssock.close(); } catch (Throwable x) {} } } From a220aaf3c62718d781aa43b4b00688ca54f3c35c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:04:49 +0000 Subject: [PATCH 125/205] 8195057: java/util/concurrent/CountDownLatch/Basic.java failed w/ Xcomp Backport-of: 012c399c26278aaab22c8f779a443f5e05924af9 --- .../util/concurrent/CountDownLatch/Basic.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java index 61fa4776784..bf2d9a6b0ae 100644 --- a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java +++ b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java @@ -25,24 +25,27 @@ * @test * @bug 6332435 * @summary Basic tests for CountDownLatch + * @library /test/lib * @author Seetharam Avadhanam, Martin Buchholz */ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import jdk.test.lib.Utils; -interface AwaiterFactory { - Awaiter getAwaiter(); -} +public class Basic { + static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); -abstract class Awaiter extends Thread { - private volatile Throwable result = null; - protected void result(Throwable result) { this.result = result; } - public Throwable result() { return this.result; } -} + interface AwaiterFactory { + Awaiter getAwaiter(); + } -public class Basic { + abstract static class Awaiter extends Thread { + private volatile Throwable result = null; + protected void result(Throwable result) { this.result = result; } + public Throwable result() { return this.result; } + } private void toTheStartingGate(CountDownLatch gate) { try { @@ -78,15 +81,12 @@ private Awaiter awaiter(final CountDownLatch latch, catch (Throwable result) { result(result); }}}; } - private AwaiterFactory awaiterFactories(final CountDownLatch latch, - final CountDownLatch gate, - final int i) { - if (i == 1) - return new AwaiterFactory() { public Awaiter getAwaiter() { - return awaiter(latch, gate); }}; + AwaiterFactory awaiterFactory(CountDownLatch latch, CountDownLatch gate) { + return () -> awaiter(latch, gate); + } - return new AwaiterFactory() { public Awaiter getAwaiter() { - return awaiter(latch, gate, 10000); }}; + AwaiterFactory timedAwaiterFactory(CountDownLatch latch, CountDownLatch gate) { + return () -> awaiter(latch, gate, LONG_DELAY_MS); } //---------------------------------------------------------------- @@ -100,8 +100,8 @@ public static void normalUse() throws Throwable { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); @@ -129,8 +129,8 @@ public static void threadInterrupted() throws Throwable { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); @@ -162,8 +162,8 @@ public static void timeOut() throws Throwable { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = test.awaiter(latch, gate, timeout[i]); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); From 88d8eb222224ef96918aeb9dc7daf25b4626e71c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:10:12 +0000 Subject: [PATCH 126/205] 8170705: sun/net/www/protocol/http/StackTraceTest.java fails intermittently with Invalid Http response Backport-of: 1df787692a91c35e821610c03bbaba7e024d2932 --- .../net/www/protocol/http/StackTraceTest.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/jdk/sun/net/www/protocol/http/StackTraceTest.java b/test/jdk/sun/net/www/protocol/http/StackTraceTest.java index 3a12c3c4eef..0b710269570 100644 --- a/test/jdk/sun/net/www/protocol/http/StackTraceTest.java +++ b/test/jdk/sun/net/www/protocol/http/StackTraceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -21,22 +21,30 @@ * questions. */ -/** +/* * @test * @bug 4773417 5003746 + * @library /test/lib + * @build jdk.test.lib.Utils + * @run main StackTraceTest * @summary HttpURLConnection.getInputStream() produces IOException with * bad stack trace; HttpURLConnection.getInputStream loses * exception message, exception class */ import java.net.*; import java.io.IOException; +import jdk.test.lib.Utils; public class StackTraceTest { public static void main(String[] args) throws Exception { - URL url; - try (ServerSocket ss = new ServerSocket(0)) { // refusing socket - url = new URL("http://localhost:" + ss.getLocalPort() + "/"); - } + InetSocketAddress refusing = Utils.refusingEndpoint(); + int port = refusing.getPort(); + String host = refusing.getAddress().getHostAddress(); + if (host.contains(":")) + host = "[" + host + "]"; + URL url = URI.create("http://" + host + ":" + port + "/").toURL(); + System.out.println("URL: " + url); + URLConnection uc = url.openConnection(); // Trigger implicit connection by trying to retrieve bogus From 834e07259cbda6fe0f53e4ae28f9ea1db48662d0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:14:33 +0000 Subject: [PATCH 127/205] 8221098: Run java/net/URL/HandlerLoop.java in othervm mode Backport-of: defc86bd5b1cd94c473edaec68aadf0f1193d5a4 --- test/jdk/java/net/URL/HandlerLoop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/net/URL/HandlerLoop.java b/test/jdk/java/net/URL/HandlerLoop.java index 3249e24712f..26adcf0bec4 100644 --- a/test/jdk/java/net/URL/HandlerLoop.java +++ b/test/jdk/java/net/URL/HandlerLoop.java @@ -32,7 +32,7 @@ * @summary Test bootstrap problem when a URLStreamHandlerFactory is loaded * by the application class loader. * @modules java.base/sun.net.www.protocol.file - * @run main HandlerLoop + * @run main/othervm HandlerLoop */ public class HandlerLoop { From 3614fb27a439c28a6a191eb24f7ea1430c3eda0f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:18:31 +0000 Subject: [PATCH 128/205] 8222430: Add tests for ElementKind predicates Backport-of: 4a9f7612be2f4949c20c12b5faae7e215f175875 --- .../element/TestElementKindPredicates.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 test/langtools/tools/javac/processing/model/element/TestElementKindPredicates.java diff --git a/test/langtools/tools/javac/processing/model/element/TestElementKindPredicates.java b/test/langtools/tools/javac/processing/model/element/TestElementKindPredicates.java new file mode 100644 index 00000000000..479124812e3 --- /dev/null +++ b/test/langtools/tools/javac/processing/model/element/TestElementKindPredicates.java @@ -0,0 +1,74 @@ +/* + * 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 + * @bug 8222430 + * @summary Test various predicates of ElementKind. + */ + +import java.util.Set; +import java.util.function.Predicate; +import javax.lang.model.element.ElementKind; + +/** + * Test the isClass, isField, and isInterface predicates of ElementKind. + */ +public class TestElementKindPredicates { + public static void main(String... args) { + Set ALL_KINDS = Set.of(ElementKind.values()); + + // isClass: Returns true if this is a kind of class: either CLASS or ENUM. + test(ALL_KINDS, + (ElementKind k) -> Set.of(ElementKind.CLASS, + ElementKind.ENUM).contains(k), + (ElementKind k) -> k.isClass(), "isClass"); + + // isField: Returns true if this is a kind of field: either FIELD or ENUM_CONSTANT. + test(ALL_KINDS, + (ElementKind k) -> Set.of(ElementKind.FIELD, + ElementKind.ENUM_CONSTANT).contains(k), + (ElementKind k) -> k.isField(), "isField"); + + // isInterface: Returns true if this is a kind of interface: either INTERFACE or ANNOTATION_TYPE. + test(ALL_KINDS, + (ElementKind k) -> Set.of(ElementKind.INTERFACE, + ElementKind.ANNOTATION_TYPE).contains(k), + (ElementKind k) -> k.isInterface(), "isInterface"); + } + + private static void test(Set kinds, + Predicate expectedPred, + Predicate actualPred, + String errorMessage) { + for(ElementKind kind : kinds) { + boolean expected = expectedPred.test(kind); + boolean actual = actualPred.test(kind); + + if (expected != actual) { + throw new RuntimeException("Error testing ElementKind." + errorMessage + "(" + kind + + "):\texpected " + expected + "\tgot " + actual); + } + } + } +} From c90bc806cfd1381c9b5d6fdb22c4937d5b769659 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:23:32 +0000 Subject: [PATCH 129/205] 8129315: java/net/Socket/LingerTest.java and java/net/Socket/ShutdownBoth.java timeout intermittently Tests are updated to use the loopback address instead of the wildcard to avoid traffic being routed to a different server than what was intended by the test. Backport-of: 72467d916c82ff02bc5101f91e3e7d32c1d5e5b5 --- test/jdk/java/net/Socket/LingerTest.java | 19 +++++---- test/jdk/java/net/Socket/ShutdownBoth.java | 5 ++- test/jdk/java/net/Socks/SocksIPv6Test.java | 40 ++++++++++++++----- test/jdk/java/net/Socks/SocksServer.java | 21 +++++++++- .../http/HttpURLConnection/PostOnDelete.java | 13 ++++-- 5 files changed, 75 insertions(+), 23 deletions(-) diff --git a/test/jdk/java/net/Socket/LingerTest.java b/test/jdk/java/net/Socket/LingerTest.java index 83e0be833d9..9a084c69df9 100644 --- a/test/jdk/java/net/Socket/LingerTest.java +++ b/test/jdk/java/net/Socket/LingerTest.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 @@ -71,11 +71,13 @@ public void run() { } static class Other implements Runnable { - int port; - long delay; + final InetAddress address; + final int port; + final long delay; boolean connected = false; - public Other(int port, long delay) { + public Other(InetAddress address, int port, long delay) { + this.address = address; this.port = port; this.delay = delay; } @@ -85,7 +87,7 @@ public void run() { try { Thread.sleep(delay); System.out.println ("Other opening socket"); - Socket s = new Socket("localhost", port); + Socket s = new Socket(address, port); synchronized (this) { connected = true; } @@ -103,9 +105,10 @@ public synchronized boolean connected() { } public static void main(String args[]) throws Exception { - ServerSocket ss = new ServerSocket(0); + InetAddress loopback = InetAddress.getLoopbackAddress(); + ServerSocket ss = new ServerSocket(0, 50, loopback); - Socket s1 = new Socket("localhost", ss.getLocalPort()); + Socket s1 = new Socket(loopback, ss.getLocalPort()); Socket s2 = ss.accept(); // setup conditions for untransmitted data and lengthy @@ -119,7 +122,7 @@ public static void main(String args[]) throws Exception { senderThread.start(); // other thread that will connect after 5 seconds. - Other other = new Other(ss.getLocalPort(), 5000); + Other other = new Other(loopback, ss.getLocalPort(), 5000); Thread otherThread = new Thread(other); otherThread.start(); diff --git a/test/jdk/java/net/Socket/ShutdownBoth.java b/test/jdk/java/net/Socket/ShutdownBoth.java index 421d52b7361..2adc67cb13c 100644 --- a/test/jdk/java/net/Socket/ShutdownBoth.java +++ b/test/jdk/java/net/Socket/ShutdownBoth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, 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 @@ -32,7 +32,8 @@ public class ShutdownBoth { public static void main(String args[]) throws Exception { - ServerSocket ss = new ServerSocket(0); + InetAddress loopback = InetAddress.getLoopbackAddress(); + ServerSocket ss = new ServerSocket(0, 50, loopback); Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort()); Socket s2 = ss.accept(); diff --git a/test/jdk/java/net/Socks/SocksIPv6Test.java b/test/jdk/java/net/Socks/SocksIPv6Test.java index a09db166d73..a104209df6d 100644 --- a/test/jdk/java/net/Socks/SocksIPv6Test.java +++ b/test/jdk/java/net/Socks/SocksIPv6Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -30,7 +30,6 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Authenticator; @@ -43,7 +42,6 @@ import java.net.ServerSocket; import java.net.SocketException; import java.net.NetworkInterface; -import java.net.UnknownHostException; import java.util.Collections; import java.util.List; import com.sun.net.httpserver.*; @@ -65,7 +63,7 @@ public class SocksIPv6Test { public void setUp() throws Exception { shouldRun = ensureInet6AddressFamily() && ensureIPv6OnLoopback(); - server = HttpServer.create(new InetSocketAddress(0), 0); + server = HttpServer.create(new InetSocketAddress("::1", 0), 0); server.createContext("/", ex -> { ex.sendResponseHeaders(200, response.length()); try (BufferedWriter writer = new BufferedWriter( @@ -76,7 +74,7 @@ public void setUp() throws Exception { }); server.start(); - socks = new SocksServer(0, false); + socks = new SocksServer(InetAddress.getByName("::1"), 0, false); socks.addUser("user", "pass"); socks.start(); @@ -140,21 +138,45 @@ public void testSocksOverIPv6() throws Exception { public void testSocksOverIPv6Hostname() throws Exception { if (!shouldRun) return; - String ipv6Hostname = InetAddress.getByName("::1").getHostName(); - String ipv4Hostname = InetAddress.getByName("127.0.0.1").getHostName(); + InetAddress ipv6Loopback = InetAddress.getByName("::1"); + String ipv6Hostname = ipv6Loopback.getHostName(); + String ipv6HostAddress = ipv6Loopback.getHostAddress(); + InetAddress ipv4Loopback; + String ipv4Hostname; + String ipv4HostAddress; + try { + ipv4Loopback = InetAddress.getByName("127.0.0.1"); + ipv4Hostname = ipv4Loopback == null ? null : ipv4Loopback.getHostName(); + ipv4HostAddress = ipv4Loopback == null ? null : ipv4Loopback.getHostAddress(); + } catch (IOException io) { + ipv4Hostname = null; + ipv4HostAddress = null; + } + + System.out.println("ipv6Hostname: " + ipv6Hostname + " / " + ipv6HostAddress); + System.out.println("ipv4Hostname: " + ipv4Hostname + " / " + ipv4HostAddress); - if (ipv6Hostname.equals(InetAddress.getByName("::1").getHostAddress())) { + if (ipv6Hostname.equals(ipv6HostAddress)) { System.out.println("Unable to get the hostname of the IPv6 loopback " + "address. Skipping test case."); return; } - if (ipv6Hostname.equals(ipv4Hostname)) { + if (ipv4Hostname != null && ipv6Hostname.equals(ipv4Hostname)) { System.out.println("IPv6 and IPv4 loopback addresses map to the" + " same hostname. Skipping test case."); return; } + if (!InetAddress.getByName(ipv6Hostname).getHostAddress() + .equals(ipv6HostAddress)) { + System.out.println(ipv6Hostname + " resolves to \"" + + InetAddress.getByName(ipv6Hostname).getHostAddress() + + "\", not \"" + ipv6HostAddress + + "\". Skipping test case."); + return; + } + Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ipv6Hostname, socks.getPort())); URL url = new URL("http://" + ipv6Hostname + ":" + server.getAddress().getPort()); diff --git a/test/jdk/java/net/Socks/SocksServer.java b/test/jdk/java/net/Socks/SocksServer.java index f2d6ef82bfe..6d9ded42ab5 100644 --- a/test/jdk/java/net/Socks/SocksServer.java +++ b/test/jdk/java/net/Socks/SocksServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -491,6 +491,25 @@ public SocksServer(int port) throws IOException { } } + public SocksServer(InetAddress addr, int port, boolean useV4) throws IOException { + this.port = port; + this.useV4 = useV4; + server = new ServerSocket(); + if (port == 0 && addr == null) { + server.bind(null); + this.port = server.getLocalPort(); + } else if (port == 0 && addr != null) { + server.bind(new InetSocketAddress(addr, 0)); + this.port = server.getLocalPort(); + } else if (addr == null) { + assert port != 0; + server.bind(new InetSocketAddress(port)); + } else { + assert port != 0; + server.bind(new InetSocketAddress(addr, port)); + } + } + public SocksServer() throws IOException { this (DEFAULT_PORT); } diff --git a/test/jdk/sun/net/www/http/HttpURLConnection/PostOnDelete.java b/test/jdk/sun/net/www/http/HttpURLConnection/PostOnDelete.java index 104be1d6d94..e785c426156 100644 --- a/test/jdk/sun/net/www/http/HttpURLConnection/PostOnDelete.java +++ b/test/jdk/sun/net/www/http/HttpURLConnection/PostOnDelete.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -49,7 +49,7 @@ public void runTest() throws Exception { try { s = new Server(); s.startServer(); - URL url = new URL("http://localhost:" + s.getPort()); + URL url = new URL("http://" + s.getAuthority()); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestMethod("DELETE"); urlConnection.setDoOutput(true); @@ -70,7 +70,8 @@ class Server { HttpServer server; public void startServer() { - InetSocketAddress addr = new InetSocketAddress(0); + InetAddress loopback = InetAddress.getLoopbackAddress(); + InetSocketAddress addr = new InetSocketAddress(loopback,0); try { server = HttpServer.create(addr, 0); } catch (IOException ioe) { @@ -81,6 +82,12 @@ public void startServer() { server.start(); } + public String getAuthority() { + String address = server.getAddress().getHostString(); + address = (address.indexOf(':') >= 0) ? ("[" + address + "]") : address; + return address + ":" + getPort(); + } + public int getPort() { return server.getAddress().getPort(); } From 6c6006eb49f2e769591567e4c646b7b6586114c1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:26:26 +0000 Subject: [PATCH 130/205] 8224024: java/util/concurrent/BlockingQueue/DrainToFails.java testBounded fails intermittently Backport-of: 22a4313efc832bf79a172f6e6c220302173533b0 --- .../concurrent/BlockingQueue/DrainToFails.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java index 0fc826a739e..45bb6811bfa 100644 --- a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java +++ b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java @@ -35,6 +35,7 @@ /* * @test * @summary Test drainTo failing due to c.add throwing + * @library /test/lib */ import java.util.ArrayList; @@ -50,9 +51,11 @@ import java.util.concurrent.RunnableScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import jdk.test.lib.Utils; @SuppressWarnings({"unchecked", "rawtypes"}) public class DrainToFails { + static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); final int CAPACITY = 10; final int SMALL = 2; @@ -169,7 +172,7 @@ void testBounded(final BlockingQueue q) throws Throwable { fail("should throw"); } catch (IllegalStateException success) { for (Thread putter : putters) { - putter.join(2000L); + putter.join(LONG_DELAY_MS); check(! putter.isAlive()); } assertContentsInOrder(q2, 2, 3); @@ -183,11 +186,10 @@ void testBounded(final BlockingQueue q) throws Throwable { } } - Runnable putter(final BlockingQueue q, final int elt) { - return new Runnable() { - public void run() { - try { q.put(elt); } - catch (Throwable t) { unexpected(t); }}}; + Runnable putter(BlockingQueue q, int elt) { + return () -> { + try { q.put(elt); } + catch (Throwable t) { unexpected(t); }}; } void assertContentsInOrder(Iterable it, Object... contents) { From 8773d465b90bbd663c60d0be9c5321026b9e3a85 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:28:01 +0000 Subject: [PATCH 131/205] 8223736: jvmti/scenarios/contention/TC04/tc04t001/TestDescription.java fails due to wrong number of MonitorContendedEntered events Fix the synchronization issue in the test Backport-of: fc6b87472cdad4a5d73ced2700ea799babcb48c3 --- .../scenarios/contention/TC04/tc04t001.java | 34 +++++++++++++++---- .../contention/TC04/tc04t001/tc04t001.cpp | 7 +++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java index 018cf664357..712ff82c2af 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -24,6 +24,7 @@ package nsk.jvmti.scenarios.contention.TC04; import java.io.PrintStream; +import java.util.concurrent.*; import nsk.share.*; import nsk.share.jvmti.*; @@ -31,6 +32,7 @@ public class tc04t001 extends DebugeeClass { final static int THREADS_LIMIT = 2; + final static CountDownLatch threadsDoneSignal = new CountDownLatch(THREADS_LIMIT); // run test from command line public static void main(String argv[]) { @@ -68,8 +70,8 @@ public int runIt(String argv[], PrintStream out) { } try { - for (int i = 0; i < THREADS_LIMIT; i++) { - threads[i].join(timeout/THREADS_LIMIT); + if (!threadsDoneSignal.await(timeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("Threads timeout"); } } catch (InterruptedException e) { throw new Failure(e); @@ -122,6 +124,8 @@ class tc04t001Thread extends Thread { */ private int id; + private static volatile int lastEnterEventsCount; + private static native int enterEventsCount(); public tc04t001Thread(int i) { super("Debuggee Thread " + i); @@ -131,11 +135,13 @@ public tc04t001Thread(int i) { public synchronized void run() { for (int i = 0; i < INCREMENT_LIMIT; i++) { flicker.waitFor(id); + lastEnterEventsCount = enterEventsCount(); increment(id); try { wait(1); } catch (InterruptedException e) {} } + tc04t001.threadsDoneSignal.countDown(); } static synchronized void increment(int i) { @@ -144,10 +150,24 @@ static synchronized void increment(int i) { */ flicker.unlock(i); int temp = value; - for (int j = 0; j < DELAY; j++) ; - try { - sleep(500); - } catch (InterruptedException e) {} + + // Wait in a loop for a MonitorContendedEnter event. + // Timeout is: 20ms * DELAY. + for (int j = 0; j < DELAY; j++) { + try { + sleep(20); + } catch (InterruptedException e) {} + + if (enterEventsCount() > lastEnterEventsCount) { + break; // Got an expected MonitorContendedEnter event + } + } + System.out.println("Thread-" + i + ": increment event: " + enterEventsCount()); + + if (enterEventsCount() == lastEnterEventsCount) { + String msg = "Timeout in waiting for a MonitorContendedEnter event"; + throw new RuntimeException(msg); + } value = temp + 1; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp index 325f47eda1e..718434ae275 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -344,6 +344,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_OK; } +JNIEXPORT jint JNICALL +Java_nsk_jvmti_scenarios_contention_TC04_tc04t001Thread_enterEventsCount(JNIEnv* jni, jclass klass) { + return enterEventsCount; +} + /* ========================================================================== */ } From 4c27fa059117b0068eb0066db4f7bda46f56f3dc Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:29:40 +0000 Subject: [PATCH 132/205] 8231595: [TEST] develop a test case for SuspendThreadList including current thread Extend test coverage for SuspendThreadList Backport-of: 40918999947d6763d3f6d592bcdf828503217901 --- .../SuspendWithCurrentThread.java | 222 ++++++++++++++++++ .../libSuspendWithCurrentThread.cpp | 209 +++++++++++++++++ 2 files changed, 431 insertions(+) create mode 100644 test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/SuspendWithCurrentThread.java create mode 100644 test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/SuspendWithCurrentThread.java b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/SuspendWithCurrentThread.java new file mode 100644 index 00000000000..a49147a9b8b --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/SuspendWithCurrentThread.java @@ -0,0 +1,222 @@ +/* + * 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 + * @bug 8231595 + * @summary [TEST] develop a test case for SuspendThreadList including current thread + * @library /test/lib + * @compile SuspendWithCurrentThread.java + * @run main/othervm/native -agentlib:SuspendWithCurrentThread SuspendWithCurrentThread SuspenderIndex=first + * @run main/othervm/native -agentlib:SuspendWithCurrentThread SuspendWithCurrentThread SuspenderIndex=last + */ + +import java.io.PrintStream; + +public class SuspendWithCurrentThread { + private static final String AGENT_LIB = "SuspendWithCurrentThread"; + private static final String SUSPENDER_OPT = "SuspenderIndex="; + private static final int THREADS_COUNT = 10; + + private static void log(String msg) { System.out.println(msg); } + + private static native void registerTestedThreads(Thread[] threads); + private static native boolean checkTestedThreadsSuspended(); + private static native void resumeTestedThreads(); + private static native void releaseTestedThreadsInfo(); + + // The suspender thread index defines the thread which has to suspend + // the tested threads including itself with the JVMTI SuspendThreadList + private static int suspenderIndex; + + public static void main(String args[]) throws Exception { + try { + System.loadLibrary(AGENT_LIB); + log("Loaded library: " + AGENT_LIB); + } catch (UnsatisfiedLinkError ule) { + log("Failed to load library: " + AGENT_LIB); + log("java.library.path: " + System.getProperty("java.library.path")); + throw ule; + } + if (args.length != 1) { + throw new RuntimeException("Main: wrong arguments count: " + args.length + ", expected: 1"); + } + String arg = args[0]; + if (arg.equals(SUSPENDER_OPT + "first")) { + suspenderIndex = 0; + } else if (arg.equals(SUSPENDER_OPT + "last")) { + suspenderIndex = THREADS_COUNT - 1; + } else { + throw new RuntimeException("Main: wrong argument: " + arg + ", expected: SuspenderIndex={first|last}"); + } + log("Main: suspenderIndex: " + suspenderIndex); + + SuspendWithCurrentThread test = new SuspendWithCurrentThread(); + test.run(); + } + + private ThreadToSuspend[] startTestedThreads(int threadsCount) throws RuntimeException { + ThreadToSuspend[]threads = new ThreadToSuspend[threadsCount]; + + // create tested threads + for (int i = 0; i < threads.length; i++) { + threads[i] = new ThreadToSuspend("ThreadToSuspend#" + i, + i == suspenderIndex // isSuspender + ); + } + log("Main: starting tested threads"); + for (int i = 0; i < threads.length; i++) { + threads[i].start(); + if (!threads[i].checkReady()) { + throw new RuntimeException("Main: unable to prepare tested thread: " + threads[i]); + } + } + log("Main: tested threads started"); + + registerTestedThreads(threads); + return threads; + } + + private boolean checkSuspendedStatus() throws RuntimeException { + log("Main: checking all tested threads have been suspended"); + return checkTestedThreadsSuspended(); + } + + /* The test does the following steps: + * - main thread starts several (THREADS_COUNT) ThreadToSuspend tested threads + * - main thread waits for threads to be ready with the thread.checkReady() + * - main thread registers tested threads within the native agent library + * with the native method registerTestedThreads() + * - main thread triggers the suspender tested thread with the + * ThreadToSuspend.setAllThreadsReady() to suspend tested threads + * - suspender thread suspends tested threads including itself with the native + * method suspendTestedThreads() (uses the JVMTI SuspendThreadList function) + * - main thread checks tested threads suspended status with the native method + * checkSuspendedStatus(); the tested threads are expected to have suspended status + * - main thread resumes tested threads with the native method resumeTestedThreads() + * - main thread releases tested threads with the native method releaseTestedThreads() + * - main thread triggers the tested threads to finish with the thread.letFinish() + */ + private void run() throws Exception { + ThreadToSuspend[] threads = null; // tested threads + + log("Main: started"); + try { + threads = startTestedThreads(THREADS_COUNT); + + log("Main: trigger " + threads[suspenderIndex].getName() + + " to suspend all tested threads including itself"); + ThreadToSuspend.setAllThreadsReady(); + + if (!checkSuspendedStatus()) { + throw new RuntimeException("Main: FAILED status returned from checkTestedThreadsSuspended"); + } + + log("Main: resuming all tested threads"); + resumeTestedThreads(); + } finally { + // let threads to finish + for (int i = 0; i < threads.length; i++) { + threads[i].letFinish(); + } + log("Main: tested threads finished"); + } + + // wait for threads to finish + log("Main: joining tested threads"); + try { + for (int i = 0; i < threads.length; i++) { + threads[i].join(); + } + log("Main: tested thread joined"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + log("Main: releasing tested threads native info"); + releaseTestedThreadsInfo(); + + log("Main: finished"); + } +} + +/* =================================================================== */ + +// tested threads +class ThreadToSuspend extends Thread { + private static void log(String msg) { System.out.println(msg); } + + private static native void init(); + private static native void suspendTestedThreads(); + private static volatile boolean allThreadsReady = false; + + public static void setAllThreadsReady() { + allThreadsReady = true; + } + + private volatile boolean threadReady = false; + private volatile boolean shouldFinish = false; + private boolean isSuspender = false; + + // make thread with specific name + public ThreadToSuspend(String name, boolean isSuspender) { + super(name); + this.isSuspender = isSuspender; + } + + // run thread continuously + public void run() { + boolean needSuspend = true; + + if (isSuspender) { + init(); + } + threadReady = true; + + // run in a loop + while (!shouldFinish) { + if (isSuspender && needSuspend && allThreadsReady) { + log(getName() + ": before suspending all tested threads including myself"); + needSuspend = false; + suspendTestedThreads(); + log(getName() + ": after suspending all tested threads including myself"); + } + } + } + + // check if thread is ready + public boolean checkReady() { + try { + while (!threadReady) { + sleep(1); + } + } catch (InterruptedException e) { + throw new RuntimeException("checkReady: sleep was interrupted\n\t" + e); + } + return threadReady; + } + + // let thread to finish + public void letFinish() { + shouldFinish = true; + } +} diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp new file mode 100644 index 00000000000..30316bd8470 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp @@ -0,0 +1,209 @@ +/* + * 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. + */ + +#include +#include "jvmti.h" + +extern "C" { + +static jvmtiEnv* jvmti = NULL; +static jthread* threads = NULL; +static jsize threads_count = 0; +static jrawMonitorID agent_monitor = NULL; + +#define LOG(...) \ + do { \ + printf(__VA_ARGS__); \ + printf("\n"); \ + fflush(stdout); \ + } while (0) + +static void +check_jvmti_status(JNIEnv* jni, jvmtiError err, const char* msg) { + if (err != JVMTI_ERROR_NONE) { + LOG("check_jvmti_status: JVMTI function returned error: %d", err); + jni->FatalError(msg); + } +} + +static void +agent_lock(JNIEnv* jni) { + jvmtiError err = jvmti->RawMonitorEnter(agent_monitor); + check_jvmti_status(jni, err, "monitor_enter: error in JVMTI RawMonitorEnter"); +} + +static void +agent_unlock(JNIEnv* jni) { + jvmtiError err = jvmti->RawMonitorExit(agent_monitor); + check_jvmti_status(jni, err, "monitor_exit: error in JVMTI RawMonitorExit"); +} + +JNIEXPORT void JNICALL +Java_SuspendWithCurrentThread_registerTestedThreads(JNIEnv *jni, jclass cls, jobjectArray threadsArr) { + LOG("\nregisterTestedThreads: started"); + threads_count = jni->GetArrayLength(threadsArr); + + jvmtiError err = jvmti->Allocate((threads_count * sizeof(jthread)), + (unsigned char**)&threads); + check_jvmti_status(jni, err, "registerTestedThreads: error in JVMTI Allocate threads array"); + + for (int i = 0; i < threads_count; i++) { + jobject elem = jni->GetObjectArrayElement(threadsArr, i); + threads[i] = (jthread)jni->NewGlobalRef(elem); + } + LOG("registerTestedThreads: finished\n"); +} + +/* This function is executed on the suspender thread, not the Main thread */ +JNIEXPORT void JNICALL +Java_ThreadToSuspend_init(JNIEnv *jni, jclass cls) { + jvmtiError err = jvmti->CreateRawMonitor("Agent monitor", &agent_monitor); + check_jvmti_status(jni, err, "Java_ThreadToSuspend_init: error in JVMTI CreateRawMonitor"); + + // Main thread has to wait for the suspender thread to complete tested threads suspension + agent_lock(jni); +} + +/* This function is executed on the suspender thread which is not Main thread */ +JNIEXPORT void JNICALL +Java_ThreadToSuspend_suspendTestedThreads(JNIEnv *jni, jclass cls) { + jvmtiError* results = NULL; + jvmtiError err; + + LOG("\nsuspendTestedThreads: started"); + err = jvmti->Allocate((threads_count * sizeof(jvmtiError)), + (unsigned char**)&results); + check_jvmti_status(jni, err, "suspendTestedThreads: error in JVMTI Allocate results array"); + + LOG("suspendTestedThreads: before JVMTI SuspendThreadList"); + err = jvmti->SuspendThreadList(threads_count, threads, results); + check_jvmti_status(jni, err, "suspendTestedThreads: error in JVMTI SuspendThreadList"); + + LOG("suspendTestedThreads: check and print SuspendThreadList results:"); + for (int i = 0; i < threads_count; i++) { + LOG(" thread #%d: (%d)", i, (int)results[i]); + check_jvmti_status(jni, results[i], "suspendTestedThreads: error in SuspendThreadList results[i]"); + } + LOG("suspendTestedThreads: finished\n"); + + // Allow the Main thread to inspect the result of tested threads suspension + agent_unlock(jni); + + err = jvmti->Deallocate((unsigned char*)results); + check_jvmti_status(jni, err, "suspendTestedThreads: error in JVMTI Deallocate results"); +} + +JNIEXPORT jboolean JNICALL +Java_SuspendWithCurrentThread_checkTestedThreadsSuspended(JNIEnv *jni, jclass cls) { + LOG("checkTestedThreadsSuspended: started"); + + // Block until the suspender thread competes the tested threads suspension + agent_lock(jni); + agent_unlock(jni); + + for (int i = 0; i < threads_count; i++) { + jint state = 0; + jvmtiError err = jvmti->GetThreadState(threads[i], &state); + check_jvmti_status(jni, err, "checkTestedThreadsSuspended: error in GetThreadState"); + + if ((state & JVMTI_THREAD_STATE_SUSPENDED) == 0) { + LOG("thread #%d has not been suspended yet: " + "# state: (%#x)", i, (int)state); + jni->FatalError("checkTestedThreadsSuspended: error: expected all tested threads suspended"); + } + } + LOG("checkTestedThreadsSuspended: finished\n"); + return JNI_TRUE; +} + +JNIEXPORT void JNICALL +Java_SuspendWithCurrentThread_resumeTestedThreads(JNIEnv *jni, jclass cls) { + jvmtiError* results = NULL; + jvmtiError err; + + LOG("\nresumeTestedThreads: started"); + err = jvmti->Allocate((threads_count * sizeof(jvmtiError)), + (unsigned char**)&results); + check_jvmti_status(jni, err, "resumeTestedThreads: error in JVMTI Allocate results array"); + + LOG("resumeTestedThreads: before JVMTI ResumeThreadList"); + err = jvmti->ResumeThreadList(threads_count, threads, results); + check_jvmti_status(jni, err, "resumeTestedThreads: error in ResumeThreadList"); + + LOG("resumeTestedThreads: check and print ResumeThreadList results:"); + for (int i = 0; i < threads_count; i++) { + LOG(" thread #%d: (%d)", i, (int)results[i]); + check_jvmti_status(jni, results[i], "resumeTestedThreads: error in ResumeThreadList results[i]"); + } + + err = jvmti->Deallocate((unsigned char*)results); + check_jvmti_status(jni, err, "resumeTestedThreads: error in JVMTI Deallocate results"); + + LOG("resumeTestedThreads: finished\n"); +} + +JNIEXPORT void JNICALL +Java_SuspendWithCurrentThread_releaseTestedThreadsInfo(JNIEnv *jni, jclass cls) { + jvmtiError err; + + LOG("\nreleaseTestedThreadsInfo: started"); + err = jvmti->DestroyRawMonitor(agent_monitor); + check_jvmti_status(jni, err, "releaseTestedThreadsInfo: error in JVMTI DestroyRawMonitor"); + + for (int i = 0; i < threads_count; i++) { + if (threads[i] != NULL) { + jni->DeleteGlobalRef(threads[i]); + } + } + err = jvmti->Deallocate((unsigned char*)threads); + check_jvmti_status(jni, err, "releaseTestedThreadsInfo: error in JVMTI Deallocate threads"); + + LOG("releaseTestedThreadsInfo: finished\n"); +} + + +/** Agent library initialization. */ + +JNIEXPORT jint JNICALL +Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { + LOG("\nAgent_OnLoad started"); + + // create JVMTI environment + if (jvm->GetEnv((void **) (&jvmti), JVMTI_VERSION) != JNI_OK) { + return JNI_ERR; + } + + // add specific capabilities for suspending thread + jvmtiCapabilities suspendCaps; + memset(&suspendCaps, 0, sizeof(suspendCaps)); + suspendCaps.can_suspend = 1; + + jvmtiError err = jvmti->AddCapabilities(&suspendCaps); + if (err != JVMTI_ERROR_NONE) { + return JNI_ERR; + } + LOG("Agent_OnLoad finished\n"); + return JNI_OK; +} + +} From 1f0e77e8d1b287f3d168d0af61bcafb3cea00d69 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 14 Feb 2023 20:31:23 +0000 Subject: [PATCH 133/205] 8295116: C2: assert(dead->outcnt() == 0 && !dead->is_top()) failed: node must be dead Backport-of: 94575d14f47e2dfb11b671bce26b69270b6bb3c8 --- src/hotspot/share/opto/ifnode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp index c61e66de086..ae553351ead 100644 --- a/src/hotspot/share/opto/ifnode.cpp +++ b/src/hotspot/share/opto/ifnode.cpp @@ -723,6 +723,7 @@ bool IfNode::is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn) { ctrl->in(0)->as_If()->cmpi_folds(igvn) && // Must compare same value ctrl->in(0)->in(1)->in(1)->in(1) != NULL && + ctrl->in(0)->in(1)->in(1)->in(1) != igvn->C->top() && ctrl->in(0)->in(1)->in(1)->in(1) == in(1)->in(1)->in(1); } From d7a6e6ae495a780c6818dd69ae240ac092e41504 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 15 Feb 2023 09:06:27 +0000 Subject: [PATCH 134/205] 8285093: Introduce UTIL_ARG_WITH 8285755: JDK-8285093 changed the default for --with-output-sync 8285919: Remove debug printout from JDK-8285093 Reviewed-by: mbaesken Backport-of: 5b77b574685ee043dfce2b5b17cb0f166b339485 --- make/autoconf/basic_tools.m4 | 54 +++--- make/autoconf/util.m4 | 348 +++++++++++++++++++++++++++++++++++ 2 files changed, 373 insertions(+), 29 deletions(-) diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index c39b87deecb..e2131029a54 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -156,25 +156,23 @@ AC_DEFUN([BASIC_CHECK_MAKE_VERSION], AC_DEFUN([BASIC_CHECK_MAKE_OUTPUT_SYNC], [ # Check if make supports the output sync option and if so, setup using it. - AC_MSG_CHECKING([if make --output-sync is supported]) - if $MAKE --version -O > /dev/null 2>&1; then - OUTPUT_SYNC_SUPPORTED=true - AC_MSG_RESULT([yes]) - AC_MSG_CHECKING([for output-sync value]) - AC_ARG_WITH([output-sync], [AS_HELP_STRING([--with-output-sync], - [set make output sync type if supported by make. @<:@recurse@:>@])], - [OUTPUT_SYNC=$with_output_sync]) - if test "x$OUTPUT_SYNC" = "x"; then - OUTPUT_SYNC=none - fi - AC_MSG_RESULT([$OUTPUT_SYNC]) - if ! $MAKE --version -O$OUTPUT_SYNC > /dev/null 2>&1; then - AC_MSG_ERROR([Make did not the support the value $OUTPUT_SYNC as output sync type.]) - fi - else - OUTPUT_SYNC_SUPPORTED=false - AC_MSG_RESULT([no]) - fi + UTIL_ARG_WITH(NAME: output-sync, TYPE: literal, + VALID_VALUES: [none recurse line target], DEFAULT: none, + OPTIONAL: true, ENABLED_DEFAULT: true, + ENABLED_RESULT: OUTPUT_SYNC_SUPPORTED, + CHECKING_MSG: [for make --output-sync value], + DESC: [set make --output-sync type if supported by make], + CHECK_AVAILABLE: + [ + AC_MSG_CHECKING([if make --output-sync is supported]) + if ! $MAKE --version -O > /dev/null 2>&1; then + AC_MSG_RESULT([no]) + AVAILABLE=false + else + AC_MSG_RESULT([yes]) + fi + ] + ) AC_SUBST(OUTPUT_SYNC_SUPPORTED) AC_SUBST(OUTPUT_SYNC) ]) @@ -372,17 +370,15 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], UTIL_REQUIRE_PROGS(XATTR, xattr) UTIL_LOOKUP_PROGS(CODESIGN, codesign) - if test "x$CODESIGN" != "x"; then - # Check for user provided code signing identity. - # If no identity was provided, fall back to "openjdk_codesign". - AC_ARG_WITH([macosx-codesign-identity], [AS_HELP_STRING([--with-macosx-codesign-identity], - [specify the code signing identity])], - [MACOSX_CODESIGN_IDENTITY=$with_macosx_codesign_identity], - [MACOSX_CODESIGN_IDENTITY=openjdk_codesign] - ) - - AC_SUBST(MACOSX_CODESIGN_IDENTITY) + # Check for user provided code signing identity. + UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, + DEFAULT: openjdk_codesign, CHECK_VALUE: UTIL_CHECK_STRING_NON_EMPTY, + DESC: [specify the macosx code signing identity], + CHECKING_MSG: [for macosx code signing identity] + ) + AC_SUBST(MACOSX_CODESIGN_IDENTITY) + if test "x$CODESIGN" != "x"; then # Verify that the codesign certificate is present AC_MSG_CHECKING([if codesign certificate is present]) $RM codesign-testfile diff --git a/make/autoconf/util.m4 b/make/autoconf/util.m4 index bb6bbe1c2da..5bf599e1e1f 100644 --- a/make/autoconf/util.m4 +++ b/make/autoconf/util.m4 @@ -469,3 +469,351 @@ UTIL_DEFUN_NAMED([UTIL_ARG_ENABLE], ARG_IF_DISABLED fi ]) + +############################################################################### +# Helper functions for ARG_WITH, to validate different types of argument + +# Dispatcher to call the correct UTIL_CHECK_TYPE_* function depending on the ARG_TYPE +AC_DEFUN([UTIL_CHECK_TYPE], +[ + UTIL_CHECK_TYPE_$1($2) +]) + +AC_DEFUN([UTIL_CHECK_TYPE_string], +[ + # All strings always passes +]) + +AC_DEFUN([UTIL_CHECK_TYPE_integer], +[ + # Check that the argument is an integer + # Additional [] needed to keep m4 from mangling shell constructs. + [ if [[ ! "$1" =~ ^[0-9]+$ ]] ; then ] + FAILURE="Not an integer: $1" + fi +]) + +AC_DEFUN([UTIL_CHECK_TYPE_file], +[ + # Check that the argument is an existing file + if test ! -f "$1" ; then + FAILURE="File $1 does not exist or is not readable" + fi +]) + +AC_DEFUN([UTIL_CHECK_TYPE_directory], +[ + # Check that the argument is an existing directory + if test ! -d "$1" ; then + FAILURE="Directory $1 does not exist or is not readable" + fi + + if test "[x]ARG_CHECK_FOR_FILES" != x; then + for file in ARG_CHECK_FOR_FILES; do + found_files=$($ECHO $(ls $1/$file 2> /dev/null)) + if test "x$found_files" = x; then + FAILURE="Directory $1 does not contain $file" + break + elif ! test -e "$found_files"; then + FAILURE="Directory $1 contains multiple $file: $found_files" + break + fi + done + fi +]) + +AC_DEFUN([UTIL_CHECK_TYPE_literal], +[ + # Check if it contains a space between non-space characters + # Additional [] needed to keep m4 from mangling shell constructs. + [ if [[ "$1" =~ [^' ']' '+[^' '] ]] ; then ] + FAILURE="Multiple words: $1" + fi + + # Check that the selected variants are valid + UTIL_GET_NON_MATCHING_VALUES(invalid_value, $1, \ + ARG_VALID_VALUES) + if test "x$invalid_value" != x; then + FAILURE="Invalid value: $invalid_value. Valid values are: ARG_VALID_VALUES" + fi +]) + +AC_DEFUN([UTIL_CHECK_TYPE_multivalue], +[ + # We accept either space or comma as separator, but use space internally + values=`$ECHO $1 | $SED -e 's/,/ /g'` + + # Check that the selected variants are valid + UTIL_GET_NON_MATCHING_VALUES(invalid_value, $values, \ + ARG_VALID_VALUES) + if test "x$invalid_value" != x; then + FAILURE="Invalid value(s): $invalid_value. Valid values are: ARG_VALID_VALUES" + fi + + # Update to version without comma + ARG_RESULT=$($ECHO $values) +]) + +AC_DEFUN([UTIL_CHECK_TYPE_features], +[ + # We accept either space or comma as separator, but use space internally + feature_list=`$ECHO $1 | $SED -e 's/,/ /g'` + features_enabled=`$ECHO $feature_list | \ + $AWK '{ for (i=1; i<=NF; i++) if (!match($i, /^-.*/)) printf("%s ", $i) }'` + features_disabled=`$ECHO $feature_list | \ + $AWK '{ for (i=1; i<=NF; i++) if (match($i, /^-.*/)) printf("%s ", substr($i, 2))}'` + + # Check that the selected features are valid + UTIL_GET_NON_MATCHING_VALUES(invalid_features, $features_enabled \ + $features_disabled, ARG_VALID_VALUES) + if test "x$invalid_features" != x; then + FAILURE="Invalid feature(s): $invalid_features. Valid values are: ARG_VALID_VALUES" + fi + + # Update to version without comma + ARG_RESULT=$($ECHO $feature_list) +]) + +############################################################################### +# Creates a command-line option using the --with-* pattern. Will return a +# string in the RESULT variable with the option provided by the user, or the +# empty string if the --with-* option was not given. The option can not be given +# if it is not available, as specified by AVAILABLE and/or CHECK_AVAILABLE. +# +# Arguments: +# NAME: The base name of this option (i.e. what follows --with-). Required. +# TYPE: The type of the value. Can be one of "string", "integer", "file", +# "directory", "literal", "multivalue" or "features". Required. +# DEFAULT: The default value for this option. Can be any valid string. +# Required. +# OPTIONAL: If this feature can be disabled. Defaults to false. If true, +# the feature can be disabled using --without-FOO, --with-FOO=no, or +# --with-FOO=. Check the ENABLED_RESULT variable for the enabled/disabled +# state. +# RESULT: The name of the variable to set to the result. Defaults to +# . Set to empty if ENABLED_RESULT is false. +# ENABLED_DEFAULT: If the value is enabled by default. Defaults to false. Only +# relevant if OPTIONAL is true. +# ENABLED_RESULT: The name of the variable to set to the enabled/disabled +# result state. Defaults to _ENABLED. +# AVAILABLE: If true, this option is allowed to be selected. Defaults to true. +# DESC: A description of this option. Defaults to a generic and unhelpful +# string. +# DEFAULT_DESC: A message describing the default value, for the help. Defaults +# to the literal value of DEFAULT, or "" if DEFAULT is empty. +# CHECKING_MSG: The message to present to user when checking this option. +# Defaults to a generic message. +# CHECK_AVAILABLE: An optional code block to execute to determine if the +# option should be available. Must set AVAILABLE to 'false' if not. +# VALID_VALUES: A list of literals that are the allowed values. Only valid if +# TYPE is "literal", "multivalue" or "features". +# CHECK_VALUE: An optional code block to execute to determine if the value +# is correct. Must set FAILURE to a non-empty string if not. This string +# will be displayed. The value is given in $RESULT. +# CHECK_FOR_FILES: A list of files to verify the presence for. Only valid if +# TYPE is "directory". Paths are relative the directory given as value. +# Wildcards are accepted. Exactly one matching file must be found, for each +# listed file, or FAILURE is set. +# IF_AUTO: An optional code block to execute if the value is "auto", either by +# default or given by the command line. Must set RESULT to the calculated +# value. +# IF_GIVEN: An optional code block to execute if the option was given on the +# command line (regardless of the value). +# IF_NOT_GIVEN: An optional code block to execute if the option was not given +# on the command line (regardless of the value). +# +UTIL_DEFUN_NAMED([UTIL_ARG_WITH], + [*NAME *TYPE *DEFAULT OPTIONAL RESULT ENABLED_DEFAULT ENABLED_RESULT + AVAILABLE DESC DEFAULT_DESC CHECKING_MSG CHECK_AVAILABLE VALID_VALUES + CHECK_VALUE CHECK_FOR_FILES IF_AUTO IF_GIVEN IF_NOT_GIVEN], [$@], +[ + ########################## + # Part 1: Set up m4 macros + ########################## + + # If ENABLED_DEFAULT is not specified, set it to 'false'. + m4_define([ARG_ENABLED_DEFAULT], m4_if(ARG_ENABLED_DEFAULT, , false, ARG_ENABLED_DEFAULT)) + + # If AVAILABLE is not specified, set it to 'true'. + m4_define([ARG_AVAILABLE], m4_if(ARG_AVAILABLE, , true, ARG_AVAILABLE)) + + # If OPTIONAL is not specified, set it to 'false'. + m4_define([ARG_OPTIONAL], m4_if(ARG_OPTIONAL, , false, ARG_OPTIONAL)) + + # If DEFAULT_DESC is not specified, calculate it from DEFAULT. + m4_define([ARG_DEFAULT_DESC], m4_if(ARG_DEFAULT_DESC, , m4_if(ARG_DEFAULT, , , ARG_DEFAULT), ARG_DEFAULT_DESC)) + + # If RESULT is not specified, set it to 'ARG_NAME'. + m4_define([ARG_RESULT], m4_if(ARG_RESULT, , m4_translit(ARG_NAME, [a-z-], [A-Z_]), ARG_RESULT)) + + # If ENABLED_RESULT is not specified, set it to 'ARG_NAME[_ENABLED]'. + m4_define([ARG_ENABLED_RESULT], m4_if(ARG_ENABLED_RESULT, , m4_translit(ARG_NAME, [a-z-], [A-Z_])[_ENABLED], ARG_ENABLED_RESULT)) + + # Construct shell variable names for the option + m4_define(ARG_OPTION, [with_]m4_translit(ARG_NAME, [-], [_])) + m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN]) + + # If DESC is not specified, set it to a generic description. + m4_define([ARG_DESC], m4_if(ARG_DESC, , [Give a value for the ARG_NAME feature], m4_normalize(ARG_DESC))) + + # If CHECKING_MSG is not specified, set it to a generic description. + m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --with-ARG_NAME], m4_normalize(ARG_CHECKING_MSG))) + + m4_define([ARG_HAS_AUTO_BLOCK], m4_if(ARG_IF_AUTO, , false, true)) + + # If the code blocks are not given, set them to the empty statements to avoid + # tripping up bash. + m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE)) + m4_define([ARG_CHECK_VALUE], m4_if(ARG_CHECK_VALUE, , :, ARG_CHECK_VALUE)) + m4_define([ARG_CHECK_FOR_FILES], m4_if(ARG_CHECK_FOR_FILES, , :, ARG_CHECK_FOR_FILES)) + m4_define([ARG_IF_AUTO], m4_if(ARG_IF_AUTO, , :, ARG_IF_AUTO)) + m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN)) + m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN)) + + ########################## + # Part 2: Set up autoconf shell code + ########################## + + # Check that OPTIONAL has a valid value + if test "[x]ARG_OPTIONAL" != xtrue && test "[x]ARG_OPTIONAL" != xfalse ; then + AC_MSG_ERROR([Internal error: Argument OPTIONAL to [UTIL_ARG_WITH] can only be true or false, was: 'ARG_OPTIONAL']) + fi + + # Check that ENABLED_DEFAULT has a valid value + if test "[x]ARG_ENABLED_DEFAULT" != xtrue && test "[x]ARG_ENABLED_DEFAULT" != xfalse ; then + AC_MSG_ERROR([Internal error: Argument ENABLED_DEFAULT to [UTIL_ARG_WITH] can only be true or false, was: 'ARG_ENABLED_DEFAULT']) + fi + + # Check that AVAILABLE has a valid value + if test "[x]ARG_AVAILABLE" != xtrue && test "[x]ARG_AVAILABLE" != xfalse; then + AC_MSG_ERROR([Internal error: Argument AVAILABLE to [UTIL_ARG_WITH] can only be true or false, was: 'ARG_AVAILABLE']) + fi + + # Check that TYPE has a valid value + # Need to assign since we can't expand ARG TYPE inside the m4 quoted if statement + TEST_TYPE="ARG_TYPE" + # Additional [] needed to keep m4 from mangling shell constructs. + [ if [[ ! "$TEST_TYPE" =~ ^(string|integer|file|directory|literal|multivalue|features)$ ]] ; then ] + AC_MSG_ERROR([Internal error: Argument TYPE to [UTIL_ARG_WITH] must be a valid type, was: 'ARG_TYPE']) + fi + + AC_ARG_WITH(ARG_NAME, AS_HELP_STRING([--with-]ARG_NAME, + [ARG_DESC [ARG_DEFAULT_DESC]]), [ARG_GIVEN=true], [ARG_GIVEN=false]) + + # Check if the option is available + AVAILABLE=ARG_AVAILABLE + # Run the available check block (if any), which can overwrite AVAILABLE. + ARG_CHECK_AVAILABLE + + # Check if the option should be turned on + AC_MSG_CHECKING(ARG_CHECKING_MSG) + + if test x$AVAILABLE = xfalse; then + ARG_RESULT="$ARG_OPTION" + ARG_ENABLED_RESULT=false + REASON="not available" + else + if test x$ARG_GIVEN = xfalse; then + ARG_RESULT="ARG_DEFAULT" + if test "[x]ARG_OPTIONAL" = xtrue; then + ARG_ENABLED_RESULT=ARG_ENABLED_DEFAULT + else + ARG_ENABLED_RESULT=true + fi + REASON="default" + + else # ARG_GIVEN is true + # Special treatment of "yes" and "no" for "--with-ARG" and "--without-ARG" + if test "x$ARG_OPTION" = xyes || test "x$ARG_OPTION" = xno || test "x$ARG_OPTION" = x ; then + if test "[x]ARG_OPTIONAL" = xfalse; then + if test "x$ARG_OPTION" = x; then + # If not optional, the empty string is a valid value + ARG_RESULT="" + ARG_ENABLED_RESULT=true + REASON="from command line" + else + AC_MSG_RESULT([invalid]) + AC_MSG_ERROR([Option [--with-]ARG_NAME must have a specified value]) + fi + else + if test "x$ARG_OPTION" = xyes; then + ARG_RESULT="ARG_DEFAULT" + ARG_ENABLED_RESULT=true + REASON="default as enabled from command line" + else + # For optional values, both --without-FOO and --with-FOO= disables + ARG_RESULT="" + ARG_ENABLED_RESULT=false + REASON="from command line" + fi + fi + else + # The most common case -- the user gives a value for the option. + ARG_RESULT="$ARG_OPTION" + ARG_ENABLED_RESULT=true + REASON="from command line" + fi + fi + fi + + if test "x$ARG_ENABLED_RESULT" = xfalse; then + if test "x$REASON" = "xnot available"; then + AC_MSG_RESULT([, $REASON]) + if test "x$ARG_RESULT" != "x" && test "x$ARG_RESULT" != "xno" ; then + AC_MSG_WARN([Option [--with-]ARG_NAME is not available for this configuration]) + fi + else + AC_MSG_RESULT([, $REASON]) + fi + ARG_RESULT="" + else + if test [x]ARG_HAS_AUTO_BLOCK = xtrue && test "x$ARG_RESULT" = xauto; then + # Execute "auto" payload + ARG_IF_AUTO + + ARG_RESULT="$RESULT" + REASON="$REASON (calculated from 'auto')" + fi + + if test "x$ARG_RESULT" = x; then + AC_MSG_RESULT([, $REASON]) + else + AC_MSG_RESULT([$ARG_RESULT, $REASON]) + fi + fi + + # Verify value + # First use our dispatcher to verify that type requirements are satisfied + UTIL_CHECK_TYPE(ARG_TYPE, $ARG_RESULT) + + if test "x$FAILURE" = x; then + # Execute custom verification payload, if present + RESULT="$ARG_RESULT" + + ARG_CHECK_VALUE + + ARG_RESULT="$RESULT" + fi + + if test "x$FAILURE" != x; then + AC_MSG_NOTICE([Invalid value for [--with-]ARG_NAME: "$ARG_RESULT"]) + AC_MSG_NOTICE([$FAILURE]) + AC_MSG_ERROR([Cannot continue]) + fi + + # Execute result payloads, if present + if test x$ARG_GIVEN = xtrue; then + ARG_IF_GIVEN + else + ARG_IF_NOT_GIVEN + fi +]) + +############################################################################### +# Helper functions for CHECK_VALUE in ARG_WITH. +AC_DEFUN([UTIL_CHECK_STRING_NON_EMPTY], +[ + if test "x$RESULT" = "x"; then + FAILURE="Value cannot be empty" + fi +]) From b096b9d92d4d3225aa26fa5cd57fd0a647bca591 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 15 Feb 2023 13:56:10 +0000 Subject: [PATCH 135/205] 8289562: Change bugs.java.com and bugreport.java.com URL's to https Reviewed-by: mbaesken Backport-of: 1f484dae4efaa60cf18a3d4df947c05f1497bd5b --- src/java.desktop/macosx/native/libosxapp/AWT_debug.h | 2 +- .../classes/com/sun/tools/javac/resources/javac.properties | 4 ++-- .../classes/com/sun/tools/javac/resources/javac_ja.properties | 2 +- .../com/sun/tools/javac/resources/javac_zh_CN.properties | 2 +- .../internal/doclets/toolkit/resources/doclets.properties | 2 +- .../internal/doclets/toolkit/resources/doclets_ja.properties | 2 +- .../doclets/toolkit/resources/doclets_zh_CN.properties | 2 +- .../jdk/javadoc/internal/tool/resources/javadoc.properties | 2 +- .../jdk/javadoc/internal/tool/resources/javadoc_ja.properties | 2 +- .../javadoc/internal/tool/resources/javadoc_zh_CN.properties | 2 +- .../share/classes/jdk/tools/jlink/resources/jlink.properties | 2 +- .../classes/jdk/tools/jlink/resources/jlink_ja.properties | 2 +- .../classes/jdk/tools/jlink/resources/jlink_zh_CN.properties | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/java.desktop/macosx/native/libosxapp/AWT_debug.h b/src/java.desktop/macosx/native/libosxapp/AWT_debug.h index 99fc0bf58aa..04af7eecd64 100644 --- a/src/java.desktop/macosx/native/libosxapp/AWT_debug.h +++ b/src/java.desktop/macosx/native/libosxapp/AWT_debug.h @@ -39,7 +39,7 @@ bool ShouldPrintVerboseDebugging(); if (ShouldPrintVerboseDebugging()) AWT_DEBUG_LOG((str)) #define AWT_DEBUG_BUG_REPORT_MESSAGE \ - NSLog(@"\tPlease file a bug report at http://bugreport.java.com/bugreport \ + NSLog(@"\tPlease file a bug report at https://bugreport.java.com/bugreport \ with this message and a reproducible test case.") #endif diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index c45d93a3fcc..39fc113a7fd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -350,8 +350,8 @@ These extra options are subject to change without notice. javac.msg.bug=\ An exception has occurred in the compiler ({0}). \ -Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \ -after checking the Bug Database (http://bugs.java.com) for duplicates. \ +Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) \ +after checking the Bug Database (https://bugs.java.com) for duplicates. \ Include your program and the following diagnostic in your report. Thank you. javac.msg.io=\ diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties index caf06796063..c2f6535fce5 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties @@ -202,7 +202,7 @@ javac.msg.usage=\u4F7F\u7528\u65B9\u6CD5: {0} \n\u4F7F\u javac.msg.usage.nonstandard.footer=\u3053\u306E\u8FFD\u52A0\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 -javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Database (http://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8(http://bugreport.java.com)\u3067Java\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Database (https://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8(https://bugreport.java.com)\u3067Java\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties index 66b41b980b1..6ccf38282cf 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties @@ -202,7 +202,7 @@ javac.msg.usage=\u7528\u6CD5: {0} <\u9009\u9879> <\u6E90\u6587\u4EF6>\n\u4F7F\u7 javac.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u989D\u5916\u9009\u9879\u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002 -javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Bug Database (http://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (http://bugreport.java.com) \u5EFA\u7ACB\u8BE5 Java \u7F16\u8BD1\u5668 Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Bug Database (https://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (https://bugreport.java.com) \u5EFA\u7ACB\u8BE5 Java \u7F16\u8BD1\u5668 Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 javac.msg.io=\n\n\u53D1\u751F\u8F93\u5165/\u8F93\u51FA\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties index 88f54e39f23..8554bedfcd6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties @@ -26,7 +26,7 @@ doclet.internal.exception=An internal exception has occurred. \n\ \t({0}) doclet.internal.report.bug=\ Please file a bug against the javadoc tool via the Java bug reporting page\n\ -(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)\n\ +(https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com)\n\ for duplicates. Include error messages and the following diagnostic in your report. Thank you. doclet.File_not_found=File not found: {0} doclet.Copy_Overwrite_warning=File {0} not copied to {1} due to existing file with same name... diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties index e1ef2ed90c1..97fdccb95bc 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties @@ -20,7 +20,7 @@ doclet.exception.read.file=\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u4E2 doclet.exception.write.file=\u30D5\u30A1\u30A4\u30EB\u306E\u66F8\u8FBC\u307F\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\n\t({1}) doclet.exception.read.resource=\u30B7\u30B9\u30C6\u30E0\u30FB\u30EA\u30BD\u30FC\u30B9\u306E\u8AAD\u53D6\u308A\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\n\t({1}) doclet.internal.exception=\u5185\u90E8\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002 \n\t({0}) -doclet.internal.report.bug=Bug Database (http://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8\n(http://bugreport.java.com)\u3067javadoc\u30C4\u30FC\u30EB\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\n\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u30A8\u30E9\u30FC\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +doclet.internal.report.bug=Bug Database (https://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8\n(https://bugreport.java.com)\u3067javadoc\u30C4\u30FC\u30EB\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\n\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u30A8\u30E9\u30FC\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 doclet.File_not_found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} doclet.Copy_Overwrite_warning=\u30D5\u30A1\u30A4\u30EB{0}\u306F\u540C\u3058\u540D\u524D\u306E\u30D5\u30A1\u30A4\u30EB\u304C\u3042\u308B\u306E\u3067{1}\u306B\u30B3\u30D4\u30FC\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F... doclet.Copying_File_0_To_Dir_1=\u30D5\u30A1\u30A4\u30EB{0}\u3092\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{1}\u306B\u30B3\u30D4\u30FC\u4E2D... diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties index 3dfa8a3c6aa..30afe118c91 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties @@ -20,7 +20,7 @@ doclet.exception.read.file=\u8BFB\u53D6\u6587\u4EF6\u65F6\u51FA\u9519: {0}\n\t({ doclet.exception.write.file=\u5199\u5165\u6587\u4EF6\u65F6\u51FA\u9519: {0}\n\t({1}) doclet.exception.read.resource=\u8BFB\u53D6\u7CFB\u7EDF\u8D44\u6E90\u65F6\u51FA\u9519: {0}\n\t({1}) doclet.internal.exception=\u51FA\u73B0\u5185\u90E8\u5F02\u5E38\u9519\u8BEF\u3002\n\t({0}) -doclet.internal.report.bug=\u5982\u679C\u5728 Bug Database (http://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u91CD\u590D\u9879, \n\u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (http://bugreport.java.com) \u9488\u5BF9\u8BE5 \njavadoc \u5DE5\u5177\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u9519\u8BEF\u6D88\u606F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +doclet.internal.report.bug=\u5982\u679C\u5728 Bug Database (https://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u91CD\u590D\u9879, \n\u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (https://bugreport.java.com) \u9488\u5BF9\u8BE5 \njavadoc \u5DE5\u5177\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u9519\u8BEF\u6D88\u606F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 doclet.File_not_found=\u627E\u4E0D\u5230\u6587\u4EF6: {0} doclet.Copy_Overwrite_warning=\u672A\u5C06\u6587\u4EF6{0}\u590D\u5236\u5230 {1}, \u56E0\u4E3A\u73B0\u6709\u6587\u4EF6\u5177\u6709\u76F8\u540C\u540D\u79F0... doclet.Copying_File_0_To_Dir_1=\u6B63\u5728\u5C06\u6587\u4EF6{0}\u590D\u5236\u5230\u76EE\u5F55 {1}... diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties index aef51de0bec..88450670733 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties @@ -297,7 +297,7 @@ main.internal.error=an internal error has occurred main.unexpected.exception=an unexpected exception was caught: {0} doclet.internal.report.bug=\ Please file a bug against the javadoc tool via the Java bug reporting page\n\ -(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)\n\ +(https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com)\n\ for duplicates. Include error messages and the following diagnostic in your report. Thank you. main.legacy_api=The old Doclet and Taglet APIs in the packages\n\ com.sun.javadoc, com.sun.tools.doclets and their implementations\n\ diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties index 728f1d86682..69452f7fecf 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties @@ -186,7 +186,7 @@ main.assertion.error=\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u304C\u5931\u6557\u305 main.unknown.error=\u4E0D\u660E\u306A\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F main.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F main.unexpected.exception=\u4E88\u671F\u3057\u306A\u3044\u4F8B\u5916\u304C\u6355\u6349\u3055\u308C\u307E\u3057\u305F: {0} -doclet.internal.report.bug=Bug Database (http://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8\n(http://bugreport.java.com)\u3067javadoc\u30C4\u30FC\u30EB\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\n\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u30A8\u30E9\u30FC\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +doclet.internal.report.bug=Bug Database (https://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8\n(https://bugreport.java.com)\u3067javadoc\u30C4\u30FC\u30EB\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\n\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u30A8\u30E9\u30FC\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 main.legacy_api=\u30D1\u30C3\u30B1\u30FC\u30B8com.sun.javadoc\u3001com.sun.tools.doclets\u304A\u3088\u3073\n\u305D\u308C\u3089\u306E\u5B9F\u88C5\u5185\u306E\u53E4\u3044Doclet\u304A\u3088\u3073Taglet API\u306F\u3001\n\u4ECA\u5F8C\u306EJDK\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\u3002\u3053\u308C\u3089\u306E\n\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306Fjdk.javadoc.doclet\u306E\u65B0\u3057\u3044API\u306B\u3088\u3063\u3066\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002\n\u30E6\u30FC\u30B6\u30FC\u306B\u306F\u65B0\u3057\u3044API\u306B\u79FB\u884C\u3059\u308B\u3053\u3068\u3092\u5F37\u304F\u304A\u85A6\u3081\u3057\u307E\u3059\u3002\n javadoc.class_not_found=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties index f002ecdd204..2b55ac50eed 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties @@ -186,7 +186,7 @@ main.assertion.error=\u65AD\u8A00\u5931\u8D25: "{0}}" main.unknown.error=\u51FA\u73B0\u672A\u77E5\u9519\u8BEF main.internal.error=\u51FA\u73B0\u5185\u90E8\u9519\u8BEF main.unexpected.exception=\u6355\u83B7\u5230\u610F\u5916\u7684\u5F02\u5E38\u9519\u8BEF: {0} -doclet.internal.report.bug=\u5982\u679C\u5728 Bug Database (http://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u91CD\u590D\u9879, \n\u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (http://bugreport.java.com) \u9488\u5BF9\u8BE5 \njavadoc \u5DE5\u5177\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u9519\u8BEF\u6D88\u606F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +doclet.internal.report.bug=\u5982\u679C\u5728 Bug Database (https://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u91CD\u590D\u9879, \n\u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (https://bugreport.java.com) \u9488\u5BF9\u8BE5 \njavadoc \u5DE5\u5177\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u9519\u8BEF\u6D88\u606F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 main.legacy_api=\u5DF2\u8BA1\u5212\u5728\u672A\u6765\u7684 JDK \u53D1\u884C\u7248\u4E2D\u5220\u9664\u7A0B\u5E8F\u5305\ncom.sun.javadoc, com.sun.tools.doclets\n\u53CA\u5176\u5B9E\u73B0\u4E2D\u7684\u65E7 Doclet \u548C Taglet API\u3002\n\u8FD9\u4E9B\u7EC4\u4EF6\u5728 jdk.javadoc.doclet \u4E2D\u5DF2\u7531\u65B0 API \u53D6\u4EE3\u3002\n\u5F3A\u70C8\u5EFA\u8BAE\u7528\u6237\u8FC1\u79FB\u5230\u65B0 API\u3002\n javadoc.class_not_found=\u627E\u4E0D\u5230\u7C7B{0}\u3002 diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index 0353896d660..588b20226be 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -86,7 +86,7 @@ main.opt.verbose=\ main.msg.bug=\ An exception has occurred in jlink. \ -Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \ +Please file a bug at the Java Bug Database (https://bugreport.java.com/bugreport/) \ after checking the database for duplicates. \ Include your program and the following diagnostic in your report. Thank you. diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_ja.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_ja.properties index f07aea1cccb..09661b8c85e 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_ja.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_ja.properties @@ -55,7 +55,7 @@ main.opt.ignore-signing-information=\ --ignore-signing-information \u7 main.opt.verbose=\ -v\u3001--verbose \u8A73\u7D30\u306A\u30C8\u30EC\u30FC\u30B9\u3092\u6709\u52B9\u306B\u3057\u307E\u3059 -main.msg.bug=jlink\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Bug Database (http://bugreport.java.com/bugreport/)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +main.msg.bug=jlink\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Bug Database (https://bugreport.java.com/bugreport/)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u6B21\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 main.extended.help=\u4F7F\u7528\u53EF\u80FD\u306A\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30EA\u30B9\u30C8: diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_zh_CN.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_zh_CN.properties index 7666581bb4e..7d1300f031b 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_zh_CN.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_zh_CN.properties @@ -55,7 +55,7 @@ main.opt.ignore-signing-information=\ --ignore-signing-information \ main.opt.verbose=\ -v, --verbose \u542F\u7528\u8BE6\u7EC6\u8DDF\u8E2A -main.msg.bug=jlink \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Java Bug Database (http://bugreport.java.com/bugreport/) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728\u8BE5\u6570\u636E\u5E93\u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +main.msg.bug=jlink \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Java Bug Database (https://bugreport.java.com/bugreport/) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728\u8BE5\u6570\u636E\u5E93\u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 main.extended.help=\u53EF\u7528\u63D2\u4EF6\u5217\u8868: From 6678084b221ea47d57b68b89af5473e7aeeba12a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 15 Feb 2023 13:56:59 +0000 Subject: [PATCH 136/205] 8279614: The left line of the TitledBorder is not painted on 150 scale factor Backport-of: b42c1ad1086a5c3f579e27380d23f67f8cebb437 --- .../javax/swing/border/EtchedBorder.java | 82 ++++++- .../EtchedBorder/ScaledEtchedBorderTest.java | 232 ++++++++++++++++++ 2 files changed, 301 insertions(+), 13 deletions(-) create mode 100644 test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java diff --git a/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java b/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java index e9f979faef3..02ec4c0fccc 100644 --- a/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java +++ b/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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,11 +24,14 @@ */ package javax.swing.border; +import java.awt.BasicStroke; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.Rectangle; import java.awt.Color; import java.awt.Component; +import java.awt.Stroke; +import java.awt.geom.AffineTransform; import java.beans.ConstructorProperties; /** @@ -119,6 +122,22 @@ public EtchedBorder(int etchType, Color highlight, Color shadow) { this.shadow = shadow; } + private void paintBorderHighlight(Graphics g, Color c, int w, int h, int stkWidth) { + g.setColor(c); + g.drawRect(stkWidth/2, stkWidth/2, w-(2*stkWidth), h-(2*stkWidth)); + } + + private void paintBorderShadow(Graphics g, Color c, int w, int h, int stkWidth) { + g.setColor(c); + g.drawLine(((3*stkWidth)/2), h-((3*stkWidth)/2), ((3*stkWidth)/2), ((3*stkWidth)/2)); // left line + g.drawLine(((3*stkWidth)/2), ((3*stkWidth)/2), w-((3*stkWidth)/2), ((3*stkWidth)/2)); // top line + + g.drawLine((stkWidth/2), h-(stkWidth-stkWidth/2), + w-(stkWidth-stkWidth/2), h-(stkWidth-stkWidth/2)); // bottom line + g.drawLine(w-(stkWidth-stkWidth/2), h-(stkWidth-stkWidth/2), + w-(stkWidth-stkWidth/2), stkWidth/2); // right line + } + /** * Paints the border for the specified component with the * specified position and size. @@ -131,22 +150,59 @@ public EtchedBorder(int etchType, Color highlight, Color shadow) { * @param height the height of the painted border */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - int w = width; - int h = height; + // We remove any initial transforms to prevent rounding errors + // when drawing in non-integer scales + AffineTransform at = null; + Stroke oldStk = null; + int stkWidth = 1; + boolean resetTransform = false; + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + at = g2d.getTransform(); + 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 = (int) Math.floor(Math.min(at.getScaleX(), at.getScaleY())); + g2d.setStroke(new BasicStroke((float) stkWidth)); + } + } - g.translate(x, y); + int w; + int h; + int xtranslation; + int ytranslation; + if (resetTransform) { + w = (int) Math.floor(at.getScaleX() * width - 1); + h = (int) Math.floor(at.getScaleY() * height - 1); + xtranslation = (int) Math.ceil(at.getScaleX()*x+at.getTranslateX()); + ytranslation = (int) Math.ceil(at.getScaleY()*y+at.getTranslateY()); + } else { + w = width; + h = height; + xtranslation = x; + ytranslation = y; + } - g.setColor(etchType == LOWERED? getShadowColor(c) : getHighlightColor(c)); - g.drawRect(0, 0, w-2, h-2); + g.translate(xtranslation, ytranslation); - g.setColor(etchType == LOWERED? getHighlightColor(c) : getShadowColor(c)); - g.drawLine(1, h-3, 1, 1); - g.drawLine(1, 1, w-3, 1); + paintBorderShadow(g, (etchType == LOWERED) ? getHighlightColor(c) + : getShadowColor(c), + w, h, stkWidth); + paintBorderHighlight(g, (etchType == LOWERED) ? getShadowColor(c) + : getHighlightColor(c), + w, h, stkWidth); - g.drawLine(0, h-1, w-1, h-1); - g.drawLine(w-1, h-1, w-1, 0); + g.translate(-xtranslation, -ytranslation); - g.translate(-x, -y); + // Set the transform we removed earlier + if (resetTransform) { + Graphics2D g2d = (Graphics2D) g; + g2d.setTransform(at); + g2d.setStroke(oldStk); + } } /** diff --git a/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java b/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java new file mode 100644 index 00000000000..e1eb17414c6 --- /dev/null +++ b/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java @@ -0,0 +1,232 @@ +/* + * 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 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.Graphics2D; +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 8279614 + * @summary The left line of the TitledBorder is not painted on 150 scale factor + * @requires (os.family == "windows") + * @run main ScaledEtchedBorderTest + */ + +public class ScaledEtchedBorderTest { + + public static final Dimension SIZE = new Dimension(120, 20); + + public static Color highlight = Color.RED; + public static Color shadow = Color.BLUE; + + private static final double[] scales = + {1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00}; + + private static final List images = + new ArrayList<>(scales.length); + + private static final List panelLocations = + new ArrayList<>(4); + + public static void main(String[] args) throws Exception { + boolean showFrame = args.length > 0 && "-show".equals(args[0]); + SwingUtilities.invokeAndWait(() -> testScaling(showFrame)); + } + + private static void testScaling(boolean show) { + createGUI(show); + + for (int i = 0; i < scales.length; i++) { + BufferedImage img = images.get(i); + double scaling = scales[i]; + System.out.println("Testing scaling: " + scaling); + + + // checking vertical border + int x = SIZE.width / 2; + checkVerticalBorder(x, img, scaling); + + for (Point p : panelLocations) { + int y = (int) (p.y * scaling) + SIZE.height / 2; + checkHorizontalBorder(y, img, scaling); + } + } + } + + private static void checkHorizontalBorder(int y, BufferedImage img, double scaling) { + int thickness = 0; + boolean checkShadow = false; + boolean checkHighlight = false; + for (int x = 0; x < img.getWidth(); x++) { + int color = img.getRGB(x, y); + if (!checkHighlight && !checkShadow) { + if (color == shadow.getRGB()) { + checkHighlight = true; + thickness++; + } else if (color == highlight.getRGB()) { + throw new RuntimeException("Horizontal Border was clipped or overdrawn."); + } + } else if (checkHighlight) { + if (color == shadow.getRGB()) { + thickness++; + } else if (color == highlight.getRGB()) { + verifyThickness(x, y, thickness, scaling, "Horizontal"); + checkHighlight = false; + checkShadow = true; + thickness = 1; + } else { + throw new RuntimeException("Horizontal Border has empty space between highlight and shadow."); + } + } else { + if (color == shadow.getRGB()) { + throw new RuntimeException("Border colors reversed."); + } else if (color == highlight.getRGB()) { + thickness++; + } else { + verifyThickness(x, y, thickness, scaling, "Horizontal"); + checkShadow = false; + thickness = 0; + } + } + } + } + + private static void verifyThickness(int x, int y, int thickness, double scaling, String orientation) { + int expected = (int) Math.floor(scaling); + if (thickness != expected) { + throw new RuntimeException("Unexpected " + orientation + " Border thickness at x:" + + x + " y: " + y + ". Expected: " + expected + " Actual: " + thickness); + } + } + + private static void checkVerticalBorder(int x, BufferedImage img, double scaling) { + int thickness = 0; + boolean checkShadow = false; + boolean checkHighlight = false; + for (int y = 0; y < img.getHeight(); y++) { + int color = img.getRGB(x, y); + if (!checkHighlight && !checkShadow) { + if (color == shadow.getRGB()) { + checkHighlight = true; + thickness++; + } else if (color == highlight.getRGB()) { + throw new RuntimeException("Vertical Border was clipped or overdrawn."); + } + } else if (checkHighlight) { + if (color == shadow.getRGB()) { + thickness++; + } else if (color == highlight.getRGB()) { + verifyThickness(x, y, thickness, scaling, "Vertical"); + checkHighlight = false; + checkShadow = true; + thickness = 1; + } else { + throw new RuntimeException("Vertical Border has empty space between highlight and shadow."); + } + } else { + if (color == shadow.getRGB()) { + throw new RuntimeException("Border colors reversed."); + } else if (color == highlight.getRGB()) { + thickness++; + } else { + verifyThickness(x, y, thickness, scaling, "Vertical"); + checkShadow = false; + thickness = 0; + } + } + } + } + + private static void createGUI(boolean show) { + // Render content panel + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); + + Dimension childSize = null; + for (int i = 0; i < 4; i++) { + JPanel childPanel = new JPanel(new BorderLayout()); + childPanel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(0, i, 4, 4), + BorderFactory.createEtchedBorder(highlight, shadow))); + childPanel.add(Box.createRigidArea(SIZE), BorderLayout.CENTER); + + contentPanel.add(childPanel); + if (childSize == null) { + childSize = childPanel.getPreferredSize(); + } + childPanel.setBounds(0, childSize.height * i, childSize.width, childSize.height); + } + + contentPanel.setSize(childSize.width, childSize.height * 4); + + for (double scaling : scales) { + // Create BufferedImage + BufferedImage buff = new BufferedImage((int) Math.ceil(contentPanel.getWidth() * scaling), + (int) Math.ceil(contentPanel.getHeight() * scaling), + BufferedImage.TYPE_INT_ARGB); + Graphics2D graph = buff.createGraphics(); + graph.scale(scaling, scaling); + // Painting panel onto BufferedImage + contentPanel.paint(graph); + graph.dispose(); + // Save each image ? -- Here it's useful for debugging + saveImage(buff, String.format("test%.2f.png", scaling)); + images.add(buff); + } + // Save coordinates of the panels + for (Component comp : contentPanel.getComponents()) { + panelLocations.add(comp.getLocation()); + } + + if (show) { + JFrame frame = new JFrame("Swing Test"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().add(contentPanel, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + } + + private static void saveImage(BufferedImage image, String filename) { + try { + ImageIO.write(image, "png", new File(filename)); + } catch (IOException e) { + // Don't propagate the exception + e.printStackTrace(); + } + } +} From 0a9127402fc04cf9e6dca84efb9266ab9836b22e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 15 Feb 2023 14:51:44 +0000 Subject: [PATCH 137/205] 8282958: Rendering Issues with Borders on Windows High-DPI systems Backport-of: 9911405e543dbe07767808bad88534abbcc03c5a --- .../javax/swing/border/LineBorder.java | 57 +++- .../LineBorder/ScaledLineBorderTest.java | 299 +++++++++++++++++ .../LineBorder/ScaledTextFieldBorderTest.java | 313 ++++++++++++++++++ 3 files changed, 663 insertions(+), 6 deletions(-) create mode 100644 test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java create mode 100644 test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java diff --git a/src/java.desktop/share/classes/javax/swing/border/LineBorder.java b/src/java.desktop/share/classes/javax/swing/border/LineBorder.java index 9c5fa739383..1e666f4a1e9 100644 --- a/src/java.desktop/share/classes/javax/swing/border/LineBorder.java +++ b/src/java.desktop/share/classes/javax/swing/border/LineBorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -34,6 +34,9 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import java.beans.ConstructorProperties; +import java.awt.geom.AffineTransform; + +import static sun.java2d.pipe.Region.clipRound; /** * A class which implements a line border of arbitrary thickness @@ -144,28 +147,70 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he if ((this.thickness > 0) && (g instanceof Graphics2D)) { Graphics2D g2d = (Graphics2D) g; + AffineTransform at = g2d.getTransform(); + + // if m01 or m10 is non-zero, then there is a rotation or shear + // or if no Scaling enabled, + // skip resetting the transform + boolean resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)) && + ((at.getScaleX() > 1) || (at.getScaleY() > 1)); + + int xtranslation; + int ytranslation; + int w; + int h; + int offs; + + if (resetTransform) { + /* Deactivate the HiDPI scaling transform, + * so we can do paint operations in the device + * pixel coordinate system instead of the logical coordinate system. + */ + g2d.setTransform(new AffineTransform()); + double xx = at.getScaleX() * x + at.getTranslateX(); + double yy = at.getScaleY() * y + at.getTranslateY(); + xtranslation = clipRound(xx); + ytranslation = clipRound(yy); + w = clipRound(at.getScaleX() * width + xx) - xtranslation; + h = clipRound(at.getScaleY() * height + yy) - ytranslation; + offs = this.thickness * (int) at.getScaleX(); + } else { + w = width; + h = height; + xtranslation = x; + ytranslation = y; + offs = this.thickness; + } + + g2d.translate(xtranslation, ytranslation); + Color oldColor = g2d.getColor(); g2d.setColor(this.lineColor); Shape outer; Shape inner; - int offs = this.thickness; int size = offs + offs; if (this.roundedCorners) { float arc = .2f * offs; - outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs); - inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc); + outer = new RoundRectangle2D.Float(0, 0, w, h, offs, offs); + inner = new RoundRectangle2D.Float(offs, offs, w - size, h - size, arc, arc); } else { - outer = new Rectangle2D.Float(x, y, width, height); - inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size); + outer = new Rectangle2D.Float(0, 0, w, h); + inner = new Rectangle2D.Float(offs, offs, w - size, h - size); } Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD); path.append(outer, false); path.append(inner, false); g2d.fill(path); g2d.setColor(oldColor); + + g2d.translate(-xtranslation, -ytranslation); + + if (resetTransform) { + g2d.setTransform(at); + } } } diff --git a/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java b/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java new file mode 100644 index 00000000000..2d858a8039b --- /dev/null +++ b/test/jdk/javax/swing/border/LineBorder/ScaledLineBorderTest.java @@ -0,0 +1,299 @@ +/* + * 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.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 8282958 + * @summary Verify LineBorder edges have the same width + * @requires (os.family == "windows") + * @run main ScaledLineBorderTest + */ +public class ScaledLineBorderTest { + private static final Dimension SIZE = new Dimension(120, 25); + + private static final Color OUTER_COLOR = Color.BLACK; + private static final Color BORDER_COLOR = Color.RED; + private static final Color INSIDE_COLOR = Color.WHITE; + private static final Color TRANSPARENT_COLOR = new Color(0x00000000, true); + + private static final double[] scales = + {1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00}; + + private static final List images = + new ArrayList<>(scales.length); + + private static final List panelLocations = + new ArrayList<>(4); + + public static void main(String[] args) throws Exception { + Collection params = Arrays.asList(args); + final boolean showFrame = params.contains("-show"); + final boolean saveImages = params.contains("-save"); + SwingUtilities.invokeAndWait(() -> testScaling(showFrame, saveImages)); + } + + private static void testScaling(boolean showFrame, boolean saveImages) { + JComponent content = createUI(); + if (showFrame) { + showFrame(content); + } + + paintToImages(content, saveImages); + verifyBorderRendering(saveImages); + } + + private static void verifyBorderRendering(final boolean saveImages) { + String errorMessage = null; + int errorCount = 0; + for (int i = 0; i < images.size(); i++) { + BufferedImage img = images.get(i); + double scaling = scales[i]; + try { + int thickness = (int) Math.floor(scaling); + + checkVerticalBorders(SIZE.width / 2, thickness, img); + + for (Point p : panelLocations) { + int y = (int) (p.y * scaling) + SIZE.height / 2; + checkHorizontalBorder(y, thickness, img); + } + } catch (Error e) { + if (errorMessage == null) { + errorMessage = e.getMessage(); + } + errorCount++; + + System.err.printf("Scaling: %.2f\n", scaling); + e.printStackTrace(); + + // Save the image if it wasn't already saved + if (!saveImages) { + saveImage(img, getImageFileName(scaling)); + } + } + } + + if (errorCount > 0) { + throw new Error("Test failed: " + + errorCount + " error(s) detected - " + + errorMessage); + } + } + + private static void checkVerticalBorders(final int x, + final int thickness, + final BufferedImage img) { + checkBorder(x, 0, + 0, 1, + thickness, img); + } + + private static void checkHorizontalBorder(final int y, + final int thickness, + final BufferedImage img) { + checkBorder(0, y, + 1, 0, + thickness, img); + } + + private static void checkBorder(final int xStart, final int yStart, + final int xStep, final int yStep, + final int thickness, + final BufferedImage img) { + final int width = img.getWidth(); + final int height = img.getHeight(); + + State state = State.BACKGROUND; + int borderThickness = 0; + + int x = xStart; + int y = yStart; + do { + do { + final int color = img.getRGB(x, y); + switch (state) { + case BACKGROUND: + if (color == BORDER_COLOR.getRGB()) { + state = State.LEFT; + borderThickness = 1; + } else if (color != OUTER_COLOR.getRGB() + && color != TRANSPARENT_COLOR.getRGB()) { + throwUnexpectedColor(x, y, color); + } + break; + + case LEFT: + if (color == BORDER_COLOR.getRGB()) { + borderThickness++; + } else if (color == INSIDE_COLOR.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + state = State.INSIDE; + borderThickness = 0; + } else { + throwUnexpectedColor(x, y, color); + } + break; + + case INSIDE: + if (color == BORDER_COLOR.getRGB()) { + state = State.RIGHT; + borderThickness = 1; + } else if (color != INSIDE_COLOR.getRGB()) { + throwUnexpectedColor(x, y, color); + } + break; + + case RIGHT: + if (color == BORDER_COLOR.getRGB()) { + borderThickness++; + } else if (color == OUTER_COLOR.getRGB()) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + state = State.BACKGROUND; + borderThickness = 0; + } else { + throwUnexpectedColor(x, y, color); + } + } + } while (yStep > 0 && ((y += yStep) < height)); + } while (xStep > 0 && ((x += xStep) < width)); + } + + private enum State { + BACKGROUND, LEFT, INSIDE, RIGHT + } + + private static void throwWrongThickness(int thickness, int borderThickness, + int x, int y) { + throw new Error( + String.format("Wrong border thickness at %d, %d: %d vs %d", + x, y, borderThickness, thickness)); + } + + private static void throwUnexpectedColor(int x, int y, int color) { + throw new Error( + String.format("Unexpected color at %d, %d: %08x", + x, y, color)); + } + + private static JComponent createUI() { + Box contentPanel = Box.createVerticalBox(); + contentPanel.setBackground(OUTER_COLOR); + + Dimension childSize = null; + for (int i = 0; i < 4; i++) { + JComponent filler = new JPanel(null); + filler.setBackground(INSIDE_COLOR); + filler.setPreferredSize(SIZE); + filler.setBounds(i, 0, SIZE.width, SIZE.height); + filler.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); + + JPanel childPanel = new JPanel(new BorderLayout()); + childPanel.setBorder(BorderFactory.createEmptyBorder(0, i, 4, 4)); + childPanel.add(filler, BorderLayout.CENTER); + childPanel.setBackground(OUTER_COLOR); + + contentPanel.add(childPanel); + if (childSize == null) { + childSize = childPanel.getPreferredSize(); + } + childPanel.setBounds(0, childSize.height * i, childSize.width, childSize.height); + } + + contentPanel.setSize(childSize.width, childSize.height * 4); + + // Save coordinates of the panels + for (Component comp : contentPanel.getComponents()) { + panelLocations.add(comp.getLocation()); + } + + return contentPanel; + } + + private static void showFrame(JComponent content) { + JFrame frame = new JFrame("Scaled Line Border Test"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().add(content, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void paintToImages(final JComponent content, + final boolean saveImages) { + for (double scaling : scales) { + BufferedImage image = + new BufferedImage((int) Math.ceil(content.getWidth() * scaling), + (int) Math.ceil(content.getHeight() * scaling), + BufferedImage.TYPE_INT_ARGB); + + Graphics2D g2d = image.createGraphics(); + g2d.scale(scaling, scaling); + content.paint(g2d); + g2d.dispose(); + + if (saveImages) { + saveImage(image, getImageFileName(scaling)); + } + images.add(image); + } + } + + private static String getImageFileName(final double scaling) { + return String.format("test%.2f.png", scaling); + } + + private static void saveImage(BufferedImage image, String filename) { + try { + ImageIO.write(image, "png", new File(filename)); + } catch (IOException e) { + // Don't propagate the exception + e.printStackTrace(); + } + } +} diff --git a/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java b/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java new file mode 100644 index 00000000000..5e2868ed506 --- /dev/null +++ b/test/jdk/javax/swing/border/LineBorder/ScaledTextFieldBorderTest.java @@ -0,0 +1,313 @@ +/* + * 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.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.border.LineBorder; + +/* + * @test + * @bug 8282958 + * @summary Verify all the borders are rendered consistently for a JTextField + * in Windows LaF which uses LineBorder + * @requires (os.family == "windows") + * @run main ScaledTextFieldBorderTest + */ +public class ScaledTextFieldBorderTest { + + private static final double[] scales = { + 1.00, 1.25, 1.50, 1.75, + 2.00, 2.25, 2.50, 2.75, + 3.00 + }; + + private static final List images = + new ArrayList<>(scales.length); + + private static final List panelLocations = + new ArrayList<>(4); + + private static Dimension textFieldSize; + + public static void main(String[] args) throws Exception { + Collection params = Arrays.asList(args); + final boolean showFrame = params.contains("-show"); + final boolean saveImages = params.contains("-save"); + SwingUtilities.invokeAndWait(() -> testScaling(showFrame, saveImages)); + } + + private static void testScaling(boolean showFrame, boolean saveImages) { + JComponent content = createUI(); + if (showFrame) { + showFrame(content); + } + + paintToImages(content, saveImages); + verifyBorderRendering(saveImages); + } + + private static void verifyBorderRendering(final boolean saveImages) { + String errorMessage = null; + int errorCount = 0; + for (int i = 0; i < images.size(); i++) { + BufferedImage img = images.get(i); + double scaling = scales[i]; + try { + int thickness = (int) Math.floor(scaling); + + checkVerticalBorders(textFieldSize.width / 2, thickness, img); + + for (Point p : panelLocations) { + int y = (int) (p.y * scaling) + textFieldSize.height / 2; + checkHorizontalBorder(y, thickness, img); + } + } catch (Error | Exception e) { + if (errorMessage == null) { + errorMessage = e.getMessage(); + } + errorCount++; + + System.err.printf("Scaling: %.2f\n", scaling); + e.printStackTrace(); + + // Save the image if it wasn't already saved + if (!saveImages) { + saveImage(img, getImageFileName(scaling)); + } + } + } + + if (errorCount > 0) { + throw new Error("Test failed: " + + errorCount + " error(s) detected - " + + errorMessage); + } + } + + private static void checkVerticalBorders(final int x, + final int thickness, + final BufferedImage img) { + checkBorder(x, 0, + 0, 1, + thickness, img); + } + + private static void checkHorizontalBorder(final int y, + final int thickness, + final BufferedImage img) { + checkBorder(0, y, + 1, 0, + thickness, img); + } + + private enum State { + BACKGROUND, LEFT, INSIDE, RIGHT + } + + private static final int transparentColor = 0x00000000; + private static int panelColor; + private static int borderColor; + private static int insideColor; + + private static void checkBorder(final int xStart, final int yStart, + final int xStep, final int yStep, + final int thickness, + final BufferedImage img) { + final int width = img.getWidth(); + final int height = img.getHeight(); + + State state = State.BACKGROUND; + int borderThickness = -1; + + int x = xStart; + int y = yStart; + do { + do { + final int color = img.getRGB(x, y); + switch (state) { + case BACKGROUND: + if (color == borderColor) { + state = State.LEFT; + borderThickness = 1; + } else if (color != panelColor + && color != transparentColor) { + throwUnexpectedColor(x, y, color); + } + break; + + case LEFT: + if (color == borderColor) { + borderThickness++; + } else if (color == insideColor) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + state = State.INSIDE; + borderThickness = 0; + } else { + throwUnexpectedColor(x, y, color); + } + break; + + case INSIDE: + if (color == borderColor) { + state = State.RIGHT; + borderThickness = 1; + } else if (color != insideColor) { + throwUnexpectedColor(x, y, color); + } + break; + + case RIGHT: + if (color == borderColor) { + borderThickness++; + } else if (color == panelColor) { + if (borderThickness != thickness) { + throwWrongThickness(thickness, borderThickness, x, y); + } + state = State.BACKGROUND; + borderThickness = 0; + } else { + throwUnexpectedColor(x, y, color); + } + } + } while (yStep > 0 && ((y += yStep) < height)); + } while (xStep > 0 && ((x += xStep) < width)); + + if (state != State.BACKGROUND) { + throw new Error(String.format("Border is not rendered correctly at %d, %d", x, y)); + } + } + + private static void throwWrongThickness(int thickness, int borderThickness, int x, int y) { + throw new Error( + String.format("Wrong border thickness at %d, %d: %d vs %d", + x, y, borderThickness, thickness)); + } + + private static void throwUnexpectedColor(int x, int y, int color) { + throw new Error( + String.format("Unexpected color at %d, %d: %08x", + x, y, color)); + } + + private static JComponent createUI() { + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); + + final LineBorder tfBorder = new LineBorder(Color.RED); + + for (int i = 0; i < 4; i++) { + JTextField textField = new JTextField(10); + textField.setBorder(tfBorder); + Box childPanel = Box.createHorizontalBox(); + childPanel.add(Box.createHorizontalStrut(i)); + childPanel.add(textField); + childPanel.add(Box.createHorizontalStrut(4)); + + contentPanel.add(childPanel); + if (textFieldSize == null) { + textFieldSize = textField.getPreferredSize(); + borderColor = tfBorder.getLineColor().getRGB(); + insideColor = textField.getBackground().getRGB(); + } + textField.setBounds(i, 0, textFieldSize.width, textFieldSize.height); + childPanel.setBounds(0, (textFieldSize.height + 4) * i, + textFieldSize.width + i + 4, textFieldSize.height); + } + + contentPanel.setSize(textFieldSize.width + 4, + (textFieldSize.height + 4) * 4); + + panelColor = contentPanel.getBackground().getRGB(); + + // Save coordinates of the panels + for (Component comp : contentPanel.getComponents()) { + panelLocations.add(comp.getLocation()); + } + + return contentPanel; + } + + private static void showFrame(JComponent content) { + JFrame frame = new JFrame("Text Field Border Test"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().add(content, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void paintToImages(final JComponent content, + final boolean saveImages) { + for (double scaling : scales) { + BufferedImage image = + new BufferedImage((int) Math.ceil(content.getWidth() * scaling), + (int) Math.ceil(content.getHeight() * scaling), + BufferedImage.TYPE_INT_ARGB); + + Graphics2D g2d = image.createGraphics(); + g2d.scale(scaling, scaling); + content.paint(g2d); + g2d.dispose(); + + if (saveImages) { + saveImage(image, getImageFileName(scaling)); + } + images.add(image); + } + } + + private static String getImageFileName(final double scaling) { + return String.format("test%.2f.png", scaling); + } + + private static void saveImage(BufferedImage image, String filename) { + try { + ImageIO.write(image, "png", new File(filename)); + } catch (IOException e) { + // Don't propagate the exception + e.printStackTrace(); + } + } +} From 5685e581bf52738da2b31c7de578732c0019b438 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:19:35 +0000 Subject: [PATCH 138/205] 8207248: Reduce incidence of compiler.warn.source.no.bootclasspath in javac tests Reviewed-by: clanger, phh Backport-of: a376d5dab4961ed5d9097ddf7010c64e14fdc9ec --- .../tools/javac/TryWithResources/WeirdTwr.java | 2 +- .../tools/javac/TryWithResources/WeirdTwr.out | 4 ---- .../tools/javac/depDocComment/SuppressDeprecation.java | 2 +- .../tools/javac/depDocComment/SuppressDeprecation8.out | 3 +-- .../javac/diags/examples/DiamondAndAnonClass.java | 3 +-- .../javac/diags/examples/DirPathElementNotFound.java | 3 +-- .../ModulesNotSupportedInSource/module-info.java | 3 +-- .../examples/PrivateInterfaceMethodsNotSupported.java | 3 +-- .../VarInTryWithResourcesNotSupportedInSource.java | 3 +-- .../tools/javac/generics/diamond/neg/Neg09a.java | 2 +- .../tools/javac/generics/diamond/neg/Neg09a.out | 2 -- .../tools/javac/generics/diamond/neg/Neg09b.java | 2 +- .../tools/javac/generics/diamond/neg/Neg09b.out | 2 -- .../tools/javac/generics/diamond/neg/Neg09c.java | 2 +- .../tools/javac/generics/diamond/neg/Neg09c.out | 2 -- .../tools/javac/generics/diamond/neg/Neg09d.java | 2 +- .../tools/javac/generics/diamond/neg/Neg09d.out | 2 -- .../tools/javac/warnings/6594914/T6594914b.out | 10 ---------- 18 files changed, 12 insertions(+), 40 deletions(-) delete mode 100644 test/langtools/tools/javac/warnings/6594914/T6594914b.out diff --git a/test/langtools/tools/javac/TryWithResources/WeirdTwr.java b/test/langtools/tools/javac/TryWithResources/WeirdTwr.java index 0895ebbde9b..ea20caa5188 100644 --- a/test/langtools/tools/javac/TryWithResources/WeirdTwr.java +++ b/test/langtools/tools/javac/TryWithResources/WeirdTwr.java @@ -3,7 +3,7 @@ * @bug 6911256 6964740 * @author Joseph D. Darcy * @summary Strange TWRs - * @compile/fail/ref=WeirdTwr.out -XDrawDiagnostics -source 6 WeirdTwr.java + * @compile/fail/ref=WeirdTwr.out -XDrawDiagnostics -Xlint:-options -source 6 WeirdTwr.java * @compile WeirdTwr.java * @run main WeirdTwr */ diff --git a/test/langtools/tools/javac/TryWithResources/WeirdTwr.out b/test/langtools/tools/javac/TryWithResources/WeirdTwr.out index 9401d7bacdf..dca54b3460e 100644 --- a/test/langtools/tools/javac/TryWithResources/WeirdTwr.out +++ b/test/langtools/tools/javac/TryWithResources/WeirdTwr.out @@ -1,6 +1,2 @@ -- compiler.warn.source.no.bootclasspath: 6 -- compiler.warn.option.obsolete.source: 6 -- compiler.warn.option.obsolete.suppression WeirdTwr.java:14:12: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.try.with.resources), 6, 7 1 error -3 warnings diff --git a/test/langtools/tools/javac/depDocComment/SuppressDeprecation.java b/test/langtools/tools/javac/depDocComment/SuppressDeprecation.java index 7968487f129..1203daa026f 100644 --- a/test/langtools/tools/javac/depDocComment/SuppressDeprecation.java +++ b/test/langtools/tools/javac/depDocComment/SuppressDeprecation.java @@ -5,7 +5,7 @@ * @author gafter * * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java - * @compile/ref=SuppressDeprecation8.out -source 8 -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java + * @compile/ref=SuppressDeprecation8.out -source 8 -Xlint:deprecation -XDrawDiagnostics -Xlint:-options SuppressDeprecation.java */ /* Test for the contexts in which deprecations warnings should diff --git a/test/langtools/tools/javac/depDocComment/SuppressDeprecation8.out b/test/langtools/tools/javac/depDocComment/SuppressDeprecation8.out index d48526da2e6..2d917b0782d 100644 --- a/test/langtools/tools/javac/depDocComment/SuppressDeprecation8.out +++ b/test/langtools/tools/javac/depDocComment/SuppressDeprecation8.out @@ -1,4 +1,3 @@ -- compiler.warn.source.no.bootclasspath: 8 SuppressDeprecation.java:83:10: compiler.warn.has.been.deprecated: g(), T SuppressDeprecation.java:84:14: compiler.warn.has.been.deprecated: g(), T SuppressDeprecation.java:85:9: compiler.warn.has.been.deprecated: var, T @@ -6,4 +5,4 @@ SuppressDeprecation.java:88:9: compiler.warn.has.been.deprecated: T(), T SuppressDeprecation.java:91:9: compiler.warn.has.been.deprecated: T(int), T SuppressDeprecation.java:99:1: compiler.warn.has.been.deprecated: T(), T SuppressDeprecation.java:131:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package -8 warnings +7 warnings diff --git a/test/langtools/tools/javac/diags/examples/DiamondAndAnonClass.java b/test/langtools/tools/javac/diags/examples/DiamondAndAnonClass.java index 0358fb03e17..65bdfb3bf39 100644 --- a/test/langtools/tools/javac/diags/examples/DiamondAndAnonClass.java +++ b/test/langtools/tools/javac/diags/examples/DiamondAndAnonClass.java @@ -24,8 +24,7 @@ // key: compiler.misc.feature.not.supported.in.source // key: compiler.misc.feature.diamond.and.anon.class // key: compiler.err.cant.apply.diamond.1 -// key: compiler.warn.source.no.bootclasspath -// options: -source 8 +// options: -source 8 -Xlint:-options import java.util.*; diff --git a/test/langtools/tools/javac/diags/examples/DirPathElementNotFound.java b/test/langtools/tools/javac/diags/examples/DirPathElementNotFound.java index 4c8a385616f..4db8942b72a 100644 --- a/test/langtools/tools/javac/diags/examples/DirPathElementNotFound.java +++ b/test/langtools/tools/javac/diags/examples/DirPathElementNotFound.java @@ -22,8 +22,7 @@ */ // key: compiler.warn.dir.path.element.not.found -// key: compiler.warn.source.no.bootclasspath -// options: -Xlint:path -source 8 -target 8 -extdirs DoesNotExist +// options: -Xlint:path,-options -source 8 -target 8 -extdirs DoesNotExist // run: simple class DirPathElementNotFound { } diff --git a/test/langtools/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java b/test/langtools/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java index 3ca647cb2d0..ba178004194 100644 --- a/test/langtools/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java +++ b/test/langtools/tools/javac/diags/examples/ModulesNotSupportedInSource/module-info.java @@ -23,8 +23,7 @@ // key: compiler.err.feature.not.supported.in.source.plural // key: compiler.misc.feature.modules -// key: compiler.warn.source.no.bootclasspath -// options: -source 8 -Xlint:-path +// options: -source 8 -Xlint:-path,-options module ModulesNotSupportedInSource { } diff --git a/test/langtools/tools/javac/diags/examples/PrivateInterfaceMethodsNotSupported.java b/test/langtools/tools/javac/diags/examples/PrivateInterfaceMethodsNotSupported.java index 76e0192e048..06993ad3142 100644 --- a/test/langtools/tools/javac/diags/examples/PrivateInterfaceMethodsNotSupported.java +++ b/test/langtools/tools/javac/diags/examples/PrivateInterfaceMethodsNotSupported.java @@ -23,8 +23,7 @@ // key: compiler.err.feature.not.supported.in.source.plural // key: compiler.misc.feature.private.intf.methods -// key: compiler.warn.source.no.bootclasspath -// options: -source 8 +// options: -source 8 -Xlint:-options interface PrivateInterfaceMethodsNotSupported { private void foo() {} diff --git a/test/langtools/tools/javac/diags/examples/VarInTryWithResourcesNotSupportedInSource.java b/test/langtools/tools/javac/diags/examples/VarInTryWithResourcesNotSupportedInSource.java index 98e4022be58..6d26b3948e2 100644 --- a/test/langtools/tools/javac/diags/examples/VarInTryWithResourcesNotSupportedInSource.java +++ b/test/langtools/tools/javac/diags/examples/VarInTryWithResourcesNotSupportedInSource.java @@ -23,8 +23,7 @@ // key: compiler.err.feature.not.supported.in.source.plural // key: compiler.misc.feature.var.in.try.with.resources -// key: compiler.warn.source.no.bootclasspath -// options: -source 8 +// options: -source 8 -Xlint:-options class VarInTryWithResourcesNotSupportedInSource { void m() { diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09a.java b/test/langtools/tools/javac/generics/diamond/neg/Neg09a.java index 4c0959163e5..195ee6512d4 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09a.java +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09a.java @@ -4,7 +4,7 @@ * * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9 * @author Maurizio Cimadamore - * @compile/fail/ref=Neg09a.out Neg09a.java -source 8 -XDrawDiagnostics + * @compile/fail/ref=Neg09a.out Neg09a.java -source 8 -XDrawDiagnostics -Xlint:-options * */ diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09a.out b/test/langtools/tools/javac/generics/diamond/neg/Neg09a.out index d4fd1b63ddc..c2592feb5e5 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09a.out +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09a.out @@ -1,4 +1,2 @@ -- compiler.warn.source.no.bootclasspath: 8 Neg09a.java:15:34: compiler.err.cant.apply.diamond.1: Neg09a.Member, (compiler.misc.feature.not.supported.in.source: (compiler.misc.feature.diamond.and.anon.class), 8, 9) 1 error -1 warning diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09b.java b/test/langtools/tools/javac/generics/diamond/neg/Neg09b.java index f08e65cdf2e..106bd9a0a6b 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09b.java +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09b.java @@ -4,7 +4,7 @@ * * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9 * @author Maurizio Cimadamore - * @compile/fail/ref=Neg09b.out Neg09b.java -source 8 -XDrawDiagnostics + * @compile/fail/ref=Neg09b.out Neg09b.java -source 8 -XDrawDiagnostics -Xlint:-options * */ diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09b.out b/test/langtools/tools/javac/generics/diamond/neg/Neg09b.out index a4ecbf9dc20..4bbbfb5d41a 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09b.out +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09b.out @@ -1,4 +1,2 @@ -- compiler.warn.source.no.bootclasspath: 8 Neg09b.java:16:34: compiler.err.cant.apply.diamond.1: Neg09b.Nested, (compiler.misc.feature.not.supported.in.source: (compiler.misc.feature.diamond.and.anon.class), 8, 9) 1 error -1 warning diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09c.java b/test/langtools/tools/javac/generics/diamond/neg/Neg09c.java index d9727c36216..bf26b4c603c 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09c.java +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09c.java @@ -4,7 +4,7 @@ * * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9 * @author Maurizio Cimadamore - * @compile/fail/ref=Neg09c.out Neg09c.java -source 8 -XDrawDiagnostics + * @compile/fail/ref=Neg09c.out Neg09c.java -source 8 -XDrawDiagnostics -Xlint:-options * */ diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09c.out b/test/langtools/tools/javac/generics/diamond/neg/Neg09c.out index e795de7c2df..bd93fb33067 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09c.out +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09c.out @@ -1,4 +1,2 @@ -- compiler.warn.source.no.bootclasspath: 8 Neg09c.java:15:39: compiler.err.cant.apply.diamond.1: Neg09c.Member, (compiler.misc.feature.not.supported.in.source: (compiler.misc.feature.diamond.and.anon.class), 8, 9) 1 error -1 warning diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09d.java b/test/langtools/tools/javac/generics/diamond/neg/Neg09d.java index d1fe9dd566e..9aff0ade838 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09d.java +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09d.java @@ -4,7 +4,7 @@ * * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9 * @author Maurizio Cimadamore - * @compile/fail/ref=Neg09d.out Neg09d.java -source 8 -XDrawDiagnostics + * @compile/fail/ref=Neg09d.out Neg09d.java -source 8 -XDrawDiagnostics -Xlint:-options * */ diff --git a/test/langtools/tools/javac/generics/diamond/neg/Neg09d.out b/test/langtools/tools/javac/generics/diamond/neg/Neg09d.out index 9d83b37b022..5689af2fce5 100644 --- a/test/langtools/tools/javac/generics/diamond/neg/Neg09d.out +++ b/test/langtools/tools/javac/generics/diamond/neg/Neg09d.out @@ -1,4 +1,2 @@ -- compiler.warn.source.no.bootclasspath: 8 Neg09d.java:16:33: compiler.err.doesnt.exist: Neg09 1 error -1 warning diff --git a/test/langtools/tools/javac/warnings/6594914/T6594914b.out b/test/langtools/tools/javac/warnings/6594914/T6594914b.out deleted file mode 100644 index 2c2735bd4bc..00000000000 --- a/test/langtools/tools/javac/warnings/6594914/T6594914b.out +++ /dev/null @@ -1,10 +0,0 @@ -- compiler.warn.source.no.bootclasspath: 1.8 -T6594914b.java:12:22: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo -T6594914b.java:17:33: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo -T6594914b.java:18:22: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo -T6594914b.java:19:37: compiler.warn.sun.proprietary: sun.security.x509.CertException -T6594914b.java:18:56: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo -T6594914b.java:27:26: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo -- compiler.note.deprecated.filename: T6594914b.java -- compiler.note.deprecated.recompile -7 warnings From 3a2a0f907003014285bc928a42fb26392df71eda Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:25:30 +0000 Subject: [PATCH 139/205] 8223463: Replace wildcard address with loopback or local host in tests - part 2 Removes (or documents) some usages of the wildcard address in intermittently failing tests. Backport-of: 1188188ee66776e6a67c0300576a950dd64f6303 --- .../net/ServerSocket/AcceptInheritHandle.java | 25 ++++++--- .../jdk/java/net/URLConnection/Responses.java | 21 ++++++-- test/jdk/java/net/ipv6tests/TcpTest.java | 5 +- test/jdk/sun/net/ftp/FtpURL.java | 53 +++++++++++++------ 4 files changed, 75 insertions(+), 29 deletions(-) diff --git a/test/jdk/java/net/ServerSocket/AcceptInheritHandle.java b/test/jdk/java/net/ServerSocket/AcceptInheritHandle.java index ce175f2f490..e01ced55979 100644 --- a/test/jdk/java/net/ServerSocket/AcceptInheritHandle.java +++ b/test/jdk/java/net/ServerSocket/AcceptInheritHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -32,6 +32,7 @@ import java.net.*; import java.nio.channels.ServerSocketChannel; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; @@ -41,8 +42,8 @@ public class AcceptInheritHandle { enum ServerSocketProducer { JAVA_NET(() -> { try { - return new ServerSocket(); } - catch(IOException x) { + return new ServerSocket(); + } catch(IOException x) { throw new UncheckedIOException(x); } }), @@ -86,13 +87,13 @@ static void testNioServerSocketChannel() throws Exception { test(ServerSocketProducer.NIO_CHANNELS); } - static void test(ServerSocketProducer ssp, String... sysProps) throws Exception { + static void test(ServerSocketProducer ssp, String... jvmArgs) throws Exception { System.out.println("\nStarting test for " + ssp.name()); List commands = new ArrayList<>(); commands.add(JAVA); - for (String prop : sysProps) - commands.add(prop); + for (String arg : jvmArgs) + commands.add(arg); commands.add("-cp"); commands.add(CLASSPATH); commands.add("AcceptInheritHandle"); @@ -107,7 +108,14 @@ static void test(ServerSocketProducer ssp, String... sysProps) throws Exception int port = dis.readInt(); System.out.println("Server process listening on " + port + ", connecting..."); - Socket socket = new Socket("localhost", port); + String address; + if (Arrays.stream(jvmArgs).anyMatch("-Djava.net.preferIPv4Stack=true"::equals)) { + address = "127.0.0.1"; + } else { + InetAddress loopback = InetAddress.getLoopbackAddress(); + address = loopback.getHostAddress(); + } + Socket socket = new Socket(address, port); String s = dis.readUTF(); System.out.println("Server process said " + s); @@ -128,7 +136,8 @@ static void test(ServerSocketProducer ssp, String... sysProps) throws Exception static void server(ServerSocketProducer producer) throws Exception { try (ServerSocket ss = producer.supplier().get()) { - ss.bind(new InetSocketAddress(0)); + InetAddress loopback = InetAddress.getLoopbackAddress(); + ss.bind(new InetSocketAddress(loopback, 0)); int port = ss.getLocalPort(); DataOutputStream dos = new DataOutputStream(System.out); dos.writeInt(port); diff --git a/test/jdk/java/net/URLConnection/Responses.java b/test/jdk/java/net/URLConnection/Responses.java index f733046d56b..e2ff1cc657e 100644 --- a/test/jdk/java/net/URLConnection/Responses.java +++ b/test/jdk/java/net/URLConnection/Responses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,9 @@ static class HttpServer implements Runnable { public HttpServer() { try { - ss = new ServerSocket(0); + InetAddress loopback = InetAddress.getLoopbackAddress(); + ss = new ServerSocket(); + ss.bind(new InetSocketAddress(loopback, 0)); } catch (IOException ioe) { throw new Error("Unable to create ServerSocket: " + ioe); } @@ -70,6 +72,16 @@ public int port() { return ss.getLocalPort(); } + public String authority() { + InetAddress address = ss.getInetAddress(); + String hostaddr = address.isAnyLocalAddress() + ? "localhost" : address.getHostAddress(); + if (hostaddr.indexOf(':') > -1) { + hostaddr = "[" + hostaddr + "]"; + } + return hostaddr + ":" + port(); + } + public void shutdown() throws IOException { ss.close(); } @@ -116,7 +128,8 @@ public static void main(String args[]) throws Exception { HttpServer svr = new HttpServer(); (new Thread(svr)).start(); - int port = svr.port(); + String authority = svr.authority(); + System.out.println("Server listening on: " + authority); /* * Iterate through each test case and check that getResponseCode @@ -129,7 +142,7 @@ public static void main(String args[]) throws Exception { System.out.println("******************"); System.out.println("Test with response: >" + tests[i][0] + "<"); - URL url = new URL("http://localhost:" + port + "/" + i); + URL url = new URL("http://" + authority + "/" + i); HttpURLConnection http = (HttpURLConnection)url.openConnection(); try { diff --git a/test/jdk/java/net/ipv6tests/TcpTest.java b/test/jdk/java/net/ipv6tests/TcpTest.java index d4b18406fc7..706d2b6807f 100644 --- a/test/jdk/java/net/ipv6tests/TcpTest.java +++ b/test/jdk/java/net/ipv6tests/TcpTest.java @@ -25,7 +25,9 @@ * @test * @bug 4868820 * @key intermittent - * @summary IPv6 support for Windows XP and 2003 server + * @summary IPv6 support for Windows XP and 2003 server. This test requires + * binding to the wildcard address, and as such is susceptible + * of intermittent failures caused by port reuse policy. * @library /test/lib * @build jdk.test.lib.NetworkConfiguration * jdk.test.lib.Platform @@ -240,4 +242,3 @@ static void test4 () throws Exception { System.out.println ("Test4: OK"); } } - diff --git a/test/jdk/sun/net/ftp/FtpURL.java b/test/jdk/sun/net/ftp/FtpURL.java index 64c4e8fc890..c94516bde37 100644 --- a/test/jdk/sun/net/ftp/FtpURL.java +++ b/test/jdk/sun/net/ftp/FtpURL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, 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 @@ -36,8 +36,8 @@ public class FtpURL { */ private class FtpServer extends Thread { - private ServerSocket server; - private int port; + private final ServerSocket server; + private final int port; private boolean done = false; private boolean portEnabled = true; private boolean pasvEnabled = true; @@ -253,8 +253,12 @@ public void run() { continue; } try { - if (pasv == null) - pasv = new ServerSocket(0); + if (pasv == null) { + // Not sure how to support PASV mode over + // IPv6 + pasv = new ServerSocket(); + pasv.bind(new InetSocketAddress("127.0.0.1", 0)); + } int port = pasv.getLocalPort(); out.println("227 Entering Passive Mode (127,0,0,1," + (port >> 8) + "," + (port & 0xff) +")"); @@ -369,21 +373,39 @@ public void run() { } public FtpServer(int port) { + this(InetAddress.getLoopbackAddress(), port); + } + + public FtpServer(InetAddress address, int port) { this.port = port; try { - server = new ServerSocket(port); + if (address == null) { + server = new ServerSocket(port); + } else { + server = new ServerSocket(); + server.bind(new InetSocketAddress(address, port)); + } } catch (IOException e) { + throw new UncheckedIOException(e); } } public FtpServer() { - this(21); + this(null, 21); } public int getPort() { - if (server != null) - return server.getLocalPort(); - return 0; + return server.getLocalPort(); + } + + public String getAuthority() { + InetAddress address = server.getInetAddress(); + String hostaddr = address.isAnyLocalAddress() + ? "localhost" : address.getHostAddress(); + if (hostaddr.indexOf(':') > -1) { + hostaddr = "[" + hostaddr +"]"; + } + return hostaddr + ":" + getPort(); } /** @@ -449,15 +471,17 @@ public static void main(String[] args) throws Exception { } public FtpURL() throws Exception { - FtpServer server = new FtpServer(0); + FtpServer server = new FtpServer(InetAddress.getLoopbackAddress(), 0); BufferedReader in = null; try { server.start(); - int port = server.getPort(); + String authority = server.getAuthority(); + System.out.println("FTP server waiting for connections at: " + authority); + assert authority != null; // Now let's check the URL handler - URL url = new URL("ftp://user:password@localhost:" + port + "/%2Fetc/motd;type=a"); + URL url = new URL("ftp://user:password@" + authority + "/%2Fetc/motd;type=a"); URLConnection con = url.openConnection(); in = new BufferedReader(new InputStreamReader(con.getInputStream())); String s; @@ -479,11 +503,10 @@ public FtpURL() throws Exception { // We're done! // Second URL test - port = server.getPort(); // Now let's check the URL handler - url = new URL("ftp://user2@localhost:" + port + "/%2Fusr/bin;type=d"); + url = new URL("ftp://user2@" + authority + "/%2Fusr/bin;type=d"); con = url.openConnection(); in = new BufferedReader(new InputStreamReader(con.getInputStream())); do { From a3d867bbea2db1692bc2a6e83f349d9acba793a7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:26:59 +0000 Subject: [PATCH 140/205] 8226595: jvmti/scenarios/contention/TC04/tc04t001/TestDescription.java still fails due to wrong number of MonitorContendedEntered events Fix one more sync issue in the test Backport-of: 8cf8442085af928c7a601662006bd92eee4a68cb --- .../scenarios/contention/TC04/tc04t001.java | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java index 712ff82c2af..0707f38b4dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java @@ -86,23 +86,6 @@ public int runIt(String argv[], PrintStream out) { ", expected: " + THREADS_LIMIT*tc04t001Thread.INCREMENT_LIMIT); status = Consts.TEST_FAILED; } - -/* DEBUG -- to check if the threads taking turns in right order - boolean race = false; - for (int i = 1; i < 2*tc04t001Thread.INCREMENT_LIMIT; i++) { - if (tc04t001Thread.passOrder[i] == tc04t001Thread.passOrder[i-1]) { - race = true; - System.out.println("Race condition in the test:"); - System.out.println("passOrder[" + (i-1) + "]:" - + tc04t001Thread.passOrder[i-1]); - System.out.println("passOrder[" + (i) + "]:" - + tc04t001Thread.passOrder[i]); - } - } - if (race) - System.out.println("There was a race condition in the test."); -*/ - return status; } } @@ -117,11 +100,6 @@ class tc04t001Thread extends Thread { static volatile int value = 0; static Flicker flicker = new Flicker(); -/* DEBUG -- to check if the threads taking turns in right order - static volatile int iter = 0; - static volatile int passOrder[] = - new int[INCREMENT_LIMIT*tc04t001.THREADS_LIMIT]; -*/ private int id; private static volatile int lastEnterEventsCount; @@ -135,7 +113,6 @@ public tc04t001Thread(int i) { public synchronized void run() { for (int i = 0; i < INCREMENT_LIMIT; i++) { flicker.waitFor(id); - lastEnterEventsCount = enterEventsCount(); increment(id); try { wait(1); @@ -145,11 +122,9 @@ public synchronized void run() { } static synchronized void increment(int i) { -/* DEBUG -- to check if the threads taking turns in right order - passOrder[iter++] = i; -*/ flicker.unlock(i); int temp = value; + boolean done = false; // Wait in a loop for a MonitorContendedEnter event. // Timeout is: 20ms * DELAY. @@ -158,17 +133,22 @@ static synchronized void increment(int i) { sleep(20); } catch (InterruptedException e) {} + done = (tc04t001.threadsDoneSignal.getCount() == 1); + if (done) { + break; // This thread is the only remaining thread, no more contention + } if (enterEventsCount() > lastEnterEventsCount) { + System.out.println("Thread-" + i + ": increment event: " + enterEventsCount()); break; // Got an expected MonitorContendedEnter event } } - System.out.println("Thread-" + i + ": increment event: " + enterEventsCount()); - if (enterEventsCount() == lastEnterEventsCount) { + if (!done && enterEventsCount() == lastEnterEventsCount) { String msg = "Timeout in waiting for a MonitorContendedEnter event"; throw new RuntimeException(msg); } value = temp + 1; + lastEnterEventsCount = enterEventsCount(); } } From 22be06112bd0c86d9a61da1a81a7d845f0a8c58b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:28:23 +0000 Subject: [PATCH 141/205] 8226917: jvmti/scenarios/contention/TC04/tc04t001/TestDescription.java fails on jvmti->InterruptThread (JVMTI_ERROR_THREAD_NOT_ALIVE) Fix one more sync issue in the test Backport-of: ff1f2fad6e332590197b52453ac305fc366d92ee --- .../scenarios/contention/TC04/tc04t001/tc04t001.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp index 718434ae275..6000051f1ad 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp @@ -119,19 +119,10 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { /* check if event is for tested object */ if (jni->IsSameObject(object_M, obj)) { - jvmtiMonitorUsage usageInfo; - if (lockSyncLock(jvmti)) { enterEventsCount++; unlockSyncLock(jvmti); } - - if (!NSK_JVMTI_VERIFY(jvmti->GetObjectMonitorUsage(obj, &usageInfo))) { - nsk_jvmti_setFailStatus(); - } else if (usageInfo.owner != NULL) { - if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(usageInfo.owner))) - nsk_jvmti_setFailStatus(); - } } } From 5c1748a40ee3f73f29d113cf101389046cd10a5d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:30:01 +0000 Subject: [PATCH 142/205] 8171405: java/net/URLConnection/ResendPostBody.java failed with "Error while cleaning up threads after test" Test cleaned up to improve safe termination Reviewed-by: clanger Backport-of: 7b49c40ee96cb5fc78071cd87c7c4edcd50417b3 --- .../net/URLConnection/ResendPostBody.java | 135 ++++++++++-------- 1 file changed, 72 insertions(+), 63 deletions(-) diff --git a/test/jdk/java/net/URLConnection/ResendPostBody.java b/test/jdk/java/net/URLConnection/ResendPostBody.java index 771ccd6926a..ed8da62c9a0 100644 --- a/test/jdk/java/net/URLConnection/ResendPostBody.java +++ b/test/jdk/java/net/URLConnection/ResendPostBody.java @@ -48,25 +48,23 @@ public class ResendPostBody { static class Server extends Thread { - InputStream in; - OutputStream out; - Socket sock; - StringBuffer response; - ServerSocket server; - - Server (ServerSocket s) throws IOException - { + private InputStream in; + private OutputStream out; + private Socket sock; + private StringBuffer response; + private ServerSocket server; + + Server(ServerSocket s) throws IOException { server = s; } - void waitFor (String s) throws IOException - { - byte[] w = s.getBytes (); - for(int c=0; c Date: Thu, 16 Feb 2023 10:31:30 +0000 Subject: [PATCH 143/205] 8233462: serviceability/tmtools/jstat tests times out with -Xcomp Backport-of: d7170782b5c6e2607c93400b9a98c7dce8970770 --- .../tmtools/share/common/ToolRunner.java | 51 +++++++------------ 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/tmtools/share/common/ToolRunner.java b/test/hotspot/jtreg/serviceability/tmtools/share/common/ToolRunner.java index b9ca940ca13..eb560cc56fe 100644 --- a/test/hotspot/jtreg/serviceability/tmtools/share/common/ToolRunner.java +++ b/test/hotspot/jtreg/serviceability/tmtools/share/common/ToolRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,15 +22,11 @@ */ package common; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.time.Instant; /** * This class starts a process specified by the passed command line waits till @@ -38,14 +34,10 @@ * output as ToolResults */ class ToolRunner { - - private final List cmdArgs = new LinkedList<>(); + private final String[] cmdArgs; ToolRunner(String cmdLine) { - StringTokenizer st = new StringTokenizer(cmdLine); - while (st.hasMoreTokens()) { - cmdArgs.add(st.nextToken()); - } + cmdArgs = cmdLine.split(" +"); } /** @@ -56,23 +48,18 @@ class ToolRunner { * @throws Exception if anything goes wrong */ ToolResults runToCompletion() throws Exception { - ProcessBuilder pb = new ProcessBuilder(cmdArgs); - OutputAnalyzer oa = ProcessTools.executeProcess(pb); - - return new ToolResults(oa.getExitValue(), - stringToList(oa.getStdout()), - stringToList(oa.getStderr())); - - } + Path out = Files.createTempFile(Paths.get("."), "out.", ".txt"); + Path err = out.resolveSibling(out.getFileName().toString().replaceFirst("out", "err")); - private static List stringToList(String s) throws IOException { - BufferedReader reader = new BufferedReader(new StringReader(s)); - List strings = new ArrayList<>(); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - strings.add(line); - } - reader.close(); - return strings; + Process p = pb.redirectOutput(ProcessBuilder.Redirect.to(out.toFile())) + .redirectError(ProcessBuilder.Redirect.to(err.toFile())) + .start(); + System.out.printf("[%s] started process %d %s with out/err redirected to '%s' and '%s'%n", + Instant.now().toString(), p.pid(), pb.command(), out.toString(), err.toString()); + int exitCode = p.waitFor(); + System.out.printf("[%s] process %d finished with exit code = %d%n", + Instant.now().toString(), p.pid(), exitCode); + return new ToolResults(exitCode, Files.readAllLines(out), Files.readAllLines(err)); } } From 131084c5a034fb2567d79340e43fbc12e2fec885 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:34:27 +0000 Subject: [PATCH 144/205] 8035787: SourcePositions are wrong for Strings concatenated with '+' operator Backport-of: 25642dd30317e77bc15d36d5fa512da5fb54dad9 --- .../javac/parser/StringFoldingPosTest.java | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 test/langtools/tools/javac/parser/StringFoldingPosTest.java diff --git a/test/langtools/tools/javac/parser/StringFoldingPosTest.java b/test/langtools/tools/javac/parser/StringFoldingPosTest.java new file mode 100644 index 00000000000..8836c36fba1 --- /dev/null +++ b/test/langtools/tools/javac/parser/StringFoldingPosTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2020, Google LLC. All rights reserved. + * 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 8134007 8035787 + * @summary folded string literals should have correct start and end positions + */ + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.LiteralTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.JavacTask; +import com.sun.source.util.SourcePositions; +import com.sun.source.util.TreeScanner; +import com.sun.source.util.Trees; + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class StringFoldingPosTest { + private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + + public static void main(String[] args) throws IOException { + StringFoldingPosTest t = new StringFoldingPosTest(); + JavaFileObject source = + t.makeSource( + "C", "class C {String X=\"F\" + \"O\" + \"L\" + \"D\" + \"E\" + \"D\";}"); + t.run(source, "FOLDED", 18, 51); + source = + t.makeSource( + "C", + "class C {String X=(\"F\" + \"O\") + (\"L\" + \"D\") + (\"E\" + \"D\");}"); + t.run(source, "FO", 19, 28); + t.run(source, "LD", 33, 42); + t.run(source, "ED", 47, 56); + } + + private static JavaFileObject makeSource(String name, String code) { + return new SimpleJavaFileObject( + URI.create( + "file:/" + name.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension), + JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return code; + } + }; + } + + private void run( + JavaFileObject source, + String expectedLiteral, + long expectedStartPos, + long expectedEndPos) + throws IOException { + JavacTask ct = + (JavacTask) compiler.getTask(null, null, null, null, null, Arrays.asList(source)); + SourcePositions positions = Trees.instance(ct).getSourcePositions(); + Iterable trees = ct.parse(); + boolean[] found = {false}; + for (CompilationUnitTree tree : trees) { + new TreeScanner() { + @Override + public Void visitLiteral(LiteralTree literal, Void v) { + if (literal.getKind() == Tree.Kind.STRING_LITERAL + && literal.getValue().equals(expectedLiteral)) { + long startPos = positions.getStartPosition(tree, literal); + long endPos = positions.getEndPosition(tree, literal); + if (startPos != expectedStartPos) { + throw new AssertionError( + "Expected start position " + + expectedStartPos + + ", but was " + + startPos); + } + if (endPos != expectedEndPos) { + throw new AssertionError( + "Expected end position " + + expectedEndPos + + ", but was " + + endPos); + } + found[0] = true; + } + return null; + } + }.scan(trees, null); + } + if (found[0]) { + return; + } + throw new AssertionError("Expected string literal " + expectedLiteral + " not found"); + } +} From d942151552b74fe020b09241b4e5353f2bf190bc Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 16 Feb 2023 10:38:49 +0000 Subject: [PATCH 145/205] 8209774: Refactor shell test javax/xml/jaxp/common/8035437/run.sh to java Backport-of: 4c54fa2274ab842dbecf72e201d5d5005eb38069 --- .../8035437/AbstractMethodErrorTest.java | 29 +++++-- .../xerces/internal/dom/DocumentImpl.java | 0 .../org/w3c/dom/Document.java | 0 .../{patch-src1 => }/org/w3c/dom/Node.java | 0 test/jdk/javax/xml/jaxp/common/8035437/run.sh | 75 ------------------- 5 files changed, 22 insertions(+), 82 deletions(-) rename test/jdk/javax/xml/jaxp/common/8035437/{patch-src2 => }/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java (100%) rename test/jdk/javax/xml/jaxp/common/8035437/{patch-src1 => }/org/w3c/dom/Document.java (100%) rename test/jdk/javax/xml/jaxp/common/8035437/{patch-src1 => }/org/w3c/dom/Node.java (100%) delete mode 100644 test/jdk/javax/xml/jaxp/common/8035437/run.sh diff --git a/test/jdk/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java b/test/jdk/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java index 142c468c164..1514b907516 100644 --- a/test/jdk/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java +++ b/test/jdk/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -28,7 +28,26 @@ import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; -class AbstractMethodErrorTest { +/* + * @test + * @bug 8035437 + * @summary Verifies that java.lang.AbstractMethodError is not thrown when + * serializing improper version of DocumentImpl class as reported in XERCESJ-1007. + * Test preconditions and steps: + * - Compiles test version of org.w3c.dom.Node and org.w3c.dom.Document + * - Compiles DocumentImpl overriding java.xml module with Node and Document + * - Runs AbstractMethodErrorTest overriding java.xml only with DocumentImpl class + * Hence, the interfaces compiled in the first step need to be removed + * from the test folder in order to reproduce the bug scenario. At the time of writing, + * the clean command was not able to resolve paths generated by compile/module + * @library /test/lib + * @compile --patch-module java.xml=${test.src} org/w3c/dom/Document.java + * org/w3c/dom/Node.java com/sun/org/apache/xerces/internal/dom/DocumentImpl.java + * @clean org.w3c.dom.* + * @run main/othervm --patch-module java.xml=${test.class.path} AbstractMethodErrorTest + */ + +public class AbstractMethodErrorTest { public static void main(String[] args) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -39,11 +58,7 @@ public static void main(String[] args) throws Exception { DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0"); LSSerializer dsi = implLS.createLSSerializer(); - /* We should have here incorrect document without getXmlVersion() method: - * Such Document is generated by replacing the JDK bootclasses with it's - * own Node,Document and DocumentImpl classes (see run.sh). According to - * XERCESJ-1007 the AbstractMethodError should be thrown in such case. - */ + // We should have here incorrect document without getXmlVersion() method String result = dsi.writeToString(document); System.out.println("Result:" + result); } diff --git a/test/jdk/javax/xml/jaxp/common/8035437/patch-src2/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java b/test/jdk/javax/xml/jaxp/common/8035437/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java similarity index 100% rename from test/jdk/javax/xml/jaxp/common/8035437/patch-src2/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java rename to test/jdk/javax/xml/jaxp/common/8035437/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java diff --git a/test/jdk/javax/xml/jaxp/common/8035437/patch-src1/org/w3c/dom/Document.java b/test/jdk/javax/xml/jaxp/common/8035437/org/w3c/dom/Document.java similarity index 100% rename from test/jdk/javax/xml/jaxp/common/8035437/patch-src1/org/w3c/dom/Document.java rename to test/jdk/javax/xml/jaxp/common/8035437/org/w3c/dom/Document.java diff --git a/test/jdk/javax/xml/jaxp/common/8035437/patch-src1/org/w3c/dom/Node.java b/test/jdk/javax/xml/jaxp/common/8035437/org/w3c/dom/Node.java similarity index 100% rename from test/jdk/javax/xml/jaxp/common/8035437/patch-src1/org/w3c/dom/Node.java rename to test/jdk/javax/xml/jaxp/common/8035437/org/w3c/dom/Node.java diff --git a/test/jdk/javax/xml/jaxp/common/8035437/run.sh b/test/jdk/javax/xml/jaxp/common/8035437/run.sh deleted file mode 100644 index 9b1d327e6d2..00000000000 --- a/test/jdk/javax/xml/jaxp/common/8035437/run.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh - -## -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. -# 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 8035437 -# @summary Tests that java.lang.AbstractMethodError is not thrown when -# serializing improper version of DocumentImpl class. - -OS=`uname -s` -case "$OS" in - SunOS ) - PS=":" - ;; - Linux ) - PS=":" - ;; - Darwin ) - PS=":" - ;; - AIX ) - PS=":" - ;; - Windows*) - PS=";" - ;; - CYGWIN*) - PS=";" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -mkdir -p exec/java.xml compile/java.xml - -$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - -d compile/java.xml --patch-module java.xml=$TESTSRC/patch-src1 \ - $TESTSRC/patch-src1/org/w3c/dom/Document.java \ - $TESTSRC/patch-src1/org/w3c/dom/Node.java || exit 1 - -$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - -d exec/java.xml --patch-module java.xml=compile/java.xml${PS}$TESTSRC/patch-src2 \ - $TESTSRC/patch-src2/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java \ - || exit 2 - -$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - $TESTSRC/AbstractMethodErrorTest.java -d exec || exit 3 - -$TESTJAVA/bin/java ${TESTVMOPTS} --patch-module java.xml=exec -cp exec AbstractMethodErrorTest || exit 4 - -exit 0 - From 630c80ebea296b25613787bb459caffef6b2f8f0 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 16 Feb 2023 12:44:38 +0000 Subject: [PATCH 146/205] 8293550: Optionally add get-task-allow entitlement to macos binaries Reviewed-by: phh Backport-of: da6fca4d78465625775f7b384ba752185694f699 --- doc/building.html | 9 ++ doc/building.md | 36 +++++++ make/Bundles.gmk | 11 +-- make/autoconf/basic_tools.m4 | 35 ------- make/autoconf/configure.ac | 1 + make/autoconf/jdk-options.m4 | 102 ++++++++++++++++++++ make/autoconf/spec.gmk.in | 3 +- make/common/NativeCompilation.gmk | 16 ++- make/data/macosxsigning/default-debug.plist | 18 ++++ make/data/macosxsigning/java-debug.plist | 20 ++++ 10 files changed, 200 insertions(+), 51 deletions(-) create mode 100644 make/data/macosxsigning/default-debug.plist create mode 100644 make/data/macosxsigning/java-debug.plist diff --git a/doc/building.html b/doc/building.html index a117465c340..842e7fa9947 100644 --- a/doc/building.html +++ b/doc/building.html @@ -72,6 +72,9 @@

      Building the JDK

    • Make Control Variables
  • Running Tests
  • +
  • Signing
  • Cross-compiling
    • Cross compiling the easy way with OpenJDK devkits
    • Boot JDK and Build JDK
    • @@ -583,6 +586,12 @@

      Running Tests

      To execute the most basic tests (tier 1), use:

      make run-test-tier1

      For more details on how to run tests, please see Testing the JDK (html, markdown).

      +

      Signing

      +

      macOS

      +

      Modern versions of macOS require applications to be signed and notarizied before distribution. See Apple's documentation for more background on what this means and how it works. To help support this, the JDK build can be configured to automatically sign all native binaries, and the JDK bundle, with all the options needed for successful notarization, as well as all the entitlements required by the JDK. To enable hardened signing, use configure parameter --with-macosx-codesign=hardened and configure the signing identity you wish to use with --with-macosx-codesign-identity=<identity>. The identity refers to a signing identity from Apple that needs to be preinstalled on the build host.

      +

      When not signing for distribution with the hardened option, the JDK build will still attempt to perform adhoc signing to add the special entitlement com.apple.security.get-task-allow to each binary. This entitlement is required to be able to dump core files from a process. Note that adding this entitlement makes the build invalid for notarization, so it is only added when signing in debug mode. To explicitly enable this kind of adhoc signing, use configure parameter --with-macosx-codesign=debug. It will be enabled by default in most cases.

      +

      It's also possible to completely disable any explicit codesign operations done by the JDK build using the configure parameter --without-macosx-codesign. The exact behavior then depends on the architecture. For macOS on x64, it (at least at the time of this writing) results in completely unsigned binaries that should still work fine for development and debugging purposes. On aarch64, the Xcode linker will apply a default "adhoc" signing, without any entitlements. Such a build does not allow dumping core files.

      +

      The default mode "auto" will try for hardened signing if the debug level is release and either the default identity or the specified identity is valid. If hardened isn't possible, then debug signing is chosen if it works. If nothing works, the codesign build step is disabled.

      Cross-compiling

      Cross-compiling means using one platform (the build platform) to generate output that can ran on another platform (the target platform).

      The typical reason for cross-compiling is that the build is performed on a more powerful desktop computer, but the resulting binaries will be able to run on a different, typically low-performing system. Most of the complications that arise when building for embedded is due to this separation of build and target systems.

      diff --git a/doc/building.md b/doc/building.md index 24c09bd04e3..60d4d73a638 100644 --- a/doc/building.md +++ b/doc/building.md @@ -876,6 +876,42 @@ make run-test-tier1 For more details on how to run tests, please see **Testing the JDK** ([html](testing.html), [markdown](testing.md)). +## Signing + +### macOS + +Modern versions of macOS require applications to be signed and notarizied before +distribution. See Apple's documentation for more background on what this means +and how it works. To help support this, the JDK build can be configured to +automatically sign all native binaries, and the JDK bundle, with all the options +needed for successful notarization, as well as all the entitlements required by +the JDK. To enable `hardened` signing, use configure parameter +`--with-macosx-codesign=hardened` and configure the signing identity you wish to +use with `--with-macosx-codesign-identity=`. The identity refers to a +signing identity from Apple that needs to be preinstalled on the build host. + +When not signing for distribution with the hardened option, the JDK build will +still attempt to perform `adhoc` signing to add the special entitlement +`com.apple.security.get-task-allow` to each binary. This entitlement is required +to be able to dump core files from a process. Note that adding this entitlement +makes the build invalid for notarization, so it is only added when signing in +`debug` mode. To explicitly enable this kind of adhoc signing, use configure +parameter `--with-macosx-codesign=debug`. It will be enabled by default in most +cases. + +It's also possible to completely disable any explicit codesign operations done +by the JDK build using the configure parameter `--without-macosx-codesign`. +The exact behavior then depends on the architecture. For macOS on x64, it (at +least at the time of this writing) results in completely unsigned binaries that +should still work fine for development and debugging purposes. On aarch64, the +Xcode linker will apply a default "adhoc" signing, without any entitlements. +Such a build does not allow dumping core files. + +The default mode "auto" will try for `hardened` signing if the debug level is +`release` and either the default identity or the specified identity is valid. +If hardened isn't possible, then `debug` signing is chosen if it works. If +nothing works, the codesign build step is disabled. + ## Cross-compiling Cross-compiling means using one platform (the *build* platform) to generate diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 55cb343e0bd..81a1688752b 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -288,16 +288,7 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), ) $(SYMBOLS_EXCLUDE_PATTERN), \ $(ALL_JRE_FILES)) - # On Macosx release builds, when there is a code signing certificate available, - # the final bundle layout can be signed. - SIGN_BUNDLE := false - ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) - ifneq ($(CODESIGN), ) - SIGN_BUNDLE := true - endif - endif - - ifeq ($(SIGN_BUNDLE), true) + ifeq ($(MACOSX_CODESIGN_MODE), hardened) # Macosx release build and code signing available. ################################################################################ diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index e2131029a54..c3c48f8c21b 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -369,41 +369,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], UTIL_REQUIRE_PROGS(MIG, mig) UTIL_REQUIRE_PROGS(XATTR, xattr) UTIL_LOOKUP_PROGS(CODESIGN, codesign) - - # Check for user provided code signing identity. - UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, - DEFAULT: openjdk_codesign, CHECK_VALUE: UTIL_CHECK_STRING_NON_EMPTY, - DESC: [specify the macosx code signing identity], - CHECKING_MSG: [for macosx code signing identity] - ) - AC_SUBST(MACOSX_CODESIGN_IDENTITY) - - if test "x$CODESIGN" != "x"; then - # Verify that the codesign certificate is present - AC_MSG_CHECKING([if codesign certificate is present]) - $RM codesign-testfile - $TOUCH codesign-testfile - $CODESIGN -s "$MACOSX_CODESIGN_IDENTITY" codesign-testfile 2>&AS_MESSAGE_LOG_FD \ - >&AS_MESSAGE_LOG_FD || CODESIGN= - $RM codesign-testfile - if test "x$CODESIGN" = x; then - AC_MSG_RESULT([no]) - else - AC_MSG_RESULT([yes]) - # Verify that the codesign has --option runtime - AC_MSG_CHECKING([if codesign has --option runtime]) - $RM codesign-testfile - $TOUCH codesign-testfile - $CODESIGN --option runtime -s "$MACOSX_CODESIGN_IDENTITY" codesign-testfile \ - 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN= - $RM codesign-testfile - if test "x$CODESIGN" = x; then - AC_MSG_ERROR([codesign does not have --option runtime. macOS 10.13.6 and above is required.]) - else - AC_MSG_RESULT([yes]) - fi - fi - fi UTIL_REQUIRE_PROGS(SETFILE, SetFile) elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then UTIL_REQUIRE_PROGS(ELFEDIT, elfedit) diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index 6192411da41..a2c0c1a8f5c 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -237,6 +237,7 @@ JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST JDKOPT_EXCLUDE_TRANSLATIONS JDKOPT_ENABLE_DISABLE_MANPAGES JDKOPT_SETUP_REPRODUCIBLE_BUILD +JDKOPT_SETUP_MACOSX_SIGNING ############################################################################### # diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index fc02940d0c2..e67ffd47e5b 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -756,3 +756,105 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD], AC_SUBST(SOURCE_DATE) AC_SUBST(ENABLE_REPRODUCIBLE_BUILD) ]) + +################################################################################ +# +# Setup signing on macOS. This can either be setup to sign with a real identity +# and enabling the hardened runtime, or it can simply add the debug entitlement +# com.apple.security.get-task-allow without actually signing any binaries. The +# latter is needed to be able to debug processes and dump core files on modern +# versions of macOS. It can also be skipped completely. +# +# Check if codesign will run with the given parameters +# $1: Parameters to run with +# $2: Checking message +# Sets CODESIGN_SUCCESS=true/false +AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS], +[ + PARAMS="$1" + MESSAGE="$2" + CODESIGN_TESTFILE="$CONFIGURESUPPORT_OUTPUTDIR/codesign-testfile" + $RM "$CODESIGN_TESTFILE" + $TOUCH "$CODESIGN_TESTFILE" + CODESIGN_SUCCESS=false + $CODESIGN $PARAMS "$CODESIGN_TESTFILE" 2>&AS_MESSAGE_LOG_FD \ + >&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true + $RM "$CODESIGN_TESTFILE" + AC_MSG_CHECKING([$MESSAGE]) + if test "x$CODESIGN_SUCCESS" = "xtrue"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi +]) + +AC_DEFUN([JDKOPT_CHECK_CODESIGN_HARDENED], +[ + JDKOPT_CHECK_CODESIGN_PARAMS([-s "$MACOSX_CODESIGN_IDENTITY" --option runtime], + [if codesign with hardened runtime is possible]) +]) + +AC_DEFUN([JDKOPT_CHECK_CODESIGN_DEBUG], +[ + JDKOPT_CHECK_CODESIGN_PARAMS([-s -], [if debug mode codesign is possible]) +]) + +AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING], +[ + ENABLE_CODESIGN=false + if test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$CODESIGN" != "x"; then + + UTIL_ARG_WITH(NAME: macosx-codesign, TYPE: literal, OPTIONAL: true, + VALID_VALUES: [hardened debug auto], DEFAULT: auto, + ENABLED_DEFAULT: true, + CHECKING_MSG: [for macosx code signing mode], + DESC: [set the macosx code signing mode (hardened, debug, auto)] + ) + + MACOSX_CODESIGN_MODE=disabled + if test "x$MACOSX_CODESIGN_ENABLED" = "xtrue"; then + + # Check for user provided code signing identity. + UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, + DEFAULT: openjdk_codesign, CHECK_VALUE: UTIL_CHECK_STRING_NON_EMPTY, + DESC: [specify the macosx code signing identity], + CHECKING_MSG: [for macosx code signing identity] + ) + AC_SUBST(MACOSX_CODESIGN_IDENTITY) + + if test "x$MACOSX_CODESIGN" = "xauto"; then + # Only try to default to hardened signing on release builds + if test "x$DEBUG_LEVEL" = "xrelease"; then + JDKOPT_CHECK_CODESIGN_HARDENED + if test "x$CODESIGN_SUCCESS" = "xtrue"; then + MACOSX_CODESIGN_MODE=hardened + fi + fi + if test "x$MACOSX_CODESIGN_MODE" = "xdisabled"; then + JDKOPT_CHECK_CODESIGN_DEBUG + if test "x$CODESIGN_SUCCESS" = "xtrue"; then + MACOSX_CODESIGN_MODE=debug + fi + fi + AC_MSG_CHECKING([for macosx code signing mode]) + AC_MSG_RESULT([$MACOSX_CODESIGN_MODE]) + elif test "x$MACOSX_CODESIGN" = "xhardened"; then + JDKOPT_CHECK_CODESIGN_HARDENED + if test "x$CODESIGN_SUCCESS" = "xfalse"; then + AC_MSG_ERROR([Signing with hardened runtime is not possible]) + fi + MACOSX_CODESIGN_MODE=hardened + elif test "x$MACOSX_CODESIGN" = "xdebug"; then + JDKOPT_CHECK_CODESIGN_DEBUG + if test "x$CODESIGN_SUCCESS" = "xfalse"; then + AC_MSG_ERROR([Signing in debug mode is not possible]) + fi + MACOSX_CODESIGN_MODE=debug + else + AC_MSG_ERROR([unknown value for --with-macosx-codesign: $MACOSX_CODESIGN]) + fi + fi + AC_SUBST(MACOSX_CODESIGN_IDENTITY) + AC_SUBST(MACOSX_CODESIGN_MODE) + fi +]) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 51dad49d1ac..3787b126002 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -422,7 +422,8 @@ MACOSX_VERSION_MIN=@MACOSX_VERSION_MIN@ # The highest allowed version of macosx MACOSX_VERSION_MAX=@MACOSX_VERSION_MAX@ -# The macosx code signing identity to use +# The macosx code signing configuration +MACOSX_CODESIGN_MODE:=@MACOSX_CODESIGN_MODE@ MACOSX_CODESIGN_IDENTITY=@MACOSX_CODESIGN_IDENTITY@ # Toolchain type: gcc, clang, solstudio, lxc, microsoft... diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 8eeb6def43d..6189810888e 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -283,10 +283,15 @@ endif # specialized file is found, returns the default file. # $1 Executable to find entitlements file for. ENTITLEMENTS_DIR := $(TOPDIR)/make/data/macosxsigning -DEFAULT_ENTITLEMENTS_FILE := $(ENTITLEMENTS_DIR)/default.plist +ifeq ($(MACOSX_CODESIGN_MODE), debug) + CODESIGN_PLIST_SUFFIX := -debug +else + CODESIGN_PLIST_SUFFIX := +endif +DEFAULT_ENTITLEMENTS_FILE := $(ENTITLEMENTS_DIR)/default$(CODESIGN_PLIST_SUFFIX).plist GetEntitlementsFile = \ - $(foreach f, $(ENTITLEMENTS_DIR)/$(strip $(notdir $1)).plist, \ + $(foreach f, $(ENTITLEMENTS_DIR)/$(strip $(notdir $1))$(CODESIGN_PLIST_SUFFIX).plist, \ $(if $(wildcard $f), $f, $(DEFAULT_ENTITLEMENTS_FILE)) \ ) @@ -1204,11 +1209,12 @@ define SetupNativeCompilationBody $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 endif endif - # This only works if the openjdk_codesign identity is present on the system. Let - # silently fail otherwise. - ifneq ($(CODESIGN), ) + # On macosx, optionally run codesign on every binary + ifeq ($(MACOSX_CODESIGN_MODE), hardened) $(CODESIGN) -f -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime \ --entitlements $$(call GetEntitlementsFile, $$@) $$@ + else ifeq ($(MACOSX_CODESIGN_MODE), debug) + $(CODESIGN) -f -s - --entitlements $$(call GetEntitlementsFile, $$@) $$@ endif endif diff --git a/make/data/macosxsigning/default-debug.plist b/make/data/macosxsigning/default-debug.plist new file mode 100644 index 00000000000..40041790f6a --- /dev/null +++ b/make/data/macosxsigning/default-debug.plist @@ -0,0 +1,18 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.debugger + + com.apple.security.get-task-allow + + + diff --git a/make/data/macosxsigning/java-debug.plist b/make/data/macosxsigning/java-debug.plist new file mode 100644 index 00000000000..354919ff1b4 --- /dev/null +++ b/make/data/macosxsigning/java-debug.plist @@ -0,0 +1,20 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.debugger + + com.apple.security.device.audio-input + + com.apple.security.get-task-allow + + + From 06ee0b67cdf1449cd198d24f0feff1b404090c8e Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 16 Feb 2023 12:45:37 +0000 Subject: [PATCH 147/205] 8297963: Partially fix string expansion issues in UTIL_DEFUN_NAMED and related macros Backport-of: 1a38e26e67570ac01de6e969114b476df933d1eb --- make/autoconf/flags.m4 | 8 ++++---- make/autoconf/util.m4 | 45 +++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index a5b4afd7418..5a3ea964564 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -506,14 +506,14 @@ UTIL_DEFUN_NAMED([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS], UTIL_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS], [*ARGUMENT IF_TRUE IF_FALSE PREFIX], [$@], [ - FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT], + FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: ARG_ARGUMENT, IF_TRUE: [C_COMP_SUPPORTS="yes"], IF_FALSE: [C_COMP_SUPPORTS="no"], - PREFIX: [ARG_PREFIX]) - FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT], + PREFIX: ARG_PREFIX) + FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: ARG_ARGUMENT, IF_TRUE: [CXX_COMP_SUPPORTS="yes"], IF_FALSE: [CXX_COMP_SUPPORTS="no"], - PREFIX: [ARG_PREFIX]) + PREFIX: ARG_PREFIX) AC_MSG_CHECKING([if both ARG_PREFIX[CC] and ARG_PREFIX[CXX] support "ARG_ARGUMENT"]) supports=no diff --git a/make/autoconf/util.m4 b/make/autoconf/util.m4 index 5bf599e1e1f..7be5d52424c 100644 --- a/make/autoconf/util.m4 +++ b/make/autoconf/util.m4 @@ -52,7 +52,7 @@ m4_include([util_paths.m4]) AC_DEFUN([UTIL_DEFUN_NAMED], [ AC_DEFUN($1, [ - m4_foreach(arg, m4_split(m4_normalize($2)), [ + m4_foreach([arg], m4_split(m4_normalize($2)), [ m4_if(m4_bregexp(arg, [^\*]), -1, [ m4_set_add(legal_named_args, arg) @@ -64,13 +64,18 @@ AC_DEFUN([UTIL_DEFUN_NAMED], ) ]) - m4_foreach([arg], [$3], [ - m4_if(m4_bregexp(arg, [: ]), -1, m4_define([arg], m4_bpatsubst(arg, [:], [: ]))) - m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ]))) + # Delicate quoting and unquoting sequence to ensure the actual value is passed along unchanged + # For details on how this works, see https://git.openjdk.org/jdk/pull/11458#discussion_r1038173051 + # WARNING: Proceed at the risk of your own sanity, getting this to work has made me completely + # incapable of feeling love or any other positive emotion + # ~Julian + m4_foreach([arg], m4_dquote(m4_dquote_elt($3)), [ + m4_if(m4_index(arg, [: ]), -1, [m4_define([arg], m4_dquote(m4_bpatsubst(m4_dquote(arg), [:], [: ])))]) + m4_define(arg_name, m4_substr(arg, 0, m4_index(arg, [: ]))) m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: m4_if(arg_name, , arg, arg_name) is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(defined_args, [ ]) m4_set_contents(legal_named_args, [ ])'.])]) m4_set_remove(required_named_args, arg_name) m4_set_remove(legal_named_args, arg_name) - m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))), [^\s*], [])) + m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_bpatsubst(m4_dquote(m4_dquote(arg)), arg_name[: ]), [^\s*])) m4_set_add(defined_args, arg_name) m4_undefine([arg_name]) ]) @@ -380,18 +385,18 @@ UTIL_DEFUN_NAMED([UTIL_ARG_ENABLE], m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN]) # If DESC is not specified, set it to a generic description. - m4_define([ARG_DESC], m4_if(ARG_DESC, , [Enable the ARG_NAME feature], m4_normalize(ARG_DESC))) + m4_define([ARG_DESC], m4_if(m4_quote(ARG_DESC), , [[Enable the ARG_NAME feature]], [m4_normalize(ARG_DESC)])) # If CHECKING_MSG is not specified, set it to a generic description. - m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --enable-ARG_NAME], m4_normalize(ARG_CHECKING_MSG))) + m4_define([ARG_CHECKING_MSG], m4_if(m4_quote(ARG_CHECKING_MSG), , [[for --enable-ARG_NAME]], [m4_normalize(ARG_CHECKING_MSG)])) # If the code blocks are not given, set them to the empty statements to avoid # tripping up bash. - m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE)) - m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN)) - m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN)) - m4_define([ARG_IF_ENABLED], m4_if(ARG_IF_ENABLED, , :, ARG_IF_ENABLED)) - m4_define([ARG_IF_DISABLED], m4_if(ARG_IF_DISABLED, , :, ARG_IF_DISABLED)) + m4_if(ARG_CHECK_AVAILABLE, , [m4_define([ARG_CHECK_AVAILABLE], [:])]) + m4_if(ARG_IF_GIVEN, , [m4_define([ARG_IF_GIVEN], [:])]) + m4_if(ARG_IF_NOT_GIVEN, , [m4_define([ARG_IF_NOT_GIVEN], [:])]) + m4_if(ARG_IF_ENABLED, , [m4_define([ARG_IF_ENABLED], [:])]) + m4_if(ARG_IF_DISABLED, , [m4_define([ARG_IF_DISABLED], [:])]) ########################## # Part 2: Set up autoconf shell code @@ -654,21 +659,21 @@ UTIL_DEFUN_NAMED([UTIL_ARG_WITH], m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN]) # If DESC is not specified, set it to a generic description. - m4_define([ARG_DESC], m4_if(ARG_DESC, , [Give a value for the ARG_NAME feature], m4_normalize(ARG_DESC))) + m4_define([ARG_DESC], m4_if(m4_quote(ARG_DESC), , [[Give a value for the ARG_NAME feature]], [m4_normalize(ARG_DESC)])) # If CHECKING_MSG is not specified, set it to a generic description. - m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --with-ARG_NAME], m4_normalize(ARG_CHECKING_MSG))) + m4_define([ARG_CHECKING_MSG], m4_if(m4_quote(ARG_CHECKING_MSG), , [[for --with-ARG_NAME]], [m4_normalize(ARG_CHECKING_MSG)])) m4_define([ARG_HAS_AUTO_BLOCK], m4_if(ARG_IF_AUTO, , false, true)) # If the code blocks are not given, set them to the empty statements to avoid # tripping up bash. - m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE)) - m4_define([ARG_CHECK_VALUE], m4_if(ARG_CHECK_VALUE, , :, ARG_CHECK_VALUE)) - m4_define([ARG_CHECK_FOR_FILES], m4_if(ARG_CHECK_FOR_FILES, , :, ARG_CHECK_FOR_FILES)) - m4_define([ARG_IF_AUTO], m4_if(ARG_IF_AUTO, , :, ARG_IF_AUTO)) - m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN)) - m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN)) + m4_if(ARG_CHECK_AVAILABLE, , [m4_define([ARG_CHECK_AVAILABLE], [:])]) + m4_if(ARG_CHECK_VALUE, , [m4_define([ARG_CHECK_VALUE], [:])]) + m4_if(ARG_CHECK_FOR_FILES, , [m4_define([ARG_CHECK_FOR_FILES], [:])]) + m4_if(ARG_IF_AUTO, , [m4_define([ARG_IF_AUTO], [:])]) + m4_if(ARG_IF_GIVEN, , [m4_define([ARG_IF_GIVEN], [:])]) + m4_if(ARG_IF_NOT_GIVEN, , [m4_define([ARG_IF_NOT_GIVEN], [:])]) ########################## # Part 2: Set up autoconf shell code From 136414034636feabe2010fd8f6fdef839d6b9227 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 16 Feb 2023 16:18:27 +0000 Subject: [PATCH 148/205] 8284165: Add pid to process reaper thread name Reviewed-by: phh Backport-of: 9561b5e041c4cc70319e60953819c521c1e68d6c --- .../classes/java/lang/ProcessHandleImpl.java | 55 +++++++++++-------- .../java/util/concurrent/Phaser/Basic.java | 2 +- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index c7255b96e68..3eb6ba52e3e 100644 --- a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -135,33 +135,40 @@ static CompletableFuture completion(long pid, boolean shouldReap) { processReaperExecutor.execute(new Runnable() { // Use inner class to avoid lambda stack overhead public void run() { - int exitValue = waitForProcessExit0(pid, shouldReap); - if (exitValue == NOT_A_CHILD) { - // pid not alive or not a child of this process - // If it is alive wait for it to terminate - long sleep = 300; // initial milliseconds to sleep - int incr = 30; // increment to the sleep time - - long startTime = isAlive0(pid); - long origStart = startTime; - while (startTime >= 0) { - try { - Thread.sleep(Math.min(sleep, 5000L)); // no more than 5 sec - sleep += incr; - } catch (InterruptedException ie) { - // ignore and retry - } - startTime = isAlive0(pid); // recheck if it is alive - if (startTime > 0 && origStart > 0 && startTime != origStart) { - // start time changed (and is not zero), pid is not the same process - break; + String threadName = Thread.currentThread().getName(); + Thread.currentThread().setName("process reaper (pid " + pid + ")"); + try { + int exitValue = waitForProcessExit0(pid, shouldReap); + if (exitValue == NOT_A_CHILD) { + // pid not alive or not a child of this process + // If it is alive wait for it to terminate + long sleep = 300; // initial milliseconds to sleep + int incr = 30; // increment to the sleep time + + long startTime = isAlive0(pid); + long origStart = startTime; + while (startTime >= 0) { + try { + Thread.sleep(Math.min(sleep, 5000L)); // no more than 5 sec + sleep += incr; + } catch (InterruptedException ie) { + // ignore and retry + } + startTime = isAlive0(pid); // recheck if it is alive + if (startTime > 0 && origStart > 0 && startTime != origStart) { + // start time changed (and is not zero), pid is not the same process + break; + } } + exitValue = 0; } - exitValue = 0; + newCompletion.complete(exitValue); + // remove from cache afterwards + completions.remove(pid, newCompletion); + } finally { + // Restore thread name + Thread.currentThread().setName(threadName); } - newCompletion.complete(exitValue); - // remove from cache afterwards - completions.remove(pid, newCompletion); } }); } diff --git a/test/jdk/java/util/concurrent/Phaser/Basic.java b/test/jdk/java/util/concurrent/Phaser/Basic.java index 99356cd7c7a..2ea09dced99 100644 --- a/test/jdk/java/util/concurrent/Phaser/Basic.java +++ b/test/jdk/java/util/concurrent/Phaser/Basic.java @@ -440,7 +440,7 @@ static void dumpTestThreads() { if ("Finalizer".equals(name) && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock")) continue; - if ("process reaper".equals(name)) + if (name.startsWith("process reaper")) continue; if (name != null && name.startsWith("ForkJoinPool.commonPool-worker")) continue; From bfd05a62565ba73e27efa4dc02a4285b1595afcb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:14:37 +0000 Subject: [PATCH 149/205] 8302657: [11u] Add missing '(' in makefile after backport of 8218431 Reviewed-by: dsamersoff --- make/hotspot/lib/JvmFlags.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index 903a6192f52..3246c83155b 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -74,7 +74,7 @@ ifeq ($(DEBUG_LEVEL), release) endif else ifeq ($(DEBUG_LEVEL), fastdebug) JVM_CFLAGS_DEBUGLEVEL := -DASSERT - ifeq ($call isTargetOs, windows aix), false) + ifeq ($(call isTargetOs, windows aix), false) # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX. JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS endif From 98e3b0d08d3d621e1f545489a9eb06268b3c3f3b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:20:14 +0000 Subject: [PATCH 150/205] 8202621: bad test with broken links needs to be updated Backport-of: 17773c31b62cc4e040e69e05e63d2d4e52334221 --- .../doclet/DocRootSlash/DocRootSlash.java | 12 ++--- .../javadoc/doclet/DocRootSlash/overview.html | 52 ++++++------------- .../javadoc/doclet/DocRootSlash/p1/C1.java | 38 +++----------- .../doclet/DocRootSlash/p1/package.html | 50 +++++------------- 4 files changed, 41 insertions(+), 111 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java b/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java index 1b5d3765c39..b887385df5f 100644 --- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java +++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java @@ -51,13 +51,12 @@ void test() { // Directory that contains source files that javadoc runs on String srcdir = System.getProperty("test.src", "."); - setAutomaticCheckLinks(false); // @ignore JDK-8202621 javadoc("-d", "out", "-Xdoclint:none", "-overview", (srcdir + "/overview.html"), "--frames", - "-header", "{@docroot} {@docRoot}", + "-header", "{@docroot} {@docRoot}", "-sourcepath", srcdir, "p1", "p2"); @@ -69,8 +68,8 @@ void test() { // Bug 4633447: Special test for overview-frame.html // Find two strings in file "overview-frame.html" checkOutput("overview-frame.html", true, - "", - ""); + "", + ""); } void checkFiles(String... filenameArray) { @@ -81,7 +80,7 @@ void checkFiles(String... filenameArray) { String fileString = readFile(f); System.out.println("\nSub-tests for file: " + f + " --------------"); // Loop over all tests in a single file - for ( int j = 0; j < 11; j++ ) { + for ( int j = 0; j < 7; j++ ) { // Compare actual to expected string for a single subtest compareActualToExpected(++count, fileString); @@ -107,9 +106,6 @@ void checkFiles(String... filenameArray) { */ private static final String prefix = "(?i)()"; // doublequotes (end group1, group2, group3) - private static final String ref2 = ")(\\S+?)([^<>]*>)"; // no quotes (end group1, group2, group3) - private static final String label = "(.*?)"; // text label (group4) - private static final String end = "()"; // (group5) /** * Compares the actual string to the expected string in the specified string diff --git a/test/langtools/jdk/javadoc/doclet/DocRootSlash/overview.html b/test/langtools/jdk/javadoc/doclet/DocRootSlash/overview.html index 56ccb05b517..766bce489e1 100644 --- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/overview.html +++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/overview.html @@ -9,55 +9,33 @@ Case 0 Actual: .   Current directory

      -Sub-test 23 Actual: {@docroot} Bare tag - ALL LOWERCASE
      -Sub-test 23 Expect:
      -(Expect empty string because lowercase docroot is illegal) +Sub-test 15 Actual: {@docroot} Bare tag - ALL LOWERCASE
      +Sub-test 15 Expect:
      +(Expect empty string because lowercase docroot is illegal)

      -Sub-test 24 Actual: {@docRoot} Bare tag - "R" UPPERCASE
      -Sub-test 24 Expect: . +Sub-test 16 Actual: {@docRoot} Bare tag - "R" UPPERCASE
      +Sub-test 16 Expect: .

      -Sub-test 25 Actual: {@docRoot}/package-list
      -Sub-test 25 Expect: ./package-list +Sub-test 17 Actual: {@docRoot}/element-list
      +Sub-test 17 Expect: ./element-list

      -Sub-test 26 Actual: {@docRoot}/p2/C2.html
      -Sub-test 26 Expect: ./p2/C2.html +Sub-test 18 Actual: {@docRoot}/p2/C2.html
      +Sub-test 18 Expect: ./p2/C2.html

      -Sub-test 27 Actual: {@docRoot}/../docs1/p2/C2.html
      -Sub-test 27 Expect: ./../docs1/p2/C2.html +Sub-test 19 Actual: {@docRoot}/../out/p2/C2.html
      +Sub-test 19 Expect: ./../out/p2/C2.html

      -Sub-test 28 Actual: {@docRoot}/p2/package-summary.html#package_description
      -Sub-test 28 Expect: ./p2/package-summary.html#package_description +Sub-test 20 Actual: {@docRoot}/p2/package-summary.html#package.description
      +Sub-test 20 Expect: ./p2/package-summary.html#package.description

      -Sub-test 29 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      -Sub-test 29 Expect: ./../docs1/p2/package-summary.html#package_description -

      - - - -Allow docRoot to work without a trailing slash for those who had to change their comments -to work with the 1.4.0 bug: -

      - -Sub-test 30 Actual: {@docRoot}p2/C2.html
      -Sub-test 30 Expect: ./p2/C2.html -

      - -Sub-test 31 Actual: {@docRoot}../docs1/p2/C2.html
      -Sub-test 31 Expect: ./../docs1/p2/C2.html -

      - -Sub-test 32 Actual: {@docRoot}/p2/package-summary.html#package_description
      -Sub-test 32 Expect: ./p2/package-summary.html#package_description - -

      -Sub-test 33 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      -Sub-test 33 Expect: ./../docs1/p2/package-summary.html#package_description +Sub-test 21 Actual: {@docRoot}/../out/p2/package-summary.html#package.description
      +Sub-test 21 Expect: ./../out/p2/package-summary.html#package.description diff --git a/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/C1.java b/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/C1.java index 69f8df4dc4c..51a345a0890 100644 --- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/C1.java +++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/C1.java @@ -39,46 +39,24 @@ * Sub-test 2 Expect: .. *

      * - * Sub-test 3 Actual: {@docRoot}/package-list
      - * Sub-test 3 Expect: ../package-list + * Sub-test 3 Actual: {@docRoot}/element-list
      + * Sub-test 3 Expect: ../element-list *

      * * Sub-test 4 Actual: {@docRoot}/p2/C2.html
      * Sub-test 4 Expect: ../p2/C2.html *

      * - * Sub-test 5 Actual: {@docRoot}/../docs1/p2/C2.html
      - * Sub-test 5 Expect: ../../docs1/p2/C2.html + * Sub-test 5 Actual: {@docRoot}/../out/p2/C2.html
      + * Sub-test 5 Expect: ../../out/p2/C2.html *

      * - * Sub-test 6 Actual: {@docRoot}/p2/package-summary.html#package_description
      - * Sub-test 6 Expect: ../p2/package-summary.html#package_description + * Sub-test 6 Actual: {@docRoot}/p2/package-summary.html#package.description
      + * Sub-test 6 Expect: ../p2/package-summary.html#package.description *

      * - * Sub-test 7 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      - * Sub-test 7 Expect: ../../docs1/p2/package-summary.html#package_description - *

      - * - * - * - * Allow docRoot to work without a trailing slash for those who had to change their comments - * to work with the 1.4.0 bug: - *

      - * - * Sub-test 8 Actual: {@docRoot}p2/C2.html
      - * Sub-test 8 Expect: ../p2/C2.html - *

      - * - * Sub-test 9 Actual: {@docRoot}../docs1/p2/C2.html
      - * Sub-test 9 Expect: ../../docs1/p2/C2.html - *

      - * - * Sub-test 10 Actual: {@docRoot}/p2/package-summary.html#package_description
      - * Sub-test 10 Expect: ../p2/package-summary.html#package_description#package_description - *

      - * - * Sub-test 11 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      - * Sub-test 11 Expect: ../../docs1/p2/package-summary.html#package_description + * Sub-test 7 Actual: {@docRoot}/../out/p2/package-summary.html#package.description
      + * Sub-test 7 Expect: ../../out/p2/package-summary.html#package.description * */ public class C1 { diff --git a/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/package.html b/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/package.html index abda92fd0c7..63ec94e1978 100644 --- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/package.html +++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/p1/package.html @@ -10,55 +10,33 @@ Case 0 Actual: .   Current directory

      -Sub-test 12 Actual: {@docroot} Bare tag - ALL LOWERCASE
      -Sub-test 12 Expect:
      +Sub-test 8 Actual: {@docroot} Bare tag - ALL LOWERCASE
      +Sub-test 8 Expect:
      (Expect empty string because lowercase docroot is illegal)

      -Sub-test 13 Actual: {@docRoot} Bare tag - "R" UPPERCASE
      -Sub-test 13 Expect: .. +Sub-test 9 Actual: {@docRoot} Bare tag - "R" UPPERCASE
      +Sub-test 9 Expect: ..

      -Sub-test 14 Actual: {@docRoot}/package-list
      -Sub-test 14 Expect: ../package-list +Sub-test 10 Actual: {@docRoot}/element-list
      +Sub-test 10 Expect: ../element-list

      -Sub-test 15 Actual: {@docRoot}/p2/C2.html
      -Sub-test 15 Expect: ../p2/C2.html +Sub-test 11 Actual: {@docRoot}/p2/C2.html
      +Sub-test 11 Expect: ../p2/C2.html

      -Sub-test 16 Actual: {@docRoot}/../docs1/p2/C2.html
      -Sub-test 16 Expect: ../../docs1/p2/C2.html +Sub-test 12 Actual: {@docRoot}/../out/p2/C2.html
      +Sub-test 12 Expect: ../../out/p2/C2.html

      -Sub-test 17 Actual: {@docRoot}/p2/package-summary.html#package_description
      -Sub-test 17 Expect: ../p2/package-summary.html#package_description +Sub-test 13 Actual: {@docRoot}/p2/package-summary.html#package.description
      +Sub-test 13 Expect: ../p2/package-summary.html#package.description

      -Sub-test 18 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      -Sub-test 18 Expect: ../../docs1/p2/package-summary.html#package_description -

      - - - -Allow docRoot to work without a trailing slash for those who had to change their comments -to work with the 1.4.0 bug: -

      - -Sub-test 19 Actual: {@docRoot}p2/C2.html
      -Sub-test 19 Expect: ../p2/C2.html -

      - -Sub-test 20 Actual: {@docRoot}../docs1/p2/C2.html
      -Sub-test 20 Expect: ../../docs1/p2/C2.html -

      - -Sub-test 21 Actual: {@docRoot}/p2/package-summary.html#package_description
      -Sub-test 21 Expect: ../p2/package-summary.html#package_description -

      - -Sub-test 22 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
      -Sub-test 22 Expect: ../../docs1/p2/package-summary.html#package_description +Sub-test 14 Actual: {@docRoot}/../out/p2/package-summary.html#package.description
      +Sub-test 14 Expect: ../../out/p2/package-summary.html#package.description From 43e53a32c7acf61c2e3c32d801ce4bee82eed991 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:23:15 +0000 Subject: [PATCH 151/205] 8227422: sun/net/www/protocol/file/DirPermissionDenied.java failed on Windows 2016 because DirPermissionDenied directory has no read permission Backport-of: 0518393598de764a716376a98e436fb717aef9d4 --- .../sun/net/www/protocol/file/DirPermissionDenied.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java b/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java index a391428f329..0e3f9e86c4e 100644 --- a/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java +++ b/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.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 @@ -90,8 +90,12 @@ public void setup() throws Throwable { } @AfterTest - public void tearDown() throws IOException { + public void tearDown() throws Throwable { + // add read permission to ensure the dir removable + ProcessTools.executeCommand("chmod", "733", TEST_DIR.toString()) + .outputTo(System.out) + .errorTo(System.out) + .shouldHaveExitValue(0); FileUtils.deleteFileIfExistsWithRetry(TEST_DIR); } } - From cdd3e0425f6d1701efc4748af218daa90e710eab Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:27:30 +0000 Subject: [PATCH 152/205] 8221168: java/util/concurrent/CountDownLatch/Basic.java fails Backport-of: 064f69d6ab6e76ad5dff1fde285524ac10febc80 --- .../util/concurrent/CountDownLatch/Basic.java | 185 ++++++++---------- 1 file changed, 85 insertions(+), 100 deletions(-) diff --git a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java index bf2d9a6b0ae..2e9ac391b7a 100644 --- a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java +++ b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java @@ -23,70 +23,57 @@ /* * @test - * @bug 6332435 + * @bug 6332435 8221168 * @summary Basic tests for CountDownLatch * @library /test/lib * @author Seetharam Avadhanam, Martin Buchholz */ import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; import jdk.test.lib.Utils; public class Basic { static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); - interface AwaiterFactory { - Awaiter getAwaiter(); - } - abstract static class Awaiter extends Thread { - private volatile Throwable result = null; - protected void result(Throwable result) { this.result = result; } - public Throwable result() { return this.result; } - } - - private void toTheStartingGate(CountDownLatch gate) { - try { - gate.await(); - } - catch (Throwable t) { fail(t); } + volatile Throwable exception; + volatile boolean interrupted; + abstract void realRun() throws Exception; + public final void run() { + try { realRun(); } + catch (Throwable ex) { exception = ex; } + interrupted = Thread.interrupted(); + }; } - private Awaiter awaiter(final CountDownLatch latch, - final CountDownLatch gate) { - return new Awaiter() { public void run() { - System.out.println("without millis: " + latch.toString()); - gate.countDown(); - - try { + static Awaiter awaiter(CountDownLatch latch, + CountDownLatch gate) { + return new Awaiter() { + public void realRun() throws InterruptedException { + gate.countDown(); latch.await(); - System.out.println("without millis - ComingOut"); - } - catch (Throwable result) { result(result); }}}; - } - - private Awaiter awaiter(final CountDownLatch latch, - final CountDownLatch gate, - final long millis) { - return new Awaiter() { public void run() { - System.out.println("with millis: "+latch.toString()); - gate.countDown(); - - try { - latch.await(millis, TimeUnit.MILLISECONDS); - System.out.println("with millis - ComingOut"); - } - catch (Throwable result) { result(result); }}}; + }}; } - AwaiterFactory awaiterFactory(CountDownLatch latch, CountDownLatch gate) { - return () -> awaiter(latch, gate); + static Awaiter awaiter(CountDownLatch latch, + CountDownLatch gate, + long timeoutMillis) { + return new Awaiter() { + public void realRun() throws InterruptedException { + gate.countDown(); + latch.await(timeoutMillis, TimeUnit.MILLISECONDS); + }}; } - AwaiterFactory timedAwaiterFactory(CountDownLatch latch, CountDownLatch gate) { - return () -> awaiter(latch, gate, LONG_DELAY_MS); + static Supplier randomAwaiterSupplier( + CountDownLatch latch, CountDownLatch gate) { + return () -> (ThreadLocalRandom.current().nextBoolean()) + ? awaiter(latch, gate) + : awaiter(latch, gate, LONG_DELAY_MS); } //---------------------------------------------------------------- @@ -94,28 +81,24 @@ AwaiterFactory timedAwaiterFactory(CountDownLatch latch, CountDownLatch gate) { //---------------------------------------------------------------- public static void normalUse() throws Throwable { int count = 0; - Basic test = new Basic(); CountDownLatch latch = new CountDownLatch(3); Awaiter[] a = new Awaiter[12]; for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactory(latch, gate); - AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); - a[count] = factory1.getAwaiter(); a[count++].start(); - a[count] = factory1.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); - test.toTheStartingGate(gate); - System.out.println("Main Thread: " + latch.toString()); + Supplier s = randomAwaiterSupplier(latch, gate); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + gate.await(); latch.countDown(); checkCount(latch, 2-i); } - for (int i = 0; i < 12; i++) - a[i].join(); - - for (int i = 0; i < 12; i++) - checkResult(a[i], null); + for (Awaiter awaiter : a) + awaiter.join(); + for (Awaiter awaiter : a) + checkException(awaiter, null); } //---------------------------------------------------------------- @@ -123,38 +106,38 @@ public static void normalUse() throws Throwable { //---------------------------------------------------------------- public static void threadInterrupted() throws Throwable { int count = 0; - Basic test = new Basic(); CountDownLatch latch = new CountDownLatch(3); Awaiter[] a = new Awaiter[12]; for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactory(latch, gate); - AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); - a[count] = factory1.getAwaiter(); a[count++].start(); - a[count] = factory1.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); + Supplier s = randomAwaiterSupplier(latch, gate); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + gate.await(); a[count-1].interrupt(); - test.toTheStartingGate(gate); - System.out.println("Main Thread: " + latch.toString()); latch.countDown(); checkCount(latch, 2-i); } - for (int i = 0; i < 12; i++) - a[i].join(); - - for (int i = 0; i < 12; i++) - checkResult(a[i], - (i % 4) == 3 ? InterruptedException.class : null); + for (Awaiter awaiter : a) + awaiter.join(); + for (int i = 0; i < a.length; i++) { + Awaiter awaiter = a[i]; + Throwable ex = awaiter.exception; + if ((i % 4) == 3 && !awaiter.interrupted) + checkException(awaiter, InterruptedException.class); + else + checkException(awaiter, null); + } } //---------------------------------------------------------------- // One thread timed out //---------------------------------------------------------------- public static void timeOut() throws Throwable { - int count =0; - Basic test = new Basic(); + int count = 0; CountDownLatch latch = new CountDownLatch(3); Awaiter[] a = new Awaiter[12]; @@ -162,54 +145,56 @@ public static void timeOut() throws Throwable { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactory(latch, gate); - AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); - a[count] = test.awaiter(latch, gate, timeout[i]); a[count++].start(); - a[count] = factory1.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); - a[count] = factory2.getAwaiter(); a[count++].start(); - test.toTheStartingGate(gate); - System.out.println("Main Thread: " + latch.toString()); + Supplier s = randomAwaiterSupplier(latch, gate); + a[count] = awaiter(latch, gate, timeout[i]); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + a[count] = s.get(); a[count++].start(); + gate.await(); latch.countDown(); checkCount(latch, 2-i); } - for (int i = 0; i < 12; i++) - a[i].join(); - - for (int i = 0; i < 12; i++) - checkResult(a[i], null); + for (Awaiter awaiter : a) + awaiter.join(); + for (Awaiter awaiter : a) + checkException(awaiter, null); } public static void main(String[] args) throws Throwable { - normalUse(); - threadInterrupted(); - timeOut(); + try { + normalUse(); + } catch (Throwable ex) { fail(ex); } + try { + threadInterrupted(); + } catch (Throwable ex) { fail(ex); } + try { + timeOut(); + } catch (Throwable ex) { fail(ex); } + if (failures.get() > 0L) throw new AssertionError(failures.get() + " failures"); } - private static final AtomicInteger failures = new AtomicInteger(0); + static final AtomicInteger failures = new AtomicInteger(0); - private static void fail(String msg) { + static void fail(String msg) { fail(new AssertionError(msg)); } - private static void fail(Throwable t) { + static void fail(Throwable t) { t.printStackTrace(); failures.getAndIncrement(); } - private static void checkCount(CountDownLatch b, int expected) { + static void checkCount(CountDownLatch b, int expected) { if (b.getCount() != expected) fail("Count = " + b.getCount() + ", expected = " + expected); } - private static void checkResult(Awaiter a, Class c) { - Throwable t = a.result(); - if (! ((t == null && c == null) || c.isInstance(t))) { - System.out.println("Mismatch: " + t + ", " + c.getName()); - failures.getAndIncrement(); - } + static void checkException(Awaiter awaiter, Class c) { + Throwable ex = awaiter.exception; + if (! ((ex == null && c == null) || c.isInstance(ex))) + fail("Expected: " + c + ", got: " + ex); } } From b51ebf8c3de87200a825aeba11cd25a4b53b0fc2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:29:41 +0000 Subject: [PATCH 153/205] 8248306: gc/stress/gclocker/TestExcessGCLockerCollections.java does not compile Update the test to use the method suggested in JDK-8244010. Backport-of: 83fff054980406fa93fb17976d67fc31102a9276 --- .../gc/stress/gclocker/TestExcessGCLockerCollections.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/gc/stress/gclocker/TestExcessGCLockerCollections.java b/test/hotspot/jtreg/gc/stress/gclocker/TestExcessGCLockerCollections.java index 25fee80c0f7..88fda72a80a 100644 --- a/test/hotspot/jtreg/gc/stress/gclocker/TestExcessGCLockerCollections.java +++ b/test/hotspot/jtreg/gc/stress/gclocker/TestExcessGCLockerCollections.java @@ -175,9 +175,7 @@ public static void main(String args[]) throws Exception { finalArgs.addAll(Arrays.asList(args)); // GC and other options obtained from test framework. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, finalArgs); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); + OutputAnalyzer output = ProcessTools.executeTestJvm(finalArgs); output.shouldHaveExitValue(0); //System.out.println("------------- begin stdout ----------------"); //System.out.println(output.getStdout()); From 1ce9a655103f9e8871f31b6b593e8913d2cfe454 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 09:30:56 +0000 Subject: [PATCH 154/205] 8249691: jdk/lambda/vm/StrictfpDefault.java file can be removed Backport-of: 54490d30c86891dbc412ab69d18114f3a79fae40 --- test/jdk/jdk/lambda/vm/StrictfpDefault.java | 32 --------------------- 1 file changed, 32 deletions(-) delete mode 100644 test/jdk/jdk/lambda/vm/StrictfpDefault.java diff --git a/test/jdk/jdk/lambda/vm/StrictfpDefault.java b/test/jdk/jdk/lambda/vm/StrictfpDefault.java deleted file mode 100644 index f922012301e..00000000000 --- a/test/jdk/jdk/lambda/vm/StrictfpDefault.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * 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 vm; - -/* -* @test -* @ignore -*/ -interface StrictfpDefault { - default strictfp void m() {} -} From 272199168cbe9d42cfadc532b0a826ad5265c501 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 17 Feb 2023 09:57:25 +0000 Subject: [PATCH 155/205] 8302694: [11u] Update GHA Boot JDK to 11.0.18 Reviewed-by: mbaesken, sgehwolf --- make/conf/github-actions.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf index 88c8cc25689..40dd3b57d6a 100644 --- a/make/conf/github-actions.conf +++ b/make/conf/github-actions.conf @@ -29,13 +29,13 @@ GTEST_VERSION=1.8.1 JTREG_VERSION=6.1+3 LINUX_X64_BOOT_JDK_EXT=tar.gz -LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz -LINUX_X64_BOOT_JDK_SHA256=43fb84f8063ad9bf6b6d694a67b8f64c8827552b920ec5ce794dfe5602edffe7 +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 +LINUX_X64_BOOT_JDK_SHA256=4a29efda1d702b8ff38e554cf932051f40ec70006caed5c4857a8cbc7a0b7db7 WINDOWS_X64_BOOT_JDK_EXT=zip -WINDOWS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_windows_hotspot_11.0.14.1_1.zip -WINDOWS_X64_BOOT_JDK_SHA256=3e7da701aa92e441418299714f0ed6db10c3bb1e2db625c35a2c2cd9cc619731 +WINDOWS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_x64_windows_hotspot_11.0.18_10.zip +WINDOWS_X64_BOOT_JDK_SHA256=0cfa5991a8e372b3f8eacacbb2a336663ead0cc6ec9c9ab6cd53206602fb0062 MACOS_X64_BOOT_JDK_EXT=tar.gz -MACOS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.14.1_1.tar.gz -MACOS_X64_BOOT_JDK_SHA256=8c69808f5d9d209b195575e979de0e43cdf5d0f1acec1853a569601fe2c1f743 +MACOS_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.18_10.tar.gz +MACOS_X64_BOOT_JDK_SHA256=75d79315d7265cc4b89fd9e844161ff90798bc6482ace8c1ac75f862a5b3b565 From 169b3d24d32d4c3c2f1ecf09afd6aa30f03ea846 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:04:27 +0000 Subject: [PATCH 156/205] 8252401: Introduce Utils.TEST_NATIVE_PATH Backport-of: e1d29cd6fb4a9d1ccf2105840e54593a6c3e5c7c --- test/lib/jdk/test/lib/Utils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/lib/jdk/test/lib/Utils.java b/test/lib/jdk/test/lib/Utils.java index 56b8454a582..93b0777e1f3 100644 --- a/test/lib/jdk/test/lib/Utils.java +++ b/test/lib/jdk/test/lib/Utils.java @@ -107,7 +107,12 @@ public final class Utils { */ public static final String TEST_NAME = System.getProperty("test.name", "."); - /** + /** + * Returns the value of 'test.nativepath' system property + */ + public static final String TEST_NATIVE_PATH = System.getProperty("test.nativepath", "."); + + /** * Defines property name for seed value. */ public static final String SEED_PROPERTY_NAME = "jdk.test.lib.random.seed"; From dbee8618f376e65007425efe4dc0ab164ab6a804 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:05:58 +0000 Subject: [PATCH 157/205] 8260576: Typo in compiler/runtime/safepoints/TestRegisterRestoring.java Backport-of: 54e7a642bba492198ffaca1bf7f39b890801825e --- .../compiler/runtime/safepoints/TestRegisterRestoring.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java b/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java index 0a6a308c126..32c3bda9409 100644 --- a/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java +++ b/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java @@ -47,7 +47,7 @@ public static void main(String args[]) throws Exception { // Check result for (int i = 0; i < array.length; i++) { if (array[i] != 10_000) { - throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10.000"); + throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10,000"); } array[i] = 0; } From 013aa4d85e625cad7abe4b33a301274b777cb458 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:08:37 +0000 Subject: [PATCH 158/205] 8259265: Refactor UncaughtExceptions shell test as java test. Backport-of: 0ef93feb43eb3f3cb855ed35b1c2e81493924dc8 --- .../java/lang/Thread/UncaughtExceptions.sh | 205 ----------------- .../lang/Thread/UncaughtExceptionsTest.java | 206 ++++++++++++++++++ 2 files changed, 206 insertions(+), 205 deletions(-) delete mode 100644 test/jdk/java/lang/Thread/UncaughtExceptions.sh create mode 100644 test/jdk/java/lang/Thread/UncaughtExceptionsTest.java diff --git a/test/jdk/java/lang/Thread/UncaughtExceptions.sh b/test/jdk/java/lang/Thread/UncaughtExceptions.sh deleted file mode 100644 index 7ed96672a23..00000000000 --- a/test/jdk/java/lang/Thread/UncaughtExceptions.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. -# 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 4833089 4992454 -# @summary Check for proper handling of uncaught exceptions -# @author Martin Buchholz -# -# @run shell UncaughtExceptions.sh - -# To run this test manually, simply do ./UncaughtExceptions.sh - - java="${TESTJAVA+${TESTJAVA}/bin/}java" -javac="${COMPILEJAVA+${COMPILEJAVA}/bin/}javac" - -failed="" -Fail() { echo "FAIL: $1"; failed="${failed}."; } - -Die() { printf "%s\n" "$*"; exit 1; } - -Sys() { - "$@"; rc="$?"; - test "$rc" -eq 0 || Die "Command \"$*\" failed with exitValue $rc"; -} - -HorizontalRule() { - echo "-----------------------------------------------------------------" -} - -Bottom() { - test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line" - - HorizontalRule - if test -n "$failed"; then - count=`printf "%s" "$failed" | wc -c | tr -d ' '` - echo "FAIL: $count tests failed" - exit 1 - else - echo "PASS: all tests gave expected results" - exit 0 - fi -} - -Cleanup() { Sys rm -f Seppuku* OK.class; } - -set -u - -checkOutput() { - name="$1" expected="$2" got="$3" - printf "$name:\n"; cat "$got" - if test -z "$expected"; then - test "`cat $got`" != "" && \ - Fail "Unexpected $name: `cat $got`" - else - grep "$expected" "$got" >/dev/null || \ - Fail "Expected \"$expected\", got `cat $got`" - fi -} - -CheckCommandResults() { - expectedRC="$1" expectedOut="$2" expectedErr="$3"; shift 3 - saveFailed="${failed}" - "$@" >TmpTest.Out 2>TmpTest.Err; rc="$?"; - printf "==> %s (rc=%d)\n" "$*" "$rc" - checkOutput "stdout" "$expectedOut" "TmpTest.Out" - checkOutput "stderr" "$expectedErr" "TmpTest.Err" - test "${saveFailed}" = "${failed}" && \ - echo "PASS: command completed as expected" - Sys rm -f TmpTest.Out TmpTest.Err -} - -Run() { - expectedRC="$1" expectedOut="$2" expectedErr="$3" mainBody="$4" - cat > Seppuku.java < Date: Fri, 17 Feb 2023 10:10:58 +0000 Subject: [PATCH 159/205] 8261270: MakeMethodNotCompilableTest fails with -XX:TieredStopAtLevel={1,2,3} Backport-of: 0e18634b6a855f6c2a5d3c5ef1eff57161be5b08 --- .../jtreg/compiler/whitebox/MakeMethodNotCompilableTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/whitebox/MakeMethodNotCompilableTest.java b/test/hotspot/jtreg/compiler/whitebox/MakeMethodNotCompilableTest.java index 8afec557e0d..32d4cfa7e44 100644 --- a/test/hotspot/jtreg/compiler/whitebox/MakeMethodNotCompilableTest.java +++ b/test/hotspot/jtreg/compiler/whitebox/MakeMethodNotCompilableTest.java @@ -202,7 +202,7 @@ private void testTier(int testedTier) { deoptimize(); } - if (!isCompilable(COMP_LEVEL_ANY)) { + if (!isCompilable(COMP_LEVEL_ANY) && TIERED_STOP_AT_LEVEL == COMP_LEVEL_FULL_OPTIMIZATION) { throw new RuntimeException(method + " must be compilable at 'CompLevel::CompLevel_any'" + ", if it is not compilable only at " + testedTier); From eb8c6f59aa6234e26d42d191b5d9cb08b37b954a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:12:17 +0000 Subject: [PATCH 160/205] 8261279: sun/util/resources/cldr/TimeZoneNamesTest.java timed out Backport-of: becee6435bc38c4e3fe5b197c985e68e97fc8e0d --- test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java index 53903d19d3d..e2ec97738a8 100644 --- a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java +++ b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8181157 8202537 8234347 8236548 8293834 + * @bug 8181157 8202537 8234347 8236548 8261279 8293834 * @modules jdk.localedata * @summary Checks CLDR time zone names are generated correctly at runtime * @run testng/othervm -Djava.locale.providers=CLDR TimeZoneNamesTest @@ -216,6 +216,7 @@ public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, S public void test_getZoneStrings() { assertFalse( Arrays.stream(Locale.getAvailableLocales()) + .limit(30) .peek(l -> System.out.println("Locale: " + l)) .map(l -> DateFormatSymbols.getInstance(l).getZoneStrings()) .flatMap(zs -> Arrays.stream(zs)) From ffac38fc9571653fb821246e0bd76d83b09860c6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:13:42 +0000 Subject: [PATCH 161/205] 8264512: jdk/test/jdk/java/util/prefs/ExportNode.java relies on default platform encoding Backport-of: 104e925dfdac0af3b1c6862f9a7d3442484f9241 --- test/jdk/java/util/prefs/ExportNode.java | 57 ++++++++++++++++-------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/test/jdk/java/util/prefs/ExportNode.java b/test/jdk/java/util/prefs/ExportNode.java index 3ba815e1c68..659cdb2cc68 100644 --- a/test/jdk/java/util/prefs/ExportNode.java +++ b/test/jdk/java/util/prefs/ExportNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, 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 @@ -30,25 +30,46 @@ * @run main/othervm -Djava.util.prefs.userRoot=. ExportNode * @author Konstantin Kladko */ -import java.util.prefs.*; -import java.io.*; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; public class ExportNode { + private static final String NODE_NAME_1 = "ExportNodeTestName1"; + private static final String NODE_NAME_2 = "ExportNodeTestName2"; + public static void main(String[] args) throws - BackingStoreException, IOException { - Preferences N1 = Preferences.userRoot().node("ExportNodeTest1"); - N1.put("ExportNodeTestName1","ExportNodeTestValue1"); - Preferences N2 = N1.node("ExportNodeTest2"); - N2.put("ExportNodeTestName2","ExportNodeTestValue2"); - ByteArrayOutputStream exportStream = new ByteArrayOutputStream(); - N2.exportNode(exportStream); - - // Removal of preference node should always succeed on Solaris/Linux - // by successfully acquiring the appropriate file lock (4947349) - N1.removeNode(); - - if (((exportStream.toString()).lastIndexOf("ExportNodeTestName2")== -1) || - ((exportStream.toString()).lastIndexOf("ExportNodeTestName1")!= -1)) { - } + BackingStoreException, IOException { + Preferences N1 = Preferences.userRoot().node("ExportNodeTest1"); + N1.put(NODE_NAME_1,"ExportNodeTestValue1"); + Preferences N2 = N1.node("ExportNodeTest2"); + N2.put(NODE_NAME_2,"ExportNodeTestValue2"); + ByteArrayOutputStream exportStream = new ByteArrayOutputStream(); + N2.exportNode(exportStream); + + // Removal of preference node should always succeed on Solaris/Linux + // by successfully acquiring the appropriate file lock (4947349) + N1.removeNode(); + + String streamAsString = exportStream.toString("UTF-8"); + + StringBuilder sb = null; + if (streamAsString.lastIndexOf(NODE_NAME_2) == -1) { + if (sb == null) + sb = new StringBuilder(); + sb.append(NODE_NAME_2 + " should have been found"); + } + if (streamAsString.lastIndexOf(NODE_NAME_1) != -1) { + if (sb == null) + sb = new StringBuilder(); + else + sb.append("; "); + sb.append(NODE_NAME_1 + " should *not* have been found"); + } + + if (sb != null) + throw new RuntimeException(sb.toString()); } } From 2244467c81106f36f1438ecbf30901ac6fd451ce Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:15:04 +0000 Subject: [PATCH 162/205] 8264200: java/nio/channels/DatagramChannel/SRTest.java fails intermittently Backport-of: 784f1c1f74782675c60e17f4be8b1e5d321fbea5 --- .../nio/channels/DatagramChannel/SRTest.java | 219 ++++++++++-------- 1 file changed, 125 insertions(+), 94 deletions(-) diff --git a/test/jdk/java/nio/channels/DatagramChannel/SRTest.java b/test/jdk/java/nio/channels/DatagramChannel/SRTest.java index ebed0d6ba27..9a7309cc46e 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SRTest.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SRTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -23,185 +23,216 @@ /* @test * @summary Test DatagramChannel's send and receive methods - * @author Mike McCloskey + * @run testng/othervm/timeout=20 SRTest */ import java.io.*; import java.net.*; import java.nio.*; import java.nio.channels.*; -import java.nio.charset.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Stream; +import static java.nio.charset.StandardCharsets.US_ASCII; +import org.testng.annotations.*; public class SRTest { + ExecutorService executorService; static PrintStream log = System.err; - public static void main(String[] args) throws Exception { - test(); + static final String DATA_STRING = "hello"; + + @BeforeClass + public void beforeClass() { + executorService = Executors.newCachedThreadPool(); } - static void test() throws Exception { - ClassicReader classicReader; - NioReader nioReader; + @AfterClass + public void afterClass() { + executorService.shutdown(); + } - classicReader = new ClassicReader(); - invoke(classicReader, new ClassicWriter(classicReader.port())); + @Test + public void classicReaderClassicWriter() throws Exception { + try (ClassicReader cr = new ClassicReader(); + ClassicWriter cw = new ClassicWriter(cr.port())) { + invoke(executorService, cr, cw); + } log.println("Classic RW: OK"); + } - classicReader = new ClassicReader(); - invoke(classicReader, new NioWriter(classicReader.port())); + @Test + public void classicReaderNioWriter() throws Exception { + try (ClassicReader cr = new ClassicReader(); + NioWriter nw = new NioWriter(cr.port())) { + invoke(executorService, cr, nw); + } log.println("Classic R, Nio W: OK"); + } - nioReader = new NioReader(); - invoke(nioReader, new ClassicWriter(nioReader.port())); + @Test + public void nioReaderClassicWriter() throws Exception { + try (NioReader nr = new NioReader(); + ClassicWriter cw = new ClassicWriter(nr.port())) { + invoke(executorService, nr, cw); + } log.println("Classic W, Nio R: OK"); + } - nioReader = new NioReader(); - invoke(nioReader, new NioWriter(nioReader.port())); + @Test + public void nioReaderNioWriter() throws Exception { + try (NioReader nr = new NioReader(); + NioWriter nw = new NioWriter(nr.port())) { + invoke(executorService, nr, nw); + } log.println("Nio RW: OK"); } - static void invoke(Sprintable reader, Sprintable writer) throws Exception { - Thread readerThread = new Thread(reader); - readerThread.start(); - Thread.sleep(50); - - Thread writerThread = new Thread(writer); - writerThread.start(); - - writerThread.join(); - readerThread.join(); - - reader.throwException(); - writer.throwException(); + private static void invoke(ExecutorService e, Runnable reader, Runnable writer) { + CompletableFuture f1 = CompletableFuture.runAsync(writer, e); + CompletableFuture f2 = CompletableFuture.runAsync(reader, e); + wait(f1, f2); } - public interface Sprintable extends Runnable { - public void throwException() throws Exception; + // Exit with CompletionException if any passed futures complete exceptionally + private static void wait(CompletableFuture... futures) throws CompletionException { + CompletableFuture future = CompletableFuture.allOf(futures); + Stream.of(futures) + .forEach(f -> f.exceptionally(ex -> { + future.completeExceptionally(ex); + return null; + })); + future.join(); } - public static class ClassicWriter implements Sprintable { - final int port; - Exception e = null; - - ClassicWriter(int port) { - this.port = port; - } + public static class ClassicWriter implements Runnable, AutoCloseable { + final DatagramSocket ds; + final int dstPort; - public void throwException() throws Exception { - if (e != null) - throw e; + ClassicWriter(int dstPort) throws SocketException { + this.dstPort = dstPort; + this.ds = new DatagramSocket(); } public void run() { try { - DatagramSocket ds = new DatagramSocket(); - String dataString = "hello"; - byte[] data = dataString.getBytes(); - InetAddress address = InetAddress.getLocalHost(); + byte[] data = DATA_STRING.getBytes(US_ASCII); + InetAddress address = InetAddress.getLoopbackAddress(); DatagramPacket dp = new DatagramPacket(data, data.length, - address, port); + address, dstPort); ds.send(dp); - Thread.sleep(50); - ds.send(dp); - } catch (Exception ex) { - e = ex; + } catch (Exception e) { + log.println("ClassicWriter [" + ds.getLocalAddress() + "]"); + throw new RuntimeException("ClassicWriter threw exception: " + e); + } finally { + log.println("ClassicWriter finished"); } } - } - - public static class NioWriter implements Sprintable { - final int port; - Exception e = null; - NioWriter(int port) { - this.port = port; + @Override + public void close() throws IOException { + ds.close(); } + } + + public static class NioWriter implements Runnable, AutoCloseable { + final DatagramChannel dc; + final int dstPort; - public void throwException() throws Exception { - if (e != null) - throw e; + NioWriter(int dstPort) throws IOException { + this.dc = DatagramChannel.open(); + this.dstPort = dstPort; } public void run() { try { - DatagramChannel dc = DatagramChannel.open(); ByteBuffer bb = ByteBuffer.allocateDirect(256); - bb.put("hello".getBytes()); + bb.put(DATA_STRING.getBytes(US_ASCII)); bb.flip(); - InetAddress address = InetAddress.getLocalHost(); - InetSocketAddress isa = new InetSocketAddress(address, port); - dc.send(bb, isa); - Thread.sleep(50); + InetAddress address = InetAddress.getLoopbackAddress(); + InetSocketAddress isa = new InetSocketAddress(address, dstPort); dc.send(bb, isa); } catch (Exception ex) { - e = ex; + log.println("NioWriter [" + dc.socket().getLocalAddress() + "]"); + throw new RuntimeException("NioWriter threw exception: " + ex); + } finally { + log.println("NioWriter finished"); } } + + @Override + public void close() throws IOException { + dc.close(); + } } - public static class ClassicReader implements Sprintable { + public static class ClassicReader implements Runnable, AutoCloseable { final DatagramSocket ds; - Exception e = null; ClassicReader() throws IOException { - this.ds = new DatagramSocket(); + InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + this.ds = new DatagramSocket(address); } int port() { return ds.getLocalPort(); } - public void throwException() throws Exception { - if (e != null) - throw e; - } - public void run() { try { byte[] buf = new byte[256]; DatagramPacket dp = new DatagramPacket(buf, buf.length); ds.receive(dp); - String received = new String(dp.getData()); - log.println(received); - ds.close(); + String received = new String(dp.getData(), dp.getOffset(), dp.getLength(), US_ASCII); + log.println("ClassicReader received: " + received); } catch (Exception ex) { - e = ex; + log.println("ClassicReader [" + ds.getLocalAddress() +"]"); + throw new RuntimeException("ClassicReader threw exception: " + ex); + } finally { + log.println("ClassicReader finished"); } } + + @Override + public void close() throws IOException { + ds.close(); + } } - public static class NioReader implements Sprintable { + public static class NioReader implements Runnable, AutoCloseable { final DatagramChannel dc; - Exception e = null; NioReader() throws IOException { - this.dc = DatagramChannel.open().bind(new InetSocketAddress(0)); + InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + this.dc = DatagramChannel.open().bind(address); } int port() { return dc.socket().getLocalPort(); } - public void throwException() throws Exception { - if (e != null) - throw e; - } - public void run() { try { ByteBuffer bb = ByteBuffer.allocateDirect(100); - SocketAddress sa = dc.receive(bb); + dc.receive(bb); bb.flip(); - CharBuffer cb = Charset.forName("US-ASCII"). - newDecoder().decode(bb); - log.println("From: "+sa+ " said " +cb); - dc.close(); + CharBuffer cb = US_ASCII.newDecoder().decode(bb); + log.println("NioReader received: " + cb); } catch (Exception ex) { - e = ex; + log.println("NioReader [" + dc.socket().getLocalAddress() +"]"); + throw new RuntimeException("NioReader threw exception: " + ex); + } finally { + log.println("NioReader finished"); } } - } + @Override + public void close() throws IOException { + dc.close(); + } + } } From 363586ef0b484b3beca303d1bbce85a787c29050 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:16:28 +0000 Subject: [PATCH 163/205] 8262060: compiler/whitebox/BlockingCompilation.java timed out Backport-of: 694e1cdcb82062314d26c31540819ce88023c25a --- test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java b/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java index 86320ded87f..247b06cbaa8 100644 --- a/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java +++ b/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java @@ -46,14 +46,12 @@ import sun.hotspot.WhiteBox; import java.lang.reflect.Method; -import java.util.Random; public class BlockingCompilation { private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final Random RANDOM = new Random(42); public static int foo() { - return RANDOM.nextInt(); + return 42; //constant's value is arbitrary and meaningless } public static void main(String[] args) throws Exception { From 183bb3604a0032f012ed983ca07408f91bc54a92 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:17:49 +0000 Subject: [PATCH 164/205] 8271323: [TESTBUG] serviceability/sa/ClhsdbCDSCore.java fails with -XX:TieredStopAtLevel=1 Backport-of: 9bc52afa481c476ae9c379dff44ae8266777f616 --- test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 33d25f9a38a..e6728ed0211 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -167,8 +167,8 @@ public static void main(String[] args) throws Exception { List testJavaOpts = Arrays.asList(Utils.getTestJavaOpts()); - if (testJavaOpts.contains("-Xcomp") && testJavaOpts.contains("-XX:TieredStopAtLevel=1")) { - // No MDOs are allocated in -XX:TieredStopAtLevel=1 + -Xcomp mode + if (testJavaOpts.contains("-XX:TieredStopAtLevel=1")) { + // No MDOs are allocated in -XX:TieredStopAtLevel=1 // The reason is methods being compiled aren't hot enough // Let's not call printmdo in such scenario cmds = List.of("printall", "jstack -v"); From bc29f1eb26714ef4a4f1494d9e9cd8aaf9050d7d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 17 Feb 2023 10:19:19 +0000 Subject: [PATCH 165/205] 8288332: Tier1 validate-source fails after 8279614 Backport-of: e90b579b294eb88f6b4e236d19b05063775ee8d7 --- .../swing/border/EtchedBorder/ScaledEtchedBorderTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java b/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java index e1eb17414c6..4db602f0e4d 100644 --- a/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java +++ b/test/jdk/javax/swing/border/EtchedBorder/ScaledEtchedBorderTest.java @@ -2,6 +2,10 @@ * 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 From c692aa9aad26afe0eae529dd67d0cf39ea30d45c Mon Sep 17 00:00:00 2001 From: Ekaterina Vergizova Date: Fri, 24 Feb 2023 12:39:18 +0000 Subject: [PATCH 166/205] 8301842: JFR: increase checkpoint event size for stacktrace and string pool Reviewed-by: phh Backport-of: 7dfe75cf553193faf709cff6b8b2505680d7cebc --- src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp index e50c1cd6526..2f8f4f21df8 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp @@ -135,7 +135,7 @@ class RotationLock : public StackObj { static int64_t write_checkpoint_event_prologue(JfrChunkWriter& cw, u8 type_id) { const int64_t last_cp_offset = cw.last_checkpoint_offset(); const int64_t delta_to_last_checkpoint = 0 == last_cp_offset ? 0 : last_cp_offset - cw.current_offset(); - cw.reserve(sizeof(u4)); + cw.reserve(sizeof(u8)); cw.write(EVENT_CHECKPOINT); cw.write(JfrTicks::now()); cw.write((int64_t)0); // duration @@ -176,7 +176,7 @@ class WriteCheckpointEvent : public StackObj { assert(number_of_elements > 0, "invariant"); assert(_cw.current_offset() > num_elements_offset, "invariant"); _cw.write_padded_at_offset(number_of_elements, num_elements_offset); - _cw.write_padded_at_offset((u4)_cw.current_offset() - current_cp_offset, current_cp_offset); + _cw.write_padded_at_offset((u8)(_cw.current_offset() - current_cp_offset), current_cp_offset); // update writer with last checkpoint position _cw.set_last_checkpoint_offset(current_cp_offset); return true; From 411aaff4c221136fb793100144f79e0b5375e23b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 24 Feb 2023 19:56:39 +0000 Subject: [PATCH 167/205] 8213265: fix missing newlines at end of files Backport-of: 72bfdd96f1499ab25081676e9725734a85fd6aa1 --- .../langtools/jdk/javadoc/doclet/testSummaryTag/p2/package.html | 2 +- test/langtools/tools/javac/doctree/dcapi/overview0.html | 2 +- test/langtools/tools/javac/doctree/dcapi/overview1.html | 2 +- test/langtools/tools/javac/doctree/dcapi/overview2.html | 2 +- test/langtools/tools/javac/doctree/dcapi/overview3.html | 2 +- test/langtools/tools/javac/doctree/dcapi/overview5.html | 2 +- test/langtools/tools/javac/doctree/dcapi/package.html | 2 +- test/langtools/tools/javac/doctree/dcapi/pkg/package.html | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testSummaryTag/p2/package.html b/test/langtools/jdk/javadoc/doclet/testSummaryTag/p2/package.html index f0dda3f9002..24e20e4027f 100644 --- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/p2/package.html +++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/p2/package.html @@ -2,4 +2,4 @@ foo {@summary bar} baz. - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/overview0.html b/test/langtools/tools/javac/doctree/dcapi/overview0.html index 8484422cc1f..0b4a26a8272 100644 --- a/test/langtools/tools/javac/doctree/dcapi/overview0.html +++ b/test/langtools/tools/javac/doctree/dcapi/overview0.html @@ -5,4 +5,4 @@ A simple well formed html document

      overview0.html
      . - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/overview1.html b/test/langtools/tools/javac/doctree/dcapi/overview1.html index 3012e5b3767..071049e65b7 100644 --- a/test/langtools/tools/javac/doctree/dcapi/overview1.html +++ b/test/langtools/tools/javac/doctree/dcapi/overview1.html @@ -5,4 +5,4 @@ Html document
      overview1.html
      . Missing HTML. - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/overview2.html b/test/langtools/tools/javac/doctree/dcapi/overview2.html index 432bb7d25bc..fe4c1092518 100644 --- a/test/langtools/tools/javac/doctree/dcapi/overview2.html +++ b/test/langtools/tools/javac/doctree/dcapi/overview2.html @@ -5,4 +5,4 @@ Html document
      overview2.html
      . Missing HEAD. - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/overview3.html b/test/langtools/tools/javac/doctree/dcapi/overview3.html index fed93a832f8..097668049bd 100644 --- a/test/langtools/tools/javac/doctree/dcapi/overview3.html +++ b/test/langtools/tools/javac/doctree/dcapi/overview3.html @@ -5,4 +5,4 @@ Html document
      overview3.html
      . Missing enclosing HEAD. - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/overview5.html b/test/langtools/tools/javac/doctree/dcapi/overview5.html index af7d365a440..22c0999956d 100644 --- a/test/langtools/tools/javac/doctree/dcapi/overview5.html +++ b/test/langtools/tools/javac/doctree/dcapi/overview5.html @@ -5,4 +5,4 @@ Html document
      overview5.html
      . Missing enclosing HTML - \ No newline at end of file + diff --git a/test/langtools/tools/javac/doctree/dcapi/package.html b/test/langtools/tools/javac/doctree/dcapi/package.html index 82201fd92dc..37f3bc23695 100644 --- a/test/langtools/tools/javac/doctree/dcapi/package.html +++ b/test/langtools/tools/javac/doctree/dcapi/package.html @@ -8,4 +8,4 @@ A simple well formed html document
      package.html
      .
       
      -
      \ No newline at end of file
      +
      diff --git a/test/langtools/tools/javac/doctree/dcapi/pkg/package.html b/test/langtools/tools/javac/doctree/dcapi/pkg/package.html
      index bd8212d7109..5a8d9af3be8 100644
      --- a/test/langtools/tools/javac/doctree/dcapi/pkg/package.html
      +++ b/test/langtools/tools/javac/doctree/dcapi/pkg/package.html
      @@ -6,4 +6,4 @@
       A simple well formed html document 
      package.html
      . In package pkg. - \ No newline at end of file + From b396137edacb6b4e1915e6c6738f1b7bb88484be Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 24 Feb 2023 20:05:42 +0000 Subject: [PATCH 168/205] 8257928: Test image build failure with clang-10 due to -Wmisleading-indentation Backport-of: 4ea88512ddb89470ff5a043bc1865b9e4af661d6 --- .../nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp | 4 ++-- .../nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp | 4 ++-- .../nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp | 4 ++-- .../nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp index 4afa9e5079c..c8bcfbc66bf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -244,7 +244,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* obtain WAITTIME parameter */ - timeout = nsk_jvmti_getWaitTime() * 60000; + timeout = nsk_jvmti_getWaitTime() * 60000; NSK_DISPLAY1("waittime=%d msecs\n", (int) timeout); /* create JVMTI environment */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp index 0fec733438c..7e7a630c650 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -243,7 +243,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* obtain WAITTIME parameter */ - timeout = nsk_jvmti_getWaitTime() * 60000; + timeout = nsk_jvmti_getWaitTime() * 60000; NSK_DISPLAY1("waittime=%d msecs\n", (int) timeout); /* create JVMTI environment */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp index 8dc2d553006..d84f17c6580 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -244,7 +244,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* obtain WAITTIME parameter */ - timeout = nsk_jvmti_getWaitTime() * 60000; + timeout = nsk_jvmti_getWaitTime() * 60000; NSK_DISPLAY1("waittime=%d msecs\n", (int) timeout); /* create JVMTI environment */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp index 77b5e509229..41698a6644b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -293,7 +293,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* obtain WAITTIME parameter */ - timeout = nsk_jvmti_getWaitTime() * 60000; + timeout = nsk_jvmti_getWaitTime() * 60000; NSK_DISPLAY1("waittime=%d msecs\n", (int) timeout); /* create JVMTI environment */ From b3820b21eccc97464b090d1ca6fd2ca79e0e8cf4 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 24 Feb 2023 20:08:30 +0000 Subject: [PATCH 169/205] 8273806: compiler/cpuflags/TestSSE4Disabled.java should test for CPU feature explicitly Backport-of: 09ecb11927f0042ddc0c5c23d747b275ab70b36b --- test/hotspot/jtreg/compiler/cpuflags/TestSSE4Disabled.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/cpuflags/TestSSE4Disabled.java b/test/hotspot/jtreg/compiler/cpuflags/TestSSE4Disabled.java index 812c7061a65..ae1dae0631f 100644 --- a/test/hotspot/jtreg/compiler/cpuflags/TestSSE4Disabled.java +++ b/test/hotspot/jtreg/compiler/cpuflags/TestSSE4Disabled.java @@ -24,7 +24,7 @@ /* * @test TestSSE4Disabled * @bug 8158214 - * @requires (vm.simpleArch == "x64") + * @requires vm.cpu.features ~= ".*sse4.*" * @summary Test correct execution without SSE 4. * * @run main/othervm -Xcomp -XX:UseSSE=3 compiler.cpuflags.TestSSE4Disabled From cb5d79c234c650c153560d1834cb354c54aeff49 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 24 Feb 2023 20:10:01 +0000 Subject: [PATCH 170/205] 8273895: compiler/ciReplay/TestVMNoCompLevel.java fails due to wrong data size with TieredStopAtLevel=2,3 Backport-of: a561eac912740da6a5982c47558e13f34481219f --- test/hotspot/jtreg/compiler/ciReplay/TestVMNoCompLevel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/ciReplay/TestVMNoCompLevel.java b/test/hotspot/jtreg/compiler/ciReplay/TestVMNoCompLevel.java index 97b74c7c87c..69161e6fe48 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/TestVMNoCompLevel.java +++ b/test/hotspot/jtreg/compiler/ciReplay/TestVMNoCompLevel.java @@ -26,7 +26,8 @@ * @bug 8011675 * @library / /test/lib * @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level - * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true + * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & + * (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 1 | vm.opt.TieredStopAtLevel == 4) * @modules java.base/jdk.internal.misc * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox From 05db32270ef4993eec83c0eddc4108b9469e1f4d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 24 Feb 2023 20:12:06 +0000 Subject: [PATCH 171/205] 8270609: [TESTBUG] java/awt/print/Dialog/DialogCopies.java does not show instruction Reviewed-by: phh Backport-of: 4da45c430139fe66fab020c2f96686dc9cf26a97 --- .../java/awt/print/Dialog/DialogCopies.java | 79 +++++++++++++------ 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/test/jdk/java/awt/print/Dialog/DialogCopies.java b/test/jdk/java/awt/print/Dialog/DialogCopies.java index 5086f95660f..33fb44b7ed7 100644 --- a/test/jdk/java/awt/print/Dialog/DialogCopies.java +++ b/test/jdk/java/awt/print/Dialog/DialogCopies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -21,40 +21,73 @@ * questions. */ -/** +/* * @test * @bug 6357858 * @summary Job must reports the number of copies set in the dialog. * @run main/manual DialogCopies */ -import java.awt.print.*; +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.BorderLayout; +import java.awt.print.PrinterJob; public class DialogCopies { - static String[] instructions = { - "This test assumes and requires that you have a printer installed", - "When the dialog appears, increment the number of copies then press OK.", - "The test will throw an exception if you fail to do this, since", - "it cannot distinguish that from a failure", - "" - }; + private static Frame createInstructionUI() { + final String instruction = + "This test requires that you have a printer.\n" + + "\n" + + "Press Cancel if your system has only virtual printers such as\n" + + "Microsoft Print to PDF or Microsoft XPS Document Writer since\n" + + "they don't allow setting copies to anything but 1.\n" + + "\n" + + "If a real printer is installed, select it from the drop-down\n" + + "list in the Print dialog and increase the number of copies,\n" + + "then press OK button.\n"; - public static void main(String[] args) { + TextArea instructionTextArea = new TextArea(instruction); + instructionTextArea.setEditable(false); - for (int i=0;i Date: Fri, 24 Feb 2023 20:13:52 +0000 Subject: [PATCH 172/205] 8303075: [11u] Add CompileClassWithDebugTest to ProblemList for 8303074 Reviewed-by: phh --- 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 3762a5738a5..a5b8d816d87 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -42,6 +42,7 @@ compiler/aot/verification/vmflags/TrackedFlagTest.java 8215224 generic-all compiler/aot/verification/vmflags/NotTrackedFlagTest.java 8215224 generic-all +compiler/aot/cli/jaotc/CompileClassWithDebugTest.java 8303074 linux-aarch64 compiler/ciReplay/TestSAServer.java 8029528 generic-all compiler/codecache/stress/OverloadCompileQueueTest.java 8166554 generic-all compiler/codegen/Test6896617.java 8193479 generic-all From efe44815b1725db491f5f59c53c9b0906ce43a74 Mon Sep 17 00:00:00 2001 From: "Shruthi.Shruthi1" Date: Fri, 24 Feb 2023 21:34:38 +0000 Subject: [PATCH 173/205] 8266974: duplicate property key in java.sql.rowset resource bundle Backport-of: e3d5c9e7c4ab210ae7a4417a47632603910744a1 --- .../classes/com/sun/rowset/RowSetResourceBundle.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_de.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_es.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_fr.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_it.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_ja.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_ko.properties | 3 +-- .../com/sun/rowset/RowSetResourceBundle_pt_BR.properties | 3 +-- .../classes/com/sun/rowset/RowSetResourceBundle_sv.properties | 3 +-- .../com/sun/rowset/RowSetResourceBundle_zh_CN.properties | 3 +-- .../com/sun/rowset/RowSetResourceBundle_zh_TW.properties | 3 +-- 11 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle.properties index 47ad98d28ae..f84ede5eb41 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2010, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow : no meta data cachedrowsetimpl.movetoins2 = moveToInsertRow : invalid number of columns cachedrowsetimpl.tablename = Table name cannot be null cachedrowsetimpl.keycols = Invalid key columns -cachedrowsetimpl.invalidcol = Invalid column index cachedrowsetimpl.opnotsupp = Operation not supported by Database cachedrowsetimpl.matchcols = Match columns are not the same as those set cachedrowsetimpl.setmatchcols = Set Match columns before getting them diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_de.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_de.properties index fe9d17299e7..e1e43a16010 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_de.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2016, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: keine Metadaten cachedrowsetimpl.movetoins2 = moveToInsertRow: ung\u00FCltige Spaltenanzahl cachedrowsetimpl.tablename = Tabellenname darf nicht null sein cachedrowsetimpl.keycols = Ung\u00FCltige Schl\u00FCsselspalten -cachedrowsetimpl.invalidcol = Ung\u00FCltiger Spaltenindex cachedrowsetimpl.opnotsupp = Vorgang nicht von Datenbank unterst\u00FCtzt cachedrowsetimpl.matchcols = \u00DCbereinstimmungsspalten entsprechen nicht den festgelegten Spalten cachedrowsetimpl.setmatchcols = \u00DCbereinstimmungsspalten m\u00FCssen vor dem Abrufen festgelegt werden diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_es.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_es.properties index 8f9cb1f2392..a07408974a3 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_es.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: no hay metadatos cachedrowsetimpl.movetoins2 = moveToInsertRow: n\u00FAmero de columnas no v\u00E1lido cachedrowsetimpl.tablename = El nombre de la tabla no puede ser nulo cachedrowsetimpl.keycols = Columnas clave no v\u00E1lidas -cachedrowsetimpl.invalidcol = \u00CDndice de columnas no v\u00E1lido cachedrowsetimpl.opnotsupp = La base de datos no admite esta operaci\u00F3n cachedrowsetimpl.matchcols = Las columnas coincidentes no concuerdan con las definidas cachedrowsetimpl.setmatchcols = Defina las columnas coincidentes antes de obtenerlas diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_fr.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_fr.properties index 4beab2bf8f1..585ed33b035 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_fr.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow : aucune m\u00E9tadonn\u00E9e cachedrowsetimpl.movetoins2 = moveToInsertRow : nombre de colonnes non valide cachedrowsetimpl.tablename = Le nom de la table ne peut pas \u00EAtre NULL cachedrowsetimpl.keycols = Colonnes de cl\u00E9 non valides -cachedrowsetimpl.invalidcol = Index de colonne non valide cachedrowsetimpl.opnotsupp = Op\u00E9ration non prise en charge par la base de donn\u00E9es cachedrowsetimpl.matchcols = Les colonnes correspondantes ne sont pas les m\u00EAmes que les colonnes d\u00E9finies cachedrowsetimpl.setmatchcols = D\u00E9finir les colonnes correspondantes avant de les prendre diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_it.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_it.properties index 4261aedea70..f971660d290 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_it.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: nessun metadato cachedrowsetimpl.movetoins2 = moveToInsertRow: numero di colonne non valido cachedrowsetimpl.tablename = Il nome di tabella non pu\u00F2 essere nullo cachedrowsetimpl.keycols = Colonne chiave non valide -cachedrowsetimpl.invalidcol = Indice di colonna non valido cachedrowsetimpl.opnotsupp = Operazione non supportata dal database cachedrowsetimpl.matchcols = Le colonne di corrispondenza non coincidono con le colonne impostate cachedrowsetimpl.setmatchcols = Impostare le colonne di corrispondenza prima di recuperarle diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ja.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ja.properties index 3192a22063e..cd40ad2ef42 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ja.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2016, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: \u30E1\u30BF\u30C7\u30FC\u30BF\u3 cachedrowsetimpl.movetoins2 = moveToInsertRow: \u7121\u52B9\u306A\u5217\u6570 cachedrowsetimpl.tablename = \u8868\u540D\u306Bnull\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 cachedrowsetimpl.keycols = \u7121\u52B9\u306A\u30AD\u30FC\u5217 -cachedrowsetimpl.invalidcol = \u7121\u52B9\u306A\u5217\u7D22\u5F15 cachedrowsetimpl.opnotsupp = \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u306A\u3044\u64CD\u4F5C cachedrowsetimpl.matchcols = \u4E00\u81F4\u5217\u304C\u5217\u306E\u30BB\u30C3\u30C8\u3068\u540C\u3058\u3067\u306F\u3042\u308A\u307E\u305B\u3093 cachedrowsetimpl.setmatchcols = \u4E00\u81F4\u5217\u3092\u53D6\u5F97\u3059\u308B\u524D\u306B\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044 diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ko.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ko.properties index 81e468eeb1d..9041d671483 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ko.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2017, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: \uBA54\uD0C0\uB370\uC774\uD130\uA cachedrowsetimpl.movetoins2 = moveToInsertRow: \uC5F4 \uC218\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4. cachedrowsetimpl.tablename = \uD14C\uC774\uBE14 \uC774\uB984\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. cachedrowsetimpl.keycols = \uD0A4 \uC5F4\uC774 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4. -cachedrowsetimpl.invalidcol = \uC5F4 \uC778\uB371\uC2A4\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4. cachedrowsetimpl.opnotsupp = \uB370\uC774\uD130\uBCA0\uC774\uC2A4\uC5D0\uC11C \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC791\uC5C5\uC785\uB2C8\uB2E4. cachedrowsetimpl.matchcols = \uC77C\uCE58 \uC5F4\uC774 \uC124\uC815\uB41C \uC5F4\uACFC \uB3D9\uC77C\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. cachedrowsetimpl.setmatchcols = \uC77C\uCE58 \uC5F4\uC744 \uC124\uC815\uD55C \uD6C4 \uAC00\uC838\uC624\uC2ED\uC2DC\uC624. diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_pt_BR.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_pt_BR.properties index 6a2ebe4fa31..05a783ee8fc 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_pt_BR.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2016, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow : sem metadados cachedrowsetimpl.movetoins2 = moveToInsertRow : n\u00FAmero de colunas inv\u00E1lido cachedrowsetimpl.tablename = O nome da tabela n\u00E3o pode ser nulo cachedrowsetimpl.keycols = Colunas de chaves inv\u00E1lidas -cachedrowsetimpl.invalidcol = \u00CDndice de coluna inv\u00E1lido cachedrowsetimpl.opnotsupp = Opera\u00E7\u00E3o n\u00E3o suportada pelo Banco de Dados cachedrowsetimpl.matchcols = As colunas correspondentes n\u00E3o s\u00E3o iguais \u00E0s colunas definidas cachedrowsetimpl.setmatchcols = Definir Colunas correspondentes antes de obt\u00EA-las diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties index 912dc257219..5cac0f3c502 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2018, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: inga metadata cachedrowsetimpl.movetoins2 = moveToInsertRow: ogiltigt antal kolumner cachedrowsetimpl.tablename = Tabellnamnet kan inte vara null cachedrowsetimpl.keycols = Ogiltiga nyckelkolumner -cachedrowsetimpl.invalidcol = Ogiltigt kolumnindex cachedrowsetimpl.opnotsupp = Databasen har inte st\u00F6d f\u00F6r denna \u00E5tg\u00E4rd cachedrowsetimpl.matchcols = Matchningskolumnerna \u00E4r inte samma som de som st\u00E4llts in cachedrowsetimpl.setmatchcols = St\u00E4ll in matchningskolumnerna innan du h\u00E4mtar dem diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_CN.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_CN.properties index adb91c4e8d8..a9f1203518c 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_CN.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: \u65E0\u5143\u6570\u636E cachedrowsetimpl.movetoins2 = moveToInsertRow: \u5217\u6570\u65E0\u6548 cachedrowsetimpl.tablename = \u8868\u540D\u4E0D\u80FD\u4E3A\u7A7A\u503C cachedrowsetimpl.keycols = \u5173\u952E\u5B57\u5217\u65E0\u6548 -cachedrowsetimpl.invalidcol = \u5217\u7D22\u5F15\u65E0\u6548 cachedrowsetimpl.opnotsupp = \u64CD\u4F5C\u4E0D\u53D7\u6570\u636E\u5E93\u652F\u6301 cachedrowsetimpl.matchcols = \u5339\u914D\u5217\u4E0E\u8BBE\u7F6E\u7684\u90A3\u4E9B\u5339\u914D\u5217\u4E0D\u540C cachedrowsetimpl.setmatchcols = \u5728\u83B7\u53D6\u5339\u914D\u5217\u4E4B\u524D\u5148\u8BBE\u7F6E\u5339\u914D\u5217 diff --git a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_TW.properties b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_TW.properties index dba19053aee..d42340d39e4 100644 --- a/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_TW.properties +++ b/src/java.sql.rowset/share/classes/com/sun/rowset/RowSetResourceBundle_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, 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 @@ -60,7 +60,6 @@ cachedrowsetimpl.movetoins1 = moveToInsertRow: \u6C92\u6709\u63CF\u8FF0\u8CC7\u6 cachedrowsetimpl.movetoins2 = moveToInsertRow: \u6B04\u6578\u7121\u6548 cachedrowsetimpl.tablename = \u8868\u683C\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\u503C cachedrowsetimpl.keycols = \u95DC\u9375\u6B04\u7121\u6548 -cachedrowsetimpl.invalidcol = \u6B04\u7D22\u5F15\u7121\u6548 cachedrowsetimpl.opnotsupp = \u8CC7\u6599\u5EAB\u4E0D\u652F\u63F4\u4F5C\u696D cachedrowsetimpl.matchcols = \u5339\u914D\u6B04\u548C\u8A2D\u5B9A\u7684\u6B04\u4E0D\u540C cachedrowsetimpl.setmatchcols = \u5728\u53D6\u5F97\u5339\u914D\u6B04\u4E4B\u524D\u8A2D\u5B9A\u5B83\u5011 From 83456c63beb9904583d246390ebbf2d8a8102f14 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 27 Feb 2023 08:09:23 +0000 Subject: [PATCH 174/205] 8252532: use Utils.TEST_NATIVE_PATH instead of System.getProperty("test.nativepath") Reviewed-by: phh Backport-of: 4fe6a3da68d2c75a3706ecb9a2d3639711324102 --- test/hotspot/jtreg/gtest/GTestWrapper.java | 2 +- .../handshake/HandshakeTransitionTest.java | 10 +- .../jni/CalleeSavedRegisters/FPRegs.java | 11 +- .../jtreg/runtime/jni/atExit/TestAtExit.java | 4 +- .../jtreg/runtime/signal/SigTestDriver.java | 15 +- .../AttachFailed/AttachFailedTestBase.java | 18 +- .../nsk/jvmti/NativeLibraryCopier.java | 5 +- .../jdk/test/lib/process/ProcessTools.java | 157 +++++++++--------- 8 files changed, 114 insertions(+), 108 deletions(-) diff --git a/test/hotspot/jtreg/gtest/GTestWrapper.java b/test/hotspot/jtreg/gtest/GTestWrapper.java index f44676cd55d..08ee033a60b 100644 --- a/test/hotspot/jtreg/gtest/GTestWrapper.java +++ b/test/hotspot/jtreg/gtest/GTestWrapper.java @@ -48,7 +48,7 @@ public class GTestWrapper { public static void main(String[] args) throws Throwable { // gtestLauncher is located in /hotspot/gtest// // nativePath points either to /hotspot/jtreg/native or to /hotspot/gtest - Path nativePath = Paths.get(System.getProperty("test.nativepath")); + Path nativePath = Paths.get(Utils.TEST_NATIVE_PATH); String jvmVariantDir = getJVMVariantSubDir(); // let's assume it's /hotspot/gtest Path path = nativePath.resolve(jvmVariantDir); diff --git a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java index 2a795f01514..21859e86ac9 100644 --- a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java +++ b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java @@ -22,10 +22,7 @@ * */ -import java.io.File; -import java.nio.file.Paths; -import java.time.Duration; - +import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -43,11 +40,9 @@ */ public class HandshakeTransitionTest { - public static native void someTime(int ms); public static void main(String[] args) throws Exception { - String lib = System.getProperty("test.nativepath"); WhiteBox wb = WhiteBox.getWhiteBox(); Boolean useJVMCICompiler = wb.getBooleanVMFlag("UseJVMCICompiler"); String useJVMCICompilerStr; @@ -60,7 +55,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( true, - "-Djava.library.path=" + lib, + "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, "-XX:+SafepointALot", "-XX:GuaranteedSafepointInterval=20", "-Xlog:ergo*", @@ -71,7 +66,6 @@ public static void main(String[] args) throws Exception { useJVMCICompilerStr, "HandshakeTransitionTest$Test"); - OutputAnalyzer output = ProcessTools.executeProcess(pb); output.reportDiagnosticSummary(); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java index 7da98a05985..3a373a3be98 100644 --- a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java +++ b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, 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 @@ -22,7 +22,7 @@ * */ -/** +/* * @test * @bug 8067744 * @comment Test uses custom launcher that starts VM in primordial thread. This is @@ -35,7 +35,6 @@ 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; @@ -47,14 +46,14 @@ public class FPRegs { public static void main(String[] args) throws IOException { - Path launcher = Paths.get(System.getProperty("test.nativepath"), "FPRegs" + (Platform.isWindows() ? ".exe" : "")); + Path launcher = Paths.get(Utils.TEST_NATIVE_PATH, "FPRegs" + (Platform.isWindows() ? ".exe" : "")); System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)")); Path jvmLib = findJVM(); ProcessBuilder pb = new ProcessBuilder(launcher.toString(), jvmLib.toString()); // bin as working directory to let Windows load dll pb.directory(jvmLib.getParent().getParent().toFile()); - OutputAnalyzer outputf = new OutputAnalyzer(pb.start()); - outputf.shouldHaveExitValue(0); + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + oa.shouldHaveExitValue(0); } static Path findJVM() throws IOException { diff --git a/test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java b/test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java index 6fadfeb4ac7..83af171f396 100644 --- a/test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java +++ b/test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java @@ -20,6 +20,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + +import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -57,7 +59,7 @@ public static void main(String[] args) throws Exception { // We mustn't load Tester in this VM so we exec by name. String main = "TestAtExit$Tester"; - String jlp = "-Djava.library.path=" + System.getProperty("test.nativepath"); + String jlp = "-Djava.library.path=" + Utils.TEST_NATIVE_PATH; // First run will terminate via DestroyJavaVM OutputAnalyzer output = ProcessTools.executeTestJvm(jlp, main); output.shouldNotContain("Unexpected"); diff --git a/test/hotspot/jtreg/runtime/signal/SigTestDriver.java b/test/hotspot/jtreg/runtime/signal/SigTestDriver.java index 8d4cd38c516..6fcc41c8ab2 100644 --- a/test/hotspot/jtreg/runtime/signal/SigTestDriver.java +++ b/test/hotspot/jtreg/runtime/signal/SigTestDriver.java @@ -45,7 +45,7 @@ public static void main(String[] args) { } // At least one argument should be specified - if ( (args == null) || (args.length < 1) ) { + if ((args == null) || (args.length < 1)) { throw new IllegalArgumentException("At lease one argument should be specified, the signal name"); } @@ -65,7 +65,7 @@ public static void main(String[] args) { } } - Path test = Paths.get(System.getProperty("test.nativepath")) + Path test = Paths.get(Utils.TEST_NATIVE_PATH) .resolve("sigtest") .toAbsolutePath(); String envVar = Platform.sharedLibraryPathVariableName(); @@ -87,16 +87,17 @@ public static void main(String[] args) { cmd.addAll(vmargs()); // add test specific arguments w/o signame - cmd.addAll(Arrays.asList(args) - .subList(1, args.length)); + var argList = Arrays.asList(args) + .subList(1, args.length); + cmd.addAll(argList); boolean passed = true; - for (String mode : new String[]{"sigset", "sigaction"}) { + for (String mode : new String[] {"sigset", "sigaction"}) { for (String scenario : new String[] {"nojvm", "prepre", "prepost", "postpre", "postpost"}) { cmd.set(modeIdx, mode); cmd.set(scenarioIdx, scenario); - System.out.printf("START TESTING: SIGNAL = %s, MODE = %s, SCENARIO=%s%n",signame, mode, scenario); + System.out.printf("START TESTING: SIGNAL = %s, MODE = %s, SCENARIO=%s%n", signame, mode, scenario); System.out.printf("Do execute: %s%n", cmd.toString()); ProcessBuilder pb = new ProcessBuilder(cmd); @@ -117,7 +118,7 @@ public static void main(String[] args) { oa.reportDiagnosticSummary(); int exitCode = oa.getExitValue(); if (exitCode == 0) { - System.out.println("PASSED with exit code 0"); + System.out.println("PASSED with exit code 0"); } else { System.out.println("FAILED with exit code " + exitCode); passed = false; diff --git a/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed/AttachFailedTestBase.java b/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed/AttachFailedTestBase.java index 017c7654cfd..d6b1159a4b0 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed/AttachFailedTestBase.java +++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed/AttachFailedTestBase.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 @@ -20,9 +20,15 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -import java.nio.file.Paths; -import jdk.test.lib.dcmd.*; + import jdk.test.lib.Platform; +import jdk.test.lib.Utils; +import jdk.test.lib.dcmd.CommandExecutor; +import jdk.test.lib.dcmd.JMXExecutor; +import jdk.test.lib.dcmd.PidJcmdExecutor; + +import java.nio.file.Paths; + import org.testng.annotations.Test; public abstract class AttachFailedTestBase { @@ -42,18 +48,18 @@ public static String getSharedObjectPath(String name) { libname = "lib" + name + ".so"; } - return Paths.get(System.getProperty("test.nativepath"), libname) + return Paths.get(Utils.TEST_NATIVE_PATH, libname) .toAbsolutePath() .toString(); } @Test - public void jmx() throws Throwable { + public void jmx() { run(new JMXExecutor()); } @Test - public void cli() throws Throwable { + public void cli() { run(new PidJcmdExecutor()); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeLibraryCopier.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeLibraryCopier.java index 222eb346fed..4f846f997ef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeLibraryCopier.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeLibraryCopier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ package nsk.jvmti; import jdk.test.lib.Platform; +import jdk.test.lib.Utils; import java.io.IOException; import java.nio.file.Files; @@ -32,7 +33,7 @@ public class NativeLibraryCopier { public static void main(String[] args) { - Path src = Paths.get( System.getProperty("test.nativepath", ".")) + Path src = Paths.get(Utils.TEST_NATIVE_PATH) .resolve(libname(args[0])) .toAbsolutePath(); diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index e770b6c3a53..8560f8db467 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -23,12 +23,19 @@ package jdk.test.lib.process; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; + import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.nio.file.Paths; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -39,25 +46,20 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.function.Predicate; import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.stream.Collectors; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.Platform; -import jdk.test.lib.Utils; public final class ProcessTools { private static final class LineForwarder extends StreamPumper.LinePump { private final PrintStream ps; private final String prefix; + LineForwarder(String prefix, PrintStream os) { this.ps = os; this.prefix = prefix; } + @Override protected void processLine(String line) { ps.println("[" + prefix + "] " + line); @@ -70,23 +72,25 @@ private ProcessTools() { /** *

      Starts a process from its builder.

      * The default redirects of STDOUT and STDERR are started - * @param name The process name + * + * @param name The process name * @param processBuilder The process builder * @return Returns the initialized process * @throws IOException */ public static Process startProcess(String name, ProcessBuilder processBuilder) - throws IOException { - return startProcess(name, processBuilder, (Consumer)null); + throws IOException { + return startProcess(name, processBuilder, (Consumer) null); } /** *

      Starts a process from its builder.

      * The default redirects of STDOUT and STDERR are started *

      It is possible to monitor the in-streams via the provided {@code consumer} - * @param name The process name - * @param consumer {@linkplain Consumer} instance to process the in-streams + * + * @param name The process name + * @param consumer {@linkplain Consumer} instance to process the in-streams * @param processBuilder The process builder * @return Returns the initialized process * @throws IOException @@ -95,7 +99,7 @@ public static Process startProcess(String name, public static Process startProcess(String name, ProcessBuilder processBuilder, Consumer consumer) - throws IOException { + throws IOException { try { return startProcess(name, processBuilder, consumer, null, -1, TimeUnit.NANOSECONDS); } catch (InterruptedException | TimeoutException e) { @@ -111,14 +115,15 @@ public static Process startProcess(String name, * It is possible to wait for the process to get to a warmed-up state * via {@linkplain Predicate} condition on the STDOUT *

      - * @param name The process name + * + * @param name The process name * @param processBuilder The process builder - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. - * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever - * @param unit The timeout {@linkplain TimeUnit} + * @param linePredicate The {@linkplain Predicate} to use on the STDOUT + * Used to determine the moment the target app is + * properly warmed-up. + * It can be null - in that case the warmup is skipped. + * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever + * @param unit The timeout {@linkplain TimeUnit} * @return Returns the initialized {@linkplain Process} * @throws IOException * @throws InterruptedException @@ -129,7 +134,7 @@ public static Process startProcess(String name, final Predicate linePredicate, long timeout, TimeUnit unit) - throws IOException, InterruptedException, TimeoutException { + throws IOException, InterruptedException, TimeoutException { return startProcess(name, processBuilder, null, linePredicate, timeout, unit); } @@ -141,15 +146,16 @@ public static Process startProcess(String name, * via {@linkplain Predicate} condition on the STDOUT and monitor the * in-streams via the provided {@linkplain Consumer} *

      - * @param name The process name + * + * @param name The process name * @param processBuilder The process builder - * @param lineConsumer The {@linkplain Consumer} the lines will be forwarded to - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. - * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever - * @param unit The timeout {@linkplain TimeUnit} + * @param lineConsumer The {@linkplain Consumer} the lines will be forwarded to + * @param linePredicate The {@linkplain Predicate} to use on the STDOUT + * Used to determine the moment the target app is + * properly warmed-up. + * It can be null - in that case the warmup is skipped. + * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever + * @param unit The timeout {@linkplain TimeUnit} * @return Returns the initialized {@linkplain Process} * @throws IOException * @throws InterruptedException @@ -161,8 +167,8 @@ public static Process startProcess(String name, final Predicate linePredicate, long timeout, TimeUnit unit) - throws IOException, InterruptedException, TimeoutException { - System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" "))); + throws IOException, InterruptedException, TimeoutException { + System.out.println("[" + name + "]:" + String.join(" ", processBuilder.command())); Process p = privilegedStart(processBuilder); StreamPumper stdout = new StreamPumper(p.getInputStream()); StreamPumper stderr = new StreamPumper(p.getErrorStream()); @@ -211,7 +217,7 @@ protected void processLine(String line) { } } catch (TimeoutException | InterruptedException e) { System.err.println("Failed to start a process (thread dump follows)"); - for(Map.Entry s : Thread.getAllStackTraces().entrySet()) { + for (Map.Entry s : Thread.getAllStackTraces().entrySet()) { printStack(s.getKey(), s.getValue()); } @@ -235,12 +241,13 @@ protected void processLine(String line) { * via {@linkplain Predicate} condition on the STDOUT. The warm-up will * wait indefinitely. *

      - * @param name The process name + * + * @param name The process name * @param processBuilder The process builder - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. + * @param linePredicate The {@linkplain Predicate} to use on the STDOUT + * Used to determine the moment the target app is + * properly warmed-up. + * It can be null - in that case the warmup is skipped. * @return Returns the initialized {@linkplain Process} * @throws IOException * @throws InterruptedException @@ -250,7 +257,7 @@ protected void processLine(String line) { public static Process startProcess(String name, ProcessBuilder processBuilder, final Predicate linePredicate) - throws IOException, InterruptedException, TimeoutException { + throws IOException, InterruptedException, TimeoutException { return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS); } @@ -265,7 +272,7 @@ public static long getProcessId() throws Exception { /** * Create ProcessBuilder using the java launcher from the jdk to be tested. - * + *

      * @param command Arguments to pass to the java command. * @return The ProcessBuilder instance representing the java command. */ @@ -275,7 +282,7 @@ public static ProcessBuilder createJavaProcessBuilder(List command) { /** * Create ProcessBuilder using the java launcher from the jdk to be tested. - * + *

      * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts * to the java arguments. * @param command Arguments to pass to the java command. @@ -287,7 +294,7 @@ public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOp /** * Create ProcessBuilder using the java launcher from the jdk to be tested. - * + *

      * @param command Arguments to pass to the java command. * @return The ProcessBuilder instance representing the java command. */ @@ -328,8 +335,7 @@ public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOp } private static void printStack(Thread t, StackTraceElement[] stack) { - System.out.println("\t" + t + - " stack: (length = " + stack.length + ")"); + System.out.println("\t" + t + " stack: (length = " + stack.length + ")"); if (t != null) { for (StackTraceElement stack1 : stack) { System.out.println("\t" + stack1); @@ -359,10 +365,10 @@ public static OutputAnalyzer executeTestJvm(List cmds) throws Exception * Executes a test jvm process, waits for it to finish and returns the process output. * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. * The java from the test.jdk is used to execute the command. - * + *

      * The command line will be like: * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds - * + *

      * The jvm process will have exited before this method returns. * * @param cmds User specified arguments. @@ -374,9 +380,9 @@ public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception { } /** - * @see #executeTestJvm(String...) * @param cmds User specified arguments. * @return The output from the process. + * @see #executeTestJvm(String...) */ public static OutputAnalyzer executeTestJava(String... cmds) throws Exception { return executeTestJvm(cmds); @@ -385,6 +391,7 @@ public static OutputAnalyzer executeTestJava(String... cmds) throws Exception { /** * Executes a process, waits for it to finish and returns the process output. * The process will have exited before this method returns. + * * @param pb The ProcessBuilder to execute. * @return The {@linkplain OutputAnalyzer} instance wrapping the process. */ @@ -396,7 +403,8 @@ public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception * Executes a process, pipe some text into its STDIN, waits for it * to finish and returns the process output. The process will have exited * before this method returns. - * @param pb The ProcessBuilder to execute. + * + * @param pb The ProcessBuilder to execute. * @param input The text to pipe into STDIN. Can be null. * @return The {@linkplain OutputAnalyzer} instance wrapping the process. */ @@ -407,9 +415,9 @@ public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) thr try { p = privilegedStart(pb); if (input != null) { - try (PrintStream ps = new PrintStream(p.getOutputStream())) { - ps.print(input); - } + try (PrintStream ps = new PrintStream(p.getOutputStream())) { + ps.print(input); + } } output = new OutputAnalyzer(p); @@ -433,7 +441,7 @@ public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) thr /** * Executes a process, waits for it to finish and returns the process output. - * + *

      * The process will have exited before this method returns. * * @param cmds The command line to execute. @@ -445,22 +453,20 @@ public static OutputAnalyzer executeProcess(String... cmds) throws Throwable { /** * Used to log command line, stdout, stderr and exit code from an executed process. - * @param pb The executed process. + * + * @param pb The executed process. * @param output The output from the process. */ public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) { String stderr = output == null ? "null" : output.getStderr(); String stdout = output == null ? "null" : output.getStdout(); - String exitValue = output == null ? "null": Integer.toString(output.getExitValue()); - StringBuilder logMsg = new StringBuilder(); - final String nl = System.getProperty("line.separator"); - logMsg.append("--- ProcessLog ---" + nl); - logMsg.append("cmd: " + getCommandLine(pb) + nl); - logMsg.append("exitvalue: " + exitValue + nl); - logMsg.append("stderr: " + stderr + nl); - logMsg.append("stdout: " + stdout + nl); - - return logMsg.toString(); + String exitValue = output == null ? "null" : Integer.toString(output.getExitValue()); + return String.format("--- ProcessLog ---%n" + + "cmd: %s%n" + + "exitvalue: %s%n" + + "stderr: %s%n" + + "stdout: %s%n", + getCommandLine(pb), exitValue, stderr, stdout); } /** @@ -480,7 +486,7 @@ public static String getCommandLine(ProcessBuilder pb) { /** * Executes a process, waits for it to finish, prints the process output * to stdout, and returns the process output. - * + *

      * The process will have exited before this method returns. * * @param cmds The command line to execute. @@ -488,7 +494,7 @@ public static String getCommandLine(ProcessBuilder pb) { */ public static OutputAnalyzer executeCommand(String... cmds) throws Throwable { - String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" ")); + String cmdLine = String.join(" ", cmds); System.out.println("Command line: [" + cmdLine + "]"); OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds); System.out.println(analyzer.getOutput()); @@ -498,7 +504,7 @@ public static OutputAnalyzer executeCommand(String... cmds) /** * Executes a process, waits for it to finish, prints the process output * to stdout and returns the process output. - * + *

      * The process will have exited before this method returns. * * @param pb The ProcessBuilder to execute. @@ -521,20 +527,19 @@ public static OutputAnalyzer executeCommand(ProcessBuilder pb) * test that uses/loads JVM. * * @param executableName The name of an executable to be launched. - * @param args Arguments for the executable. + * @param args Arguments for the executable. * @return New ProcessBuilder instance representing the command. */ public static ProcessBuilder createNativeTestProcessBuilder(String executableName, String... args) throws Exception { executableName = Platform.isWindows() ? executableName + ".exe" : executableName; - String executable = Paths.get(System.getProperty("test.nativepath"), executableName) - .toAbsolutePath() - .toString(); + String executable = Paths.get(Utils.TEST_NATIVE_PATH, executableName) + .toAbsolutePath() + .toString(); ProcessBuilder pb = new ProcessBuilder(executable); pb.command().addAll(Arrays.asList(args)); - addJvmLib(pb); - return pb; + return addJvmLib(pb); } /** @@ -549,7 +554,7 @@ public static ProcessBuilder addJvmLib(ProcessBuilder pb) throws Exception { String currentLibPath = pb.environment().get(libPathVar); String newLibPath = jvmLibDir; - if ( (currentLibPath != null) && !currentLibPath.isEmpty() ) { + if ((currentLibPath != null) && !currentLibPath.isEmpty() ) { newLibPath = currentLibPath + File.pathSeparator + jvmLibDir; } @@ -561,11 +566,9 @@ public static ProcessBuilder addJvmLib(ProcessBuilder pb) throws Exception { private static Process privilegedStart(ProcessBuilder pb) throws IOException { try { return AccessController.doPrivileged( - (PrivilegedExceptionAction) () -> pb.start()); + (PrivilegedExceptionAction) pb::start); } catch (PrivilegedActionException e) { - @SuppressWarnings("unchecked") - IOException t = (IOException) e.getException(); - throw t; + throw (IOException) e.getException(); } } From cfb05cb26d1b16fc12c2ba2486d00b8ebacc04da Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 27 Feb 2023 08:55:59 +0000 Subject: [PATCH 175/205] 8302903: [11u] Add modified test snippet after backport of JDK-8221871 Reviewed-by: phh --- .../testHtmlVersion/TestHtmlVersion.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java index bc3ef2c5106..434851756b4 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java @@ -147,6 +147,25 @@ void html5Output() { + "