From 6e1f17bb9c8f31fdfcf825e296347c1f44fa1a82 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 6 Aug 2024 07:06:43 +0000 Subject: [PATCH 1/8] 8337810: ProblemList BasicDirectoryModel/LoaderThreadCount.java on Windows Reviewed-by: clanger --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index f8bdfd26e8f..bd29d64addf 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -640,6 +640,7 @@ javax/sound/sampled/Clip/ClipFlushCrash.java 8308395 linux-x64 # jdk_swing javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,windows-all +javax/swing/plaf/basic/BasicDirectoryModel/LoaderThreadCount.java 8333880 windows-all javax/swing/JFrame/MaximizeWindowTest.java 8321289 linux-all javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 8233582 linux-all From 29aa06a3bd5bd17c32406abcbaf19bb8b461cbd4 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 6 Aug 2024 09:07:44 +0000 Subject: [PATCH 2/8] 8332522: SwitchBootstraps::mappedEnumLookup constructs unused array Reviewed-by: liach, redestad --- .../java/lang/runtime/SwitchBootstraps.java | 112 ++++++++++++------ .../bench/java/lang/runtime/SwitchEnum.java | 105 ++++++++++++++++ 2 files changed, 178 insertions(+), 39 deletions(-) create mode 100644 test/micro/org/openjdk/bench/java/lang/runtime/SwitchEnum.java diff --git a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java index ccb33a0e4db..43f7339c75a 100644 --- a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java +++ b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java @@ -56,6 +56,7 @@ import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.STRONG; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import static java.util.Objects.requireNonNull; @@ -95,19 +96,13 @@ private SwitchBootstraps() {} private static final ClassDesc CD_Objects = ReferenceClassDescImpl.ofValidated("Ljava/util/Objects;"); private static class StaticHolders { - private static final MethodHandle NULL_CHECK; - private static final MethodHandle IS_ZERO; - private static final MethodHandle MAPPED_ENUM_LOOKUP; + private static final MethodHandle MAPPED_ENUM_SWITCH; static { try { - NULL_CHECK = LOOKUP.findStatic(Objects.class, "isNull", - MethodType.methodType(boolean.class, Object.class)); - IS_ZERO = LOOKUP.findStatic(SwitchBootstraps.class, "isZero", - MethodType.methodType(boolean.class, int.class)); - MAPPED_ENUM_LOOKUP = LOOKUP.findStatic(SwitchBootstraps.class, "mappedEnumLookup", - MethodType.methodType(int.class, Enum.class, MethodHandles.Lookup.class, - Class.class, EnumDesc[].class, EnumMap.class)); + MAPPED_ENUM_SWITCH = LOOKUP.findStatic(SwitchBootstraps.class, "mappedEnumSwitch", + MethodType.methodType(int.class, Enum.class, int.class, MethodHandles.Lookup.class, + Class.class, EnumDesc[].class, MappedEnumCache.class)); } catch (ReflectiveOperationException e) { throw new ExceptionInInitializerError(e); @@ -211,10 +206,6 @@ private static void verifyLabel(Object label, Class selectorType) { } } - private static boolean isZero(int value) { - return value == 0; - } - /** * Bootstrap method for linking an {@code invokedynamic} call site that * implements a {@code switch} on a target of an enum type. The static @@ -286,23 +277,27 @@ public static CallSite enumSwitch(MethodHandles.Lookup lookup, labels = labels.clone(); Class enumClass = invocationType.parameterType(0); - labels = Stream.of(labels).map(l -> convertEnumConstants(lookup, enumClass, l)).toArray(); + boolean constantsOnly = true; + int len = labels.length; + + for (int i = 0; i < len; i++) { + Object convertedLabel = + convertEnumConstants(lookup, enumClass, labels[i]); + labels[i] = convertedLabel; + if (constantsOnly) + constantsOnly = convertedLabel instanceof EnumDesc; + } MethodHandle target; - boolean constantsOnly = Stream.of(labels).allMatch(l -> enumClass.isAssignableFrom(EnumDesc.class)); if (labels.length > 0 && constantsOnly) { //If all labels are enum constants, construct an optimized handle for repeat index 0: //if (selector == null) return -1 //else if (idx == 0) return mappingArray[selector.ordinal()]; //mapping array created lazily //else return "typeSwitch(labels)" - MethodHandle body = - MethodHandles.guardWithTest(MethodHandles.dropArguments(StaticHolders.NULL_CHECK, 0, int.class), - MethodHandles.dropArguments(MethodHandles.constant(int.class, -1), 0, int.class, Object.class), - MethodHandles.guardWithTest(MethodHandles.dropArguments(StaticHolders.IS_ZERO, 1, Object.class), - generateTypeSwitch(lookup, invocationType.parameterType(0), labels), - MethodHandles.insertArguments(StaticHolders.MAPPED_ENUM_LOOKUP, 1, lookup, enumClass, labels, new EnumMap()))); - target = MethodHandles.permuteArguments(body, MethodType.methodType(int.class, Object.class, int.class), 1, 0); + EnumDesc[] enumDescLabels = + Arrays.copyOf(labels, labels.length, EnumDesc[].class); + target = MethodHandles.insertArguments(StaticHolders.MAPPED_ENUM_SWITCH, 2, lookup, enumClass, enumDescLabels, new MappedEnumCache()); } else { target = generateTypeSwitch(lookup, invocationType.parameterType(0), labels); } @@ -331,26 +326,63 @@ private static > Object convertEnumConstants(MethodHandles.Loo } } - private static > int mappedEnumLookup(T value, MethodHandles.Lookup lookup, Class enumClass, EnumDesc[] labels, EnumMap enumMap) { - if (enumMap.map == null) { - T[] constants = SharedSecrets.getJavaLangAccess().getEnumConstantsShared(enumClass); - int[] map = new int[constants.length]; - int ordinal = 0; - - for (T constant : constants) { - map[ordinal] = labels.length; + private static > int mappedEnumSwitch(T value, int restartIndex, MethodHandles.Lookup lookup, Class enumClass, EnumDesc[] labels, MappedEnumCache enumCache) throws Throwable { + if (value == null) { + return -1; + } - for (int i = 0; i < labels.length; i++) { - if (Objects.equals(labels[i].constantName(), constant.name())) { - map[ordinal] = i; - break; + if (restartIndex != 0) { + MethodHandle generatedSwitch = enumCache.generatedSwitch; + if (generatedSwitch == null) { + synchronized (enumCache) { + generatedSwitch = enumCache.generatedSwitch; + + if (generatedSwitch == null) { + generatedSwitch = + generateTypeSwitch(lookup, enumClass, labels) + .asType(MethodType.methodType(int.class, + Enum.class, + int.class)); + enumCache.generatedSwitch = generatedSwitch; } } + } + + return (int) generatedSwitch.invokeExact(value, restartIndex); + } + + int[] constantsMap = enumCache.constantsMap; + + if (constantsMap == null) { + synchronized (enumCache) { + constantsMap = enumCache.constantsMap; - ordinal++; + if (constantsMap == null) { + T[] constants = SharedSecrets.getJavaLangAccess() + .getEnumConstantsShared(enumClass); + constantsMap = new int[constants.length]; + int ordinal = 0; + + for (T constant : constants) { + constantsMap[ordinal] = labels.length; + + for (int i = 0; i < labels.length; i++) { + if (Objects.equals(labels[i].constantName(), + constant.name())) { + constantsMap[ordinal] = i; + break; + } + } + + ordinal++; + } + + enumCache.constantsMap = constantsMap; + } } } - return enumMap.map[value.ordinal()]; + + return constantsMap[value.ordinal()]; } private static final class ResolvedEnumLabels implements BiPredicate { @@ -395,9 +427,11 @@ public boolean test(Integer labelIndex, Object value) { } } - private static final class EnumMap { + private static final class MappedEnumCache { + @Stable + public int[] constantsMap; @Stable - public int[] map; + public MethodHandle generatedSwitch; } /* diff --git a/test/micro/org/openjdk/bench/java/lang/runtime/SwitchEnum.java b/test/micro/org/openjdk/bench/java/lang/runtime/SwitchEnum.java new file mode 100644 index 00000000000..bfec0d321b2 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/runtime/SwitchEnum.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.java.lang.runtime; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; + +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS) +@Fork(3) +public class SwitchEnum { + + public E[] inputs; + @Setup + public void setup() { + inputs = E.values(); + } + + @Benchmark + public int enumSwitchWithBootstrap() { + int sum = 0; + for (E e : inputs) { + sum += switch (e) { + case null -> -1; + case E0 -> 10; + case E1 -> 11; + case E2 -> 12; + case E3 -> 13; + case E4 -> 14; + case E5 -> 15; + case E6 -> 16; + case E7 -> 17; + case E8 -> 18; + case E9 -> 19; + default -> 17; + }; + } + return sum; + } + + @Benchmark + public int enumSwitchTraditional() { + int sum = 0; + for (E e : inputs) { + sum += switch (e) { + case E0 -> 10; + case E1 -> 11; + case E2 -> 12; + case E3 -> 13; + case E4 -> 14; + case E5 -> 15; + case E6 -> 16; + case E7 -> 17; + case E8 -> 18; + case E9 -> 19; + default -> 17; + }; + } + return sum; + } + + public static void main(String[] args) { + SwitchEnum s = new SwitchEnum(); + s.setup(); + System.out.println(s.enumSwitchWithBootstrap()); + System.out.println(s.enumSwitchTraditional()); + } + + enum E { + E0, E1, E2, E3, E4, E5, E6, E7, E8, E9; + } +} From c5e34c7749fde7a03bd23fad9a9425bbf03ff1dc Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Tue, 6 Aug 2024 09:28:12 +0000 Subject: [PATCH 3/8] 8337798: JFR: Remove jdk/jfr/api/consumer/recordingstream/TestOnEvent.java from ProblemList.txt Reviewed-by: mgronlun --- test/jdk/ProblemList.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index bd29d64addf..3211f27b5c1 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -744,7 +744,6 @@ jdk/jfr/event/runtime/TestResidentSetSizeEvent.java 8309846 aix-ppc6 jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64 jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64 jdk/jfr/jvm/TestWaste.java 8282427 generic-all -jdk/jfr/api/consumer/recordingstream/TestOnEvent.java 8255404 linux-x64,linux-aarch64 ############################################################################ From 7f2a36d64272e6454bc876ee8668080bc0c54ea3 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 6 Aug 2024 09:37:21 +0000 Subject: [PATCH 4/8] 8337344: Redundant javadoc at RasterPrinterJob.isCancelled Reviewed-by: aivanov, prr --- .../share/classes/sun/print/RasterPrinterJob.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 0dfa5e42d9a..82f47824bfa 100644 --- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -2474,11 +2474,7 @@ public void cancel() { } } - /** - * Returns true is a print job is ongoing but will - * be cancelled and the next opportunity. false is - * returned otherwise. - */ + @Override public boolean isCancelled() { boolean cancelled = false; From 9bd6fed83aeb448d2e9a697191e1b810027998b6 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 6 Aug 2024 20:11:21 +0000 Subject: [PATCH 5/8] 8337506: Disable "best-fit" mapping on Windows command line Reviewed-by: alanb --- src/java.base/share/native/launcher/main.c | 22 ++++- .../launcher/DisableBestFitMappingTest.java | 83 +++++++++++++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 test/jdk/tools/launcher/DisableBestFitMappingTest.java diff --git a/src/java.base/share/native/launcher/main.c b/src/java.base/share/native/launcher/main.c index d3898d7adc6..c504c13154f 100644 --- a/src/java.base/share/native/launcher/main.c +++ b/src/java.base/share/native/launcher/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,25 @@ main(int argc, char **argv) } } } - JLI_CmdToArgs(GetCommandLine()); + + // Obtain the command line in UTF-16, then convert it to ANSI code page + // without the "best-fit" option + LPWSTR wcCmdline = GetCommandLineW(); + int mbSize = WideCharToMultiByte(CP_ACP, + WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR, + wcCmdline, -1, NULL, 0, NULL, NULL); + // If the call to WideCharToMultiByte() fails, it returns 0, which + // will then make the following JLI_MemAlloc() to issue exit(1) + LPSTR mbCmdline = JLI_MemAlloc(mbSize); + if (WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR, + wcCmdline, -1, mbCmdline, mbSize, NULL, NULL) == 0) { + perror("command line encoding conversion failure"); + exit(1); + } + + JLI_CmdToArgs(mbCmdline); + JLI_MemFree(mbCmdline); + margc = JLI_GetStdArgc(); // add one more to mark the end margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *))); diff --git a/test/jdk/tools/launcher/DisableBestFitMappingTest.java b/test/jdk/tools/launcher/DisableBestFitMappingTest.java new file mode 100644 index 00000000000..6602aae60a9 --- /dev/null +++ b/test/jdk/tools/launcher/DisableBestFitMappingTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8337506 + * @summary Verify Command Line arguments are not mapped with + * "best-fit" mappings on Windows + * @requires (os.family == "windows") + * @library /test/lib + * @run junit DisableBestFitMappingTest + */ +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.util.stream.Stream; +import jdk.test.lib.process.ProcessTools; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.*; + +public class DisableBestFitMappingTest { + private static final CharsetEncoder NATIVE_ENC = + Charset.forName(System.getProperty("native.encoding")).newEncoder(); + private static final String REPLACEMENT = + NATIVE_ENC.charset().decode(ByteBuffer.wrap(NATIVE_ENC.replacement())).toString(); + private static final int EXIT_SUCCESS = 0; + private static final int EXIT_FAILURE = -1; + + static Stream CMD_ARGS() { + return Stream.of( + Arguments.of("aa\uff02 \uff02bb", "aa" + REPLACEMENT + " " + REPLACEMENT + "bb"), + Arguments.of("aa\uff01bb", "aa" + REPLACEMENT + "bb"), + Arguments.of("aa\u221ebb", "aa" + REPLACEMENT + "bb") + ); + } + + @ParameterizedTest + @MethodSource("CMD_ARGS") + void testDisableBestFitMapping(String arg, String expected) throws Exception { + // Only execute if the arg cannot be encoded + assumeFalse(NATIVE_ENC.canEncode(arg), + "native.encoding (%s) can encode the argument '%s'. Test ignored." + .formatted(NATIVE_ENC.charset(), arg)); + + var result= ProcessTools.executeTestJava( + DisableBestFitMappingTest.class.getSimpleName(), arg, expected); + result.asLines().forEach(System.out::println); + assertEquals(EXIT_SUCCESS, result.getExitValue(), + "Disabling best-fit mapping failed"); + } + + public static void main(String... args) { + System.out.println(args[0]); + System.out.println(args[1]); + System.exit(args[0].equals(args[1]) ? EXIT_SUCCESS : EXIT_FAILURE); + } +} From 1cc3f6d5fcc8ead6e1302d8292de60d16fabacec Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 6 Aug 2024 21:10:06 +0000 Subject: [PATCH 6/8] 8235404: [macos] JOptionPane blocks drawing string on another component Reviewed-by: honkar, dnguyen --- .../classes/javax/swing/JOptionPane.java | 7 +- .../swing/JOptionPane/OptionPaneInput.java | 80 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 test/jdk/javax/swing/JOptionPane/OptionPaneInput.java diff --git a/src/java.desktop/share/classes/javax/swing/JOptionPane.java b/src/java.desktop/share/classes/javax/swing/JOptionPane.java index 930acc90b35..1c1f3ee9ba3 100644 --- a/src/java.desktop/share/classes/javax/swing/JOptionPane.java +++ b/src/java.desktop/share/classes/javax/swing/JOptionPane.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -883,6 +883,11 @@ public static int showOptionDialog(Component parentComponent, Object selectedValue = pane.getValue(); + if (parentComponent != null) { + parentComponent.revalidate(); + parentComponent.repaint(); + } + if(selectedValue == null) return CLOSED_OPTION; if(options == null) { diff --git a/test/jdk/javax/swing/JOptionPane/OptionPaneInput.java b/test/jdk/javax/swing/JOptionPane/OptionPaneInput.java new file mode 100644 index 00000000000..998efccf1f3 --- /dev/null +++ b/test/jdk/javax/swing/JOptionPane/OptionPaneInput.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Graphics2D; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 8235404 + * @summary Checks that JOptionPane doesn't block drawing strings on another component + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual OptionPaneInput + */ +public class OptionPaneInput { + private static JFrame f; + private static Canvas c; + private static JTextField t; + private static final String instructions = """ + 1. Type "test" into the message dialog. + 2. Press enter key. + 3. Press OK button. + 4. If the OptionPaneInput frame has test drawn on it, pass. Otherwise fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame testFrame = new PassFailJFrame(instructions); + + SwingUtilities.invokeAndWait(() -> createGUI()); + testFrame.awaitAndCheck(); + } + + public static void createGUI() { + f = new JFrame("OptionPaneInput"); + c = new Canvas(); + t = new JTextField(); + f.add(c); + + t.addActionListener(e -> { + String text = t.getText(); + Graphics2D g2 = (Graphics2D)(c.getGraphics()); + g2.setColor(Color.BLACK); + g2.drawString(text, 10, 10); + System.out.println("drawing "+text); + g2.dispose(); + }); + + f.setSize(300, 100); + PassFailJFrame.addTestWindow(f); + PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL); + f.setVisible(true); + + JOptionPane.showMessageDialog(f, t); + } +} From 033dac65ec5d05322c86e50e13e5a2f409a97c70 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Tue, 6 Aug 2024 21:44:30 +0000 Subject: [PATCH 7/8] 8337667: sun/tools/jcmd/TestJcmdPIDSubstitution.java is failing on mac and windows Reviewed-by: stuefe, kevinw --- test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java b/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java index f462ea1a52b..4af5bf1ff67 100644 --- a/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java @@ -40,6 +40,8 @@ import java.nio.file.Path; import java.nio.file.Paths; +import jdk.test.lib.Platform; + public class TestJcmdPIDSubstitution { private static final String FILENAME = "myfile%p"; @@ -47,8 +49,10 @@ public class TestJcmdPIDSubstitution { public static void main(String[] args) throws Exception { verifyOutputFilenames("Thread.dump_to_file", FILENAME); verifyOutputFilenames("GC.heap_dump", FILENAME); - verifyOutputFilenames("Compiler.perfmap", FILENAME); - verifyOutputFilenames("System.dump_map", "-F=%s".formatted(FILENAME)); + if (Platform.isLinux()) { + verifyOutputFilenames("Compiler.perfmap", FILENAME); + verifyOutputFilenames("System.dump_map", "-F=%s".formatted(FILENAME)); + } } private static void verifyOutputFilenames(String... args) throws Exception { From 8afcac96f8bc7b6ea130e9bbc6222823a2081c39 Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Tue, 6 Aug 2024 21:56:48 +0000 Subject: [PATCH 8/8] 8311990: Two JDI tests may interfere with each other Reviewed-by: dholmes, sspitsyn --- test/jdk/com/sun/jdi/JdwpListenTest.java | 5 +++-- test/jdk/com/sun/jdi/JdwpNetProps.java | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/jdk/com/sun/jdi/JdwpListenTest.java b/test/jdk/com/sun/jdi/JdwpListenTest.java index a55eefb5868..53f5b404de5 100644 --- a/test/jdk/com/sun/jdi/JdwpListenTest.java +++ b/test/jdk/com/sun/jdi/JdwpListenTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public class JdwpListenTest { // Set to true to allow testing of attach from wrong address (expected to fail). // It's off by default as it causes test time increase and test interference (see JDK-8231915). - private static boolean allowNegativeTesting = false; + private static boolean allowNegativeTesting = + "true".equalsIgnoreCase(System.getProperty("jdk.jdi.allowNegativeTesting")); public static void main(String[] args) throws Exception { List addresses = Utils.getAddressesWithSymbolicAndNumericScopes(); diff --git a/test/jdk/com/sun/jdi/JdwpNetProps.java b/test/jdk/com/sun/jdi/JdwpNetProps.java index af69c9ca3ad..0247e4551a3 100644 --- a/test/jdk/com/sun/jdi/JdwpNetProps.java +++ b/test/jdk/com/sun/jdi/JdwpNetProps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,11 @@ */ public class JdwpNetProps { + // Set to true to allow testing of attach from wrong address (expected to fail). + // It's off by default as it causes test interference (see JDK-8311990). + private static boolean allowNegativeAttachTesting = + "true".equalsIgnoreCase(System.getProperty("jdk.jdi.allowNegativeTesting")); + public static void main(String[] args) throws Exception { InetAddress addrs[] = InetAddress.getAllByName("localhost"); InetAddress ipv4Address = null; @@ -171,6 +176,14 @@ public ListenTest preferIPv6Addresses(String value) { } public void run(TestResult expectedResult) throws Exception { + log("\nTest: listen at " + listenAddress + ", attaching to " + connectAddress + + ", preferIPv4Stack = " + preferIPv4Stack + + ", preferIPv6Addresses = " + preferIPv6Addresses + + ", expectedResult = " + expectedResult); + if (expectedResult == TestResult.AttachFailed && !allowNegativeAttachTesting) { + log("SKIPPED: negative attach testing is disabled"); + return; + } List options = new LinkedList<>(); if (preferIPv4Stack != null) { options.add("-Djava.net.preferIPv4Stack=" + preferIPv4Stack.toString());