From 323e574a50520735f41549f36907563e1b4a1040 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 15 Dec 2022 11:28:06 +0000 Subject: [PATCH 01/10] 8298371: monitors_on_stack extracts unprocessed oops Backport-of: b754aa5e3f231aea8da5274c330dc55dd78b0f67 --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 645b6619cc8..ef4bacbbb98 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -1461,7 +1461,7 @@ static bool monitors_on_stack(JavaThread* thread) { ContinuationEntry* ce = thread->last_continuation(); RegisterMap map(thread, RegisterMap::UpdateMap::include, - RegisterMap::ProcessFrames::skip, + RegisterMap::ProcessFrames::include, RegisterMap::WalkContinuation::skip); map.set_include_argument_oops(false); for (frame f = thread->last_frame(); Continuation::is_frame_in_continuation(ce, f); f = f.sender(&map)) { From 22a6b5910290cb8a3876f94213ba60db86e60718 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 15 Dec 2022 11:33:56 +0000 Subject: [PATCH 02/10] 8298727: Trees.getPath may crash for unnamed package Reviewed-by: vromero --- .../com/sun/tools/javac/comp/Enter.java | 4 +- .../processing/model/EmptyPackageInfo.java | 134 ++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 test/langtools/tools/javac/processing/model/EmptyPackageInfo.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java index 7c134aa891e..01245b24af7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java @@ -356,10 +356,12 @@ public class Enter extends JCTree.Visitor { tree.packge.complete(); // Find all classes in package. Env topEnv = topLevelEnv(tree); - Env packageEnv = isPkgInfo ? topEnv.dup(pd) : null; + Env packageEnv = null; // Save environment of package-info.java file. if (isPkgInfo) { + packageEnv = topEnv.dup(pd != null ? pd : tree); + Env env0 = typeEnvs.get(tree.packge); if (env0 != null) { JCCompilationUnit tree0 = env0.toplevel; diff --git a/test/langtools/tools/javac/processing/model/EmptyPackageInfo.java b/test/langtools/tools/javac/processing/model/EmptyPackageInfo.java new file mode 100644 index 00000000000..4acf1e3abac --- /dev/null +++ b/test/langtools/tools/javac/processing/model/EmptyPackageInfo.java @@ -0,0 +1,134 @@ +/* + * 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 8298727 + * @summary Verify empty package-info.java is handled properly + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.TestRunner toolbox.ToolBox EmptyPackageInfo + * @run main EmptyPackageInfo + */ + +import com.sun.source.tree.Tree; +import com.sun.source.util.JavacTask; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import com.sun.source.util.Trees; +import java.util.ArrayList; +import java.util.List; +import javax.tools.ToolProvider; +import toolbox.TestRunner; +import toolbox.TestRunner.Test; +import toolbox.ToolBox; + +public class EmptyPackageInfo extends TestRunner { + + public static void main(String... args) throws Exception { + new EmptyPackageInfo().runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + private final ToolBox tb = new ToolBox(); + + public EmptyPackageInfo() { + super(System.err); + } + + @Test + public void testEmptyPackageInfo(Path outerBase) throws Exception { + Path src = outerBase.resolve("src"); + Path classes = outerBase.resolve("classes"); + Path packInfo = src.resolve("package-info.java"); + + tb.writeFile(packInfo, "/**javadoc*/\n"); + Files.createDirectories(classes); + + var compiler = ToolProvider.getSystemJavaCompiler(); + + try (var fm = compiler.getStandardFileManager(null, + null, + null)) { + var task = + (JavacTask) compiler.getTask(null, + fm, + null, + null, + null, + fm.getJavaFileObjects(packInfo)); + task.analyze(); + var pack = task.getElements().getPackageElement(""); + var trees = Trees.instance(task); + var packPath = trees.getPath(pack); + var packTree = packPath.getLeaf(); + if (packTree.getKind() != Tree.Kind.COMPILATION_UNIT) { + throw new AssertionError("Unexpected tree kind: " + packTree.getKind()); + } + var actualJavadoc = trees.getDocComment(packPath); + var expectedJavadoc = "javadoc"; + if (!expectedJavadoc.equals(actualJavadoc)) { + throw new AssertionError("Unexpected javadoc, " + + "expected: " + expectedJavadoc + + ", got: " + actualJavadoc); + } + } + } + + @Test + public void testMultipleFiles(Path outerBase) throws Exception { + Path src = outerBase.resolve("src"); + Path classes = outerBase.resolve("classes"); + Path packInfo1 = src.resolve("test1").resolve("package-info.java"); + Path packInfo2 = src.resolve("test2").resolve("package-info.java"); + + tb.writeFile(packInfo1, ""); + tb.writeFile(packInfo2, ""); + Files.createDirectories(classes); + + var compiler = ToolProvider.getSystemJavaCompiler(); + + try (var fm = compiler.getStandardFileManager(null, + null, + null)) { + var diags = new ArrayList(); + var task = + (JavacTask) compiler.getTask(null, + fm, + d -> diags.add(d.getCode()), + null, + null, + fm.getJavaFileObjects(packInfo1, + packInfo2)); + task.analyze(); + var expectedDiags = + List.of("compiler.warn.pkg-info.already.seen"); + if (!expectedDiags.equals(diags)) { + throw new AssertionError("Unexpected diags, " + + "expected: " + expectedDiags + + ", got: " + diags); + } + } + } +} From 48f6127325108e573b41d19213e65af99956a31f Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 15 Dec 2022 11:44:21 +0000 Subject: [PATCH 03/10] 8298376: ZGC: thaws stackChunk with stale oops Backport-of: ed8a2120ca1e9756c6ab5eeebfe24c15d549f04e --- src/hotspot/share/oops/stackChunkOop.hpp | 2 ++ src/hotspot/share/oops/stackChunkOop.inline.hpp | 13 ++++++++++++- .../share/runtime/continuationJavaClasses.hpp | 3 ++- .../runtime/continuationJavaClasses.inline.hpp | 5 +++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/oops/stackChunkOop.hpp b/src/hotspot/share/oops/stackChunkOop.hpp index f6ce1ecc500..c1c0aee8f24 100644 --- a/src/hotspot/share/oops/stackChunkOop.hpp +++ b/src/hotspot/share/oops/stackChunkOop.hpp @@ -91,6 +91,8 @@ public: inline int max_thawing_size() const; inline void set_max_thawing_size(int value); + inline oop cont() const; + template inline oop cont() const; inline void set_cont(oop value); template diff --git a/src/hotspot/share/oops/stackChunkOop.inline.hpp b/src/hotspot/share/oops/stackChunkOop.inline.hpp index 5de21075666..41ce22a7c34 100644 --- a/src/hotspot/share/oops/stackChunkOop.inline.hpp +++ b/src/hotspot/share/oops/stackChunkOop.inline.hpp @@ -86,7 +86,18 @@ inline void stackChunkOopDesc::set_max_thawing_size(int value) { jdk_internal_vm_StackChunk::set_maxThawingSize(this, (jint)value); } -inline oop stackChunkOopDesc::cont() const { return jdk_internal_vm_StackChunk::cont(as_oop()); } +inline oop stackChunkOopDesc::cont() const { return UseCompressedOops ? cont() : cont(); /* jdk_internal_vm_StackChunk::cont(as_oop()); */ } +template +inline oop stackChunkOopDesc::cont() const { + // The state of the cont oop is used by ZCollectedHeap::requires_barriers, + // to determine the age of the stackChunkOopDesc. For that to work, it is + // only the GC that is allowed to perform a load barrier on the oop. + // This function is used by non-GC code and therfore create a stack-local + // copy on the oop and perform the load barrier on that copy instead. + oop obj = jdk_internal_vm_StackChunk::cont_raw

(as_oop()); + obj = (oop)NativeAccess<>::oop_load(&obj); + return obj; +} inline void stackChunkOopDesc::set_cont(oop value) { jdk_internal_vm_StackChunk::set_cont(this, value); } template inline void stackChunkOopDesc::set_cont_raw(oop value) { jdk_internal_vm_StackChunk::set_cont_raw

(this, value); } diff --git a/src/hotspot/share/runtime/continuationJavaClasses.hpp b/src/hotspot/share/runtime/continuationJavaClasses.hpp index 2186dbe3535..d8634161a4b 100644 --- a/src/hotspot/share/runtime/continuationJavaClasses.hpp +++ b/src/hotspot/share/runtime/continuationJavaClasses.hpp @@ -124,7 +124,8 @@ class jdk_internal_vm_StackChunk: AllStatic { static inline void set_maxThawingSize(oop chunk, int value); // cont oop's processing is essential for the chunk's GC protocol - static inline oop cont(oop chunk); + template + static inline oop cont_raw(oop chunk); static inline void set_cont(oop chunk, oop value); template static inline void set_cont_raw(oop chunk, oop value); diff --git a/src/hotspot/share/runtime/continuationJavaClasses.inline.hpp b/src/hotspot/share/runtime/continuationJavaClasses.inline.hpp index 1d0ff75225a..5bba4016033 100644 --- a/src/hotspot/share/runtime/continuationJavaClasses.inline.hpp +++ b/src/hotspot/share/runtime/continuationJavaClasses.inline.hpp @@ -81,8 +81,9 @@ inline void jdk_internal_vm_StackChunk::set_parent_access(oop chunk, oop value) chunk->obj_field_put_access(_parent_offset, value); } -inline oop jdk_internal_vm_StackChunk::cont(oop chunk) { - return chunk->obj_field(_cont_offset); +template +inline oop jdk_internal_vm_StackChunk::cont_raw(oop chunk) { + return (oop)RawAccess<>::oop_load(chunk->field_addr

(_cont_offset)); } inline void jdk_internal_vm_StackChunk::set_cont(oop chunk, oop value) { From 2c42499266377a32aa0ff96a0241d76d7517cf2e Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Thu, 15 Dec 2022 15:46:05 +0000 Subject: [PATCH 04/10] 8298050: Add links to graph output for javadoc Reviewed-by: darcy --- .../build/tools/taglet/SealedGraph.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/make/jdk/src/classes/build/tools/taglet/SealedGraph.java b/make/jdk/src/classes/build/tools/taglet/SealedGraph.java index da79c17b387..df719d6fce6 100644 --- a/make/jdk/src/classes/build/tools/taglet/SealedGraph.java +++ b/make/jdk/src/classes/build/tools/taglet/SealedGraph.java @@ -40,6 +40,7 @@ import java.util.stream.Collectors; import static java.lang.System.lineSeparator; import static java.nio.file.StandardOpenOption.*; +import static java.util.stream.Collectors.joining; import static jdk.javadoc.doclet.Taglet.Location.TYPE; /** @@ -98,7 +99,7 @@ public final class SealedGraph implements Taglet { .map(Objects::toString) .collect(Collectors.toUnmodifiableSet()); - String dotContent = Renderer.graph(typeElement, exports); + String dotContent = new Renderer().graph(typeElement, exports); try { Files.writeString(dotFile, dotContent, WRITE, CREATE, TRUNCATE_EXISTING); @@ -133,13 +134,10 @@ public final class SealedGraph implements Taglet { (height <= 0 ? "" : " height=\"" + height + "\"")); } - private static final class Renderer { - - private Renderer() { - } + private final class Renderer { // Generates a graph in DOT format - static String graph(TypeElement rootClass, Set exports) { + String graph(TypeElement rootClass, Set exports) { final State state = new State(rootClass); traverse(state, rootClass, exports); return state.render(); @@ -155,17 +153,21 @@ public final class SealedGraph implements Taglet { } } - private static final class State { + private final class State { private static final String LABEL = "label"; private static final String TOOLTIP = "tooltip"; + private static final String LINK = "href"; private static final String STYLE = "style"; + private final TypeElement rootNode; + private final StringBuilder builder; private final Map> nodeStyleMap; public State(TypeElement rootNode) { + this.rootNode = rootNode; nodeStyleMap = new LinkedHashMap<>(); builder = new StringBuilder() .append("digraph G {") @@ -188,12 +190,30 @@ public final class SealedGraph implements Taglet { var styles = nodeStyleMap.computeIfAbsent(id(node), n -> new LinkedHashMap<>()); styles.put(LABEL, node.getSimpleName().toString()); styles.put(TOOLTIP, node.getQualifiedName().toString()); + styles.put(LINK, relativeLink(node)); if (!(node.getModifiers().contains(Modifier.SEALED) || node.getModifiers().contains(Modifier.FINAL))) { // This indicates that the hierarchy is not closed styles.put(STYLE, "dashed"); } } + // A permitted class must be in the same package or in the same module. + // This implies the module is always the same. + private String relativeLink(TypeElement node) { + var util = SealedGraph.this.docletEnvironment.getElementUtils(); + var rootPackage = util.getPackageOf(rootNode); + var nodePackage = util.getPackageOf(node); + var backNavigator = rootPackage.getQualifiedName().toString().chars() + .filter(c -> c == '.') + .mapToObj(c -> "../") + .collect(joining()) + + "../"; + var forwardNavigator = nodePackage.getQualifiedName().toString() + .replace(".", "/"); + + return backNavigator + forwardNavigator + "/" + node.getSimpleName() + ".html"; + } + public void addEdge(TypeElement node, TypeElement subNode) { builder.append(" ") .append(quotedId(subNode)) @@ -209,8 +229,8 @@ public final class SealedGraph implements Taglet { .append('"').append(nodeName).append("\" ") .append(styles.entrySet().stream() .map(e -> e.getKey() + "=\"" + e.getValue() + "\"") - .collect(Collectors.joining(" ", "[", "]"))) - .append(System.lineSeparator()); + .collect(joining(" ", "[", "]"))) + .append(lineSeparator()); }); builder.append("}"); return builder.toString(); From ca39eb906692568347e7f264520593188f9276cf Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 15 Dec 2022 17:27:08 +0000 Subject: [PATCH 05/10] 7093322: (fs spec) Files.newBufferedWriter should be clear when coding errors are detected Reviewed-by: alanb --- src/java.base/share/classes/java/nio/file/Files.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/nio/file/Files.java b/src/java.base/share/classes/java/nio/file/Files.java index 601dd99d461..682340614a6 100644 --- a/src/java.base/share/classes/java/nio/file/Files.java +++ b/src/java.base/share/classes/java/nio/file/Files.java @@ -2938,7 +2938,12 @@ public final class Files { * a size of {@code 0} if it exists. * *

The {@code Writer} methods to write text throw {@code IOException} - * if the text cannot be encoded using the specified charset. + * if the text cannot be encoded using the specified charset. Due to + * buffering, an {@code IOException} caused by an encoding error + * (unmappable-character or malformed-input) may be thrown when {@linkplain + * BufferedWriter#write(char[],int,int) writing}, {@linkplain + * BufferedWriter#flush flushing}, or {@linkplain BufferedWriter#close + * closing} the buffered writer. * * @param path * the path to the file From c7d7e7e3be768b35447d65661ec328204aeb40e4 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Fri, 16 Dec 2022 00:01:08 +0000 Subject: [PATCH 06/10] 8298888: ProblemList gc/g1/TestVerifyGCType.java on linux and macosx 8298889: ProblemList runtime/StackGuardPages/TestStackGuardPages.java on linux 8298891: ProblemList vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java with ZGC 8298892: ProblemList vmTestbase/nsk/sysdict/vm/stress/chain/chain008/chain008.java with ZGC Reviewed-by: bpb, lmesnik --- test/hotspot/jtreg/ProblemList-zgc.txt | 2 ++ test/hotspot/jtreg/ProblemList.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 887eb36e0d4..5735d6c51fe 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -86,3 +86,5 @@ vmTestbase/nsk/monitoring/stress/lowmem/lowmem036/TestDescription.java 8297979 g vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter001/TestDescription.java 8298059 generic-x64 vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter004/TestDescription.java 8298059 generic-x64 +vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java 8298302 generic-all +vmTestbase/nsk/sysdict/vm/stress/chain/chain008/chain008.java 8298596 linux-x64 diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 66121e1dcb1..39f5c2ee63f 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -80,6 +80,7 @@ gc/stress/gclocker/TestGCLockerWithG1.java 8180622 generic-all gc/stress/TestJNIBlockFullGC/TestJNIBlockFullGC.java 8192647 generic-all gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8241293,8298073 macosx-x64,macosx-aarch64 gc/stress/TestStressG1Humongous.java 8286554 windows-x64 +gc/g1/TestVerifyGCType.java 8298215 linux-all,macosx-all ############################################################################# @@ -97,6 +98,7 @@ runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64 runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64 runtime/vthread/RedefineClass.java 8297286 generic-all runtime/vthread/TestObjectAllocationSampleEvent.java 8297286 generic-all +runtime/StackGuardPages/TestStackGuardPages.java 8293452 linux-all applications/jcstress/copy.java 8229852 linux-all From 03a694afda81f575f8a24e655d53b2b029e3d968 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 16 Dec 2022 06:33:08 +0000 Subject: [PATCH 07/10] 8298083: The "CheckBox/RadioButton[Enabled/Disabled].textForeground" stoped working Reviewed-by: prr Backport-of: 5540a8c5b7160ab5c67bb84631e3de54fa5aeceb --- .../com/sun/java/swing/plaf/gtk/GTKStyle.java | 14 +------ .../javax/swing/plaf/synth/SynthStyle.java | 10 +---- test/jdk/ProblemList.txt | 1 + .../JRadioButton/4314194/bug4314194.java | 40 +++++++++++++------ 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index f645add8f45..9f1b468007f 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -286,18 +286,6 @@ class GTKStyle extends SynthStyle implements GTKConstants { } } } - - if ((c instanceof JCheckBox) && (state & SynthConstants.DISABLED) != 0) { - if (UIManager.getColor("CheckBox.disabledText") != null) { - return UIManager.getColor("CheckBox.disabledText"); - } - } else if ((c instanceof JRadioButton) && - (state & SynthConstants.DISABLED) != 0) { - if (UIManager.getColor("RadioButton.disabledText") != null) { - return UIManager.getColor("RadioButton.disabledText"); - } - } - return getColorForState(context, type); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java index e648fbf108e..f25b25166bc 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -779,14 +779,6 @@ public abstract class SynthStyle { (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND)) { return getColorForState(context, type); - } else if (c instanceof JCheckBox) { - if (UIManager.getColor("CheckBox.disabledText") != null) { - return UIManager.getColor("CheckBox.disabledText"); - } - } else if (c instanceof JRadioButton) { - if (UIManager.getColor("RadioButton.disabledText") != null) { - return UIManager.getColor("RadioButton.disabledText"); - } } } diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 4e00b2c1482..17bad35da71 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -662,6 +662,7 @@ javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-all javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all +javax/swing/JRadioButton/4314194/bug4314194.java 8298153 linux-all # Several tests which fail on some hidpi systems/macosx12-aarch64 system java/awt/Window/8159168/SetShapeTest.java 8274106 macosx-aarch64 diff --git a/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java b/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java index e783b147ca6..57ee1a2bb3f 100644 --- a/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java +++ b/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java @@ -23,7 +23,7 @@ /* * @test * @key headful - * @bug 4314194 8075916 + * @bug 4314194 8075916 8298083 * @summary Verifies disabled color for JCheckbox and JRadiobutton is honored in all L&F * @run main bug4314194 */ @@ -40,13 +40,14 @@ import javax.swing.JRadioButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.synth.SynthLookAndFeel; public class bug4314194 { - private static JFrame frame; - private static JRadioButton radioButton; - private static JCheckBox checkBox; - private static Point point; - private static Rectangle rect; + private static volatile JFrame frame; + private static volatile JRadioButton radioButton; + private static volatile JCheckBox checkBox; + private static volatile Point point; + private static volatile Rectangle rect; private static Robot robot; private static final Color radioButtonColor = Color.RED; private static final Color checkboxColor = Color.GREEN; @@ -87,9 +88,25 @@ public class bug4314194 { } } - private static void createUI() { - UIManager.getDefaults().put("CheckBox.disabledText", checkboxColor); - UIManager.getDefaults().put("RadioButton.disabledText", radioButtonColor); + private static void createUI(String laf) { + if (UIManager.getLookAndFeel() instanceof SynthLookAndFeel) { + // reset "basic" properties + UIManager.getDefaults().put("CheckBox.disabledText", null); + UIManager.getDefaults().put("RadioButton.disabledText", null); + // set "synth" properties + UIManager.getDefaults().put("CheckBox[Disabled].textForeground", checkboxColor); + // for some reason the RadioButton[Disabled] does not work + // see https://bugs.openjdk.org/browse/JDK-8298149 + //UIManager.getDefaults().put("RadioButton[Disabled].textForeground", radioButtonColor); + UIManager.getDefaults().put("RadioButton[Enabled].textForeground", radioButtonColor); + } else { + // reset "synth" properties + UIManager.getDefaults().put("CheckBox[Disabled].textForeground", null); + UIManager.getDefaults().put("RadioButton[Enabled].textForeground", null); + // set "basic" properties + UIManager.getDefaults().put("CheckBox.disabledText", checkboxColor); + UIManager.getDefaults().put("RadioButton.disabledText", radioButtonColor); + } checkBox = new JCheckBox("\u2588".repeat(5)); radioButton = new JRadioButton("\u2588".repeat(5)); @@ -98,7 +115,7 @@ public class bug4314194 { checkBox.setEnabled(false); radioButton.setEnabled(false); - frame = new JFrame("bug4314194"); + frame = new JFrame(laf); frame.getContentPane().add(radioButton, BorderLayout.SOUTH); frame.getContentPane().add(checkBox, BorderLayout.NORTH); frame.pack(); @@ -122,7 +139,7 @@ public class bug4314194 { System.out.println("Testing L&F: " + laf.getClassName()); SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); try { - SwingUtilities.invokeAndWait(() -> createUI()); + SwingUtilities.invokeAndWait(() -> createUI(laf.getName())); robot.waitForIdle(); robot.delay(1000); @@ -141,4 +158,3 @@ public class bug4314194 { } } } - From c47e64e4f3be80f434dd4dea9b6e8d282b2c2b32 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Fri, 16 Dec 2022 08:06:09 +0000 Subject: [PATCH 08/10] 8297979: ZGC: Ensure consistent MemoryUsage from MemoryMXBean.getHeapMemoryUsage() Reviewed-by: stefank, ayang --- src/hotspot/share/gc/z/zCollectedHeap.cpp | 4 +++ src/hotspot/share/gc/z/zCollectedHeap.hpp | 2 ++ test/hotspot/jtreg/ProblemList-zgc.txt | 37 ----------------------- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/src/hotspot/share/gc/z/zCollectedHeap.cpp b/src/hotspot/share/gc/z/zCollectedHeap.cpp index 0d333626ea0..5abc6ccf580 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.cpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp @@ -224,6 +224,10 @@ bool ZCollectedHeap::uses_stack_watermark_barrier() const { return true; } +MemoryUsage ZCollectedHeap::memory_usage() { + return _heap.serviceability_memory_pool()->get_memory_usage(); +} + GrowableArray ZCollectedHeap::memory_managers() { GrowableArray memory_managers(2); memory_managers.append(_heap.serviceability_cycle_memory_manager()); diff --git a/src/hotspot/share/gc/z/zCollectedHeap.hpp b/src/hotspot/share/gc/z/zCollectedHeap.hpp index d1d14576e0b..37f41282c94 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.hpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.hpp @@ -31,6 +31,7 @@ #include "gc/z/zInitialize.hpp" #include "gc/z/zRuntimeWorkers.hpp" #include "memory/metaspace.hpp" +#include "services/memoryUsage.hpp" class ZDirector; class ZDriver; @@ -90,6 +91,7 @@ public: virtual bool uses_stack_watermark_barrier() const; + virtual MemoryUsage memory_usage(); virtual GrowableArray memory_managers(); virtual GrowableArray memory_pools(); diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 5735d6c51fe..815ed5bed84 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -47,43 +47,6 @@ serviceability/sa/ClhsdbPstack.java#core 8248912 generic- vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 -vmTestbase/nsk/monitoring/stress/lowmem/lowmem001/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem002/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem003/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem004/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem005/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem006/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem007/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem008/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem009/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem010/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem011/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem012/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem013/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem014/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem015/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem016/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem017/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem018/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem019/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem020/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem021/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem022/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem023/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem024/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem025/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem026/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem027/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem028/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem029/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem030/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem031/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem032/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem033/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem034/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem035/TestDescription.java 8297979 generic-all -vmTestbase/nsk/monitoring/stress/lowmem/lowmem036/TestDescription.java 8297979 generic-all - vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter001/TestDescription.java 8298059 generic-x64 vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter004/TestDescription.java 8298059 generic-x64 vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java 8298302 generic-all From 0ba473489151d74c8a15b75ff4964ac480fecb28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Fri, 16 Dec 2022 10:46:37 +0000 Subject: [PATCH 09/10] 8287699: jdk/jfr/api/consumer/TestRecordingFileWrite.java fails with exception: java.lang.Exception: Found event that should not be there. Reviewed-by: egahlin --- src/hotspot/share/jfr/support/jfrThreadLocal.cpp | 3 +++ test/jdk/ProblemList.txt | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp index 19bbe25798c..ff4d255fc98 100644 --- a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp +++ b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp @@ -208,6 +208,9 @@ void JfrThreadLocal::on_exit(Thread* t) { assert(t != NULL, "invariant"); JfrThreadLocal * const tl = t->jfr_thread_local(); assert(!tl->is_dead(), "invariant"); + if (JfrRecorder::is_recording()) { + JfrCheckpointManager::write_checkpoint(t); + } if (t->is_Java_thread()) { JavaThread* const jt = JavaThread::cast(t); send_java_thread_end_event(jt, JfrThreadLocal::jvm_thread_id(jt)); diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 17bad35da71..977c7da4b28 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -755,7 +755,6 @@ jdk/jfr/startupargs/TestStartName.java 8214685 windows- 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 -jdk/jfr/api/consumer/TestRecordingFileWrite.java 8287699 generic-all ############################################################################ From f771c56e16a39724712ca0d8c2dd55b9ce260f4d Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 16 Dec 2022 10:49:22 +0000 Subject: [PATCH 10/10] 8298797: Specification of some restricted methods is incorrect Reviewed-by: jvernee, pminborg --- .../share/classes/java/lang/foreign/Linker.java | 4 +--- .../java/lang/foreign/MemorySegment.java | 17 +++++++---------- .../classes/java/lang/foreign/SymbolLookup.java | 8 ++------ .../share/classes/java/lang/foreign/VaList.java | 4 +--- .../classes/java/lang/foreign/ValueLayout.java | 1 + .../handle/lookup/MethodHandleLookup.java | 8 +++++++- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/java.base/share/classes/java/lang/foreign/Linker.java b/src/java.base/share/classes/java/lang/foreign/Linker.java index 4789292de03..6e83806a038 100644 --- a/src/java.base/share/classes/java/lang/foreign/Linker.java +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java @@ -180,9 +180,7 @@ public sealed interface Linker permits AbstractLinker { * * @return a linker for the ABI associated with the OS and processor where the Java runtime is currently executing. * @throws UnsupportedOperationException if the underlying native platform is not supported. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is specified, but does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static Linker nativeLinker() { diff --git a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java index 76c2de64242..a1da55b8c0e 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java +++ b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java @@ -1065,9 +1065,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * @param byteSize the size (in bytes) of the returned native segment. * @return a zero-length native segment with the given address and size. * @throws IllegalArgumentException if {@code byteSize < 0}. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is specified, but does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static MemorySegment ofAddress(long address, long byteSize) { @@ -1088,7 +1086,10 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * {@snippet lang = java: * ofAddress(address, byteSize, scope, null); *} - * + * This method is restricted. + * Restricted methods are unsafe, and, if used incorrectly, their use might crash + * the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on + * restricted methods, and use safe and supported functionalities, where possible. * @param address the returned segment's address. * @param byteSize the desired size. * @param scope the scope associated with the returned native segment. @@ -1097,9 +1098,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * @throws IllegalStateException if {@code scope} is not {@linkplain SegmentScope#isAlive() alive}. * @throws WrongThreadException if this method is called from a thread {@code T}, * such that {@code scope.isAccessibleBy(T) == false}. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is specified, but does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive @ForceInline @@ -1140,9 +1139,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * @throws IllegalStateException if {@code scope} is not {@linkplain SegmentScope#isAlive() alive}. * @throws WrongThreadException if this method is called from a thread {@code T}, * such that {@code scope.isAccessibleBy(T) == false}. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is specified, but does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static MemorySegment ofAddress(long address, long byteSize, SegmentScope scope, Runnable cleanupAction) { diff --git a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java index 50575f6b106..b2c5711922a 100644 --- a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java +++ b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java @@ -189,9 +189,7 @@ public interface SymbolLookup { * @param scope the scope associated with symbols obtained from the returned lookup. * @return a new symbol lookup suitable to find symbols in a library with the given name. * @throws IllegalArgumentException if {@code name} does not identify a valid library. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is either absent, or does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static SymbolLookup libraryLookup(String name, SegmentScope scope) { @@ -215,9 +213,7 @@ public interface SymbolLookup { * @param scope the scope associated with symbols obtained from the returned lookup. * @return a new symbol lookup suitable to find symbols in a library with the given path. * @throws IllegalArgumentException if {@code path} does not point to a valid library. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is either absent, or does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static SymbolLookup libraryLookup(Path path, SegmentScope scope) { diff --git a/src/java.base/share/classes/java/lang/foreign/VaList.java b/src/java.base/share/classes/java/lang/foreign/VaList.java index 0f6dd9fef47..4d8fab97575 100644 --- a/src/java.base/share/classes/java/lang/foreign/VaList.java +++ b/src/java.base/share/classes/java/lang/foreign/VaList.java @@ -247,9 +247,7 @@ public sealed interface VaList permits WinVaList, SysVVaList, LinuxAArch64VaList * @throws WrongThreadException if this method is called from a thread {@code T}, * such that {@code scope.isAccessibleBy(T) == false}. * @throws UnsupportedOperationException if the underlying native platform is not supported. - * @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option - * {@code --enable-native-access} is specified, but does not mention the module name {@code M}, or - * {@code ALL-UNNAMED} in case {@code M} is an unnamed module. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. */ @CallerSensitive static VaList ofAddress(long address, SegmentScope scope) { diff --git a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java index f9a62419598..9ff1f08d7b9 100644 --- a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java +++ b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java @@ -424,6 +424,7 @@ public sealed interface ValueLayout extends MemoryLayout { * restricted methods, and use safe and supported functionalities, where possible. * * @return an unbounded address layout with same characteristics as this layout. + * @throws IllegalCallerException If the caller is in a module that does not have native access enabled. * @see #isUnbounded() */ @CallerSensitive diff --git a/test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java b/test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java index 6bd7121c651..62014baf8af 100644 --- a/test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java +++ b/test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java @@ -50,9 +50,15 @@ public class MethodHandleLookup { return new Object[][]{ { MethodHandles.lookup().findStatic(Linker.class, "nativeLinker", MethodType.methodType(Linker.class)), "Linker::nativeLinker" }, + { MethodHandles.lookup().findStatic(MemorySegment.class, "ofAddress", + MethodType.methodType(MemorySegment.class, long.class, long.class)), + "MemorySegment::ofAddress/2" }, { MethodHandles.lookup().findStatic(MemorySegment.class, "ofAddress", MethodType.methodType(MemorySegment.class, long.class, long.class, SegmentScope.class)), - "MemorySegment::ofAddressNative" }, + "MemorySegment::ofAddress/3" }, + { MethodHandles.lookup().findStatic(MemorySegment.class, "ofAddress", + MethodType.methodType(MemorySegment.class, long.class, long.class, SegmentScope.class, Runnable.class)), + "MemorySegment::ofAddress/4" }, { MethodHandles.lookup().findStatic(SymbolLookup.class, "libraryLookup", MethodType.methodType(SymbolLookup.class, String.class, SegmentScope.class)), "SymbolLookup::libraryLookup(String)" },