From 8b076172a523ee9e845ee9d8b36e7d430206448c Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Fri, 10 Jan 2025 07:59:26 +0000 Subject: [PATCH 001/263] 8347345: Remove redundant test policy file from ModelMBeanInfoSupport directory Reviewed-by: rriggs, sspitsyn --- .../modelmbean/ModelMBeanInfoSupport/policy | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 test/jdk/javax/management/modelmbean/ModelMBeanInfoSupport/policy diff --git a/test/jdk/javax/management/modelmbean/ModelMBeanInfoSupport/policy b/test/jdk/javax/management/modelmbean/ModelMBeanInfoSupport/policy deleted file mode 100644 index ac5336ce882d9..0000000000000 --- a/test/jdk/javax/management/modelmbean/ModelMBeanInfoSupport/policy +++ /dev/null @@ -1,14 +0,0 @@ -grant { - permission javax.management.MBeanServerPermission "createMBeanServer"; - permission javax.management.MBeanPermission "javax.management.modelmbean.RequiredModelMBean#-[-]", "instantiate"; - permission javax.management.MBeanPermission "javax.management.modelmbean.RequiredModelMBean#-[*:*]", "registerMBean"; - permission javax.management.MBeanPermission "javax.management.modelmbean.RequiredModelMBean#*[*:*]", "getAttribute"; - permission javax.management.MBeanPermission "javax.management.modelmbean.RequiredModelMBean#*[*:*]", "setAttribute"; - permission javax.management.MBeanPermission "javax.management.modelmbean.RequiredModelMBean#*[*:*]", "invoke"; - permission javax.management.MBeanPermission "GetAllDescriptorsTest$Resource#-[*:*]", "registerMBean"; - permission javax.management.MBeanPermission "GetAllDescriptorsTest$Resource#*[*:*]", "invoke"; - permission javax.management.MBeanPermission "GetAllDescriptorsTest$Resource#*[*:*]", "getAttribute"; - permission javax.management.MBeanPermission "GetAllDescriptorsTest$Resource#*[*:*]", "setAttribute"; - permission javax.management.MBeanPermission "GetAllDescriptorsTest$Resource#*[*:*]", "getMBeanInfo"; - -}; From 1a0fe49732187db9e8776f80feefab4373114f75 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 10 Jan 2025 08:42:42 +0000 Subject: [PATCH 002/263] 8347256: Epsilon: Demote heap size and AlwaysPreTouch warnings to info level Reviewed-by: tschatzl, phh --- .../share/gc/epsilon/epsilonInitLogger.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp b/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp index a75e9e7679da7..bc35eddeba5c6 100644 --- a/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp @@ -32,18 +32,6 @@ #include "utilities/globalDefinitions.hpp" void EpsilonInitLogger::print_gc_specific() { - // Warn users that non-resizable heap might be better for some configurations. - // We are not adjusting the heap size by ourselves, because it affects startup time. - if (InitialHeapSize != MaxHeapSize) { - log_warning(gc, init)("Consider setting -Xms equal to -Xmx to avoid resizing hiccups"); - } - - // Warn users that AlwaysPreTouch might be better for some configurations. - // We are not turning this on by ourselves, because it affects startup time. - if (FLAG_IS_DEFAULT(AlwaysPreTouch) && !AlwaysPreTouch) { - log_warning(gc, init)("Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups"); - } - if (UseTLAB) { size_t max_tlab = EpsilonHeap::heap()->max_tlab_size() * HeapWordSize; log_info(gc, init)("TLAB Size Max: " SIZE_FORMAT "%s", @@ -57,6 +45,18 @@ void EpsilonInitLogger::print_gc_specific() { } else { log_info(gc, init)("TLAB: Disabled"); } + + // Suggest that non-resizable heap might be better for some configurations. + // We are not adjusting the heap size by ourselves, because it affects startup time. + if (InitialHeapSize != MaxHeapSize) { + log_info(gc)("Consider setting -Xms equal to -Xmx to avoid resizing hiccups"); + } + + // Suggest that AlwaysPreTouch might be better for some configurations. + // We are not turning this on by ourselves, because it affects startup time. + if (FLAG_IS_DEFAULT(AlwaysPreTouch) && !AlwaysPreTouch) { + log_info(gc)("Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups"); + } } void EpsilonInitLogger::print() { From 55c6904e8f3d02530749bf28f2cc966e8983a984 Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Fri, 10 Jan 2025 08:59:31 +0000 Subject: [PATCH 003/263] 8331717: C2: Crash with SIGFPE Because Loop Predication Wrongly Hoists Division Requiring Zero Check Reviewed-by: chagedorn, qamai, kvn --- src/hotspot/share/opto/loopPredicate.cpp | 2 +- .../TestLoopPredicationDivZeroCheck.java | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestLoopPredicationDivZeroCheck.java diff --git a/src/hotspot/share/opto/loopPredicate.cpp b/src/hotspot/share/opto/loopPredicate.cpp index 02649d3711a99..0ff08712624a0 100644 --- a/src/hotspot/share/opto/loopPredicate.cpp +++ b/src/hotspot/share/opto/loopPredicate.cpp @@ -469,7 +469,7 @@ class Invariance : public StackObj { // loop, it was marked invariant but n is only invariant if // it depends only on that test. Otherwise, unless that test // is out of the loop, it's not invariant. - if (n->is_CFG() || n->depends_only_on_test() || n->in(0) == nullptr || !_phase->is_member(_lpt, n->in(0))) { + if (n->is_CFG() || (n->depends_only_on_test() && _phase->igvn().no_dependent_zero_check(n)) || n->in(0) == nullptr || !_phase->is_member(_lpt, n->in(0))) { _invariant.set(n->_idx); // I am a invariant too } } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestLoopPredicationDivZeroCheck.java b/test/hotspot/jtreg/compiler/loopopts/TestLoopPredicationDivZeroCheck.java new file mode 100644 index 0000000000000..82935475aa0a5 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestLoopPredicationDivZeroCheck.java @@ -0,0 +1,89 @@ +/* + * 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 8331717 + * @summary C2: Crash with SIGFPE + * + * @run main/othervm -XX:CompileCommand=compileonly,*TestLoopPredicationDivZeroCheck*::* -XX:-TieredCompilation -Xbatch TestLoopPredicationDivZeroCheck + */ + +public class TestLoopPredicationDivZeroCheck { + static int iArr[] = new int[100]; + static volatile long lFld; + static int iFld; + + public static void main(String[] strArr) { + for (int i = 0; i < 10000; i++) { + test(); + } + for (int i = 0; i < 10000; i++) { + test2(); + } + } + + /* + * The division 2 / i4 requires a non-zero check. As the result is an array access, it will be the input to a range + * check. Loop predication will try to move the range check and the division to right before the loop as the division + * appears to be invariant (i4 is always 0). However, the division is not truly invariant as it requires the zero + * check for i4 that can throw an exception. The bug fixed in 8331717 caused the division to still be moved before the + * for loop with the range check. + */ + static void test() { + int i1 = 0; + + for (int i4 : iArr) { + i4 = i1; + try { + iArr[0] = 1 / i4; + i4 = iArr[2 / i4]; + } catch (ArithmeticException a_e) { + } + } + } + + /* + * Loop predication will try to move 3 / y (input to the range check for bArr[x / 30]) before its containing for loop + * but it may not as y must be zero-checked. The same problem as above occurred before the fix in 8331717. + */ + static void test2() { + int x = 0; + int y = iFld; + long lArr[] = new long[400]; + boolean bArr[] = new boolean[400]; + for (int i = 0; i < 10000; i++) { + for (int j = 1; j < 13; j++) { + for (int k = 1; k < 2; k++) { + lFld = 0; + lArr[1] = 7; + try { + x = 3 / y; + } catch (ArithmeticException a_e) { + } + bArr[x / 30] = true; + } + } + } + } +} From 5e92a4ceafd0626e3600e44a3370ca2f5d9347c8 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 10 Jan 2025 10:02:24 +0000 Subject: [PATCH 004/263] 8347267: [macOS]: UnixOperatingSystem.c:67:40: runtime error: division by zero Reviewed-by: kevinw, cjplummer --- .../macosx/native/libmanagement_ext/UnixOperatingSystem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c index 2c11cd9ca9d8d..269c4d4535909 100644 --- a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c +++ b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ Java_com_sun_management_internal_OperatingSystemImpl_getCpuLoad0 jlong used_delta = used - last_used; jlong total_delta = total - last_total; + if (total_delta == 0) { + return 0; + } jdouble cpu = (jdouble) used_delta / total_delta; From 1f457977f062e4ed219c6fa0fe26cb42acaf4bf2 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Fri, 10 Jan 2025 10:06:24 +0000 Subject: [PATCH 005/263] 8347124: Clean tests with --enable-linkable-runtime Reviewed-by: shade, alanb --- test/jdk/jdk/jfr/jvm/TestModularImage.java | 9 +++++++-- test/jdk/tools/launcher/SourceMode.java | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/jdk/jdk/jfr/jvm/TestModularImage.java b/test/jdk/jdk/jfr/jvm/TestModularImage.java index 0f10150af601a..7a01936517870 100644 --- a/test/jdk/jdk/jfr/jvm/TestModularImage.java +++ b/test/jdk/jdk/jfr/jvm/TestModularImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,12 @@ * as expected * @requires vm.hasJFR * @library /test/lib - * @run driver jdk.jfr.jvm.TestModularImage + * @comment Test is being run in othervm to support JEP 493 enabled + * JDKs which don't allow patched modules. Note that jtreg patches + * module java.base to add java.lang.JTRegModuleHelper. If then a + * jlink run is attempted in-process - using the ToolProvider API - + * on a JEP 493 enabled JDK, the test fails. + * @run main/othervm jdk.jfr.jvm.TestModularImage */ public class TestModularImage { private static final String STARTED_RECORDING = "Started recording"; diff --git a/test/jdk/tools/launcher/SourceMode.java b/test/jdk/tools/launcher/SourceMode.java index 20e8822856362..23f0b12e9b491 100644 --- a/test/jdk/tools/launcher/SourceMode.java +++ b/test/jdk/tools/launcher/SourceMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 @@ * @bug 8192920 8204588 8210275 8286571 * @summary Test source mode * @modules jdk.compiler jdk.jlink - * @run main SourceMode + * @comment Test is being run in othervm to support JEP 493 enabled + * JDKs which don't allow patched modules. Note that jtreg patches + * module java.base to add java.lang.JTRegModuleHelper. If then a + * jlink run is attempted in-process - using the ToolProvider API - + * on a JEP 493 enabled JDK, the test fails. + * @run main/othervm SourceMode */ From 57af52c57390f6f7413b5d3ffe64921c9b83aae4 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Fri, 10 Jan 2025 10:34:22 +0000 Subject: [PATCH 006/263] 8346581: JRadioButton/ButtonGroupFocusTest.java fails in CI on Linux Reviewed-by: honkar, dnguyen --- .../ButtonGroupFocusTest.java | 150 +++++++++++++----- 1 file changed, 111 insertions(+), 39 deletions(-) diff --git a/test/jdk/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java b/test/jdk/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java index c696b166dd085..633b0356f85df 100644 --- a/test/jdk/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java +++ b/test/jdk/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,26 +28,53 @@ * @run main ButtonGroupFocusTest */ -import javax.swing.*; -import java.awt.*; +import java.awt.AWTEvent; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.KeyboardFocusManager; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.concurrent.CountDownLatch; -public class ButtonGroupFocusTest { +import javax.imageio.ImageIO; +import javax.swing.ButtonGroup; +import javax.swing.JFrame; +import javax.swing.JRadioButton; +import javax.swing.SwingUtilities; + +import static java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; + +public final class ButtonGroupFocusTest { private static JRadioButton button1; private static JRadioButton button2; private static JRadioButton button3; private static JRadioButton button4; private static JRadioButton button5; - private static Robot robot; + + private static final CountDownLatch button2FocusLatch = new CountDownLatch(1); + private static final CountDownLatch button3FocusLatch = new CountDownLatch(1); + private static final CountDownLatch button4FocusLatch = new CountDownLatch(1); + + private static final CountDownLatch button2FocusLatch2 = new CountDownLatch(2); + + private static final long FOCUS_TIMEOUT = 4; + private static JFrame frame; public static void main(String[] args) throws Exception { - robot = new Robot(); - robot.setAutoDelay(100); + final Robot robot = new Robot(); SwingUtilities.invokeAndWait(() -> { - frame = new JFrame(); + frame = new JFrame("ButtonGroupFocusTest"); Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout()); button1 = new JRadioButton("Button 1"); @@ -60,6 +87,7 @@ public static void main(String[] args) throws Exception { contentPane.add(button4); button5 = new JRadioButton("Button 5"); contentPane.add(button5); + ButtonGroup group = new ButtonGroup(); group.add(button1); group.add(button2); @@ -69,52 +97,96 @@ public static void main(String[] args) throws Exception { group.add(button4); group.add(button5); + button2.addFocusListener(new LatchFocusListener(button2FocusLatch)); + button3.addFocusListener(new LatchFocusListener(button3FocusLatch)); + button4.addFocusListener(new LatchFocusListener(button4FocusLatch)); + + button2.addFocusListener(new LatchFocusListener(button2FocusLatch2)); + button2.setSelected(true); + // Debugging aid: log focus owner changes... + KeyboardFocusManager focusManager = getCurrentKeyboardFocusManager(); + focusManager.addPropertyChangeListener("focusOwner", + e -> System.out.println(e.getPropertyName() + + "\n\t" + e.getOldValue() + + "\n\t" + e.getNewValue())); + + // ...and dispatched key events + Toolkit.getDefaultToolkit().addAWTEventListener( + e -> System.out.println("Dispatched " + e), + AWTEvent.KEY_EVENT_MASK); + frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); }); - robot.waitForIdle(); - robot.delay(200); - - SwingUtilities.invokeAndWait(() -> { - if( !button2.hasFocus() ) { - frame.dispose(); - throw new RuntimeException( - "Button 2 should get focus after activation"); + try { + if (!button2FocusLatch.await(FOCUS_TIMEOUT, SECONDS)) { + throw new RuntimeException("Button 2 should get focus " + + "after activation"); } - }); + robot.waitForIdle(); + robot.delay(200); - robot.keyPress(KeyEvent.VK_TAB); - robot.keyRelease(KeyEvent.VK_TAB); + System.out.println("\n\n*** Tab 1st"); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); - robot.waitForIdle(); - robot.delay(200); + if (!button4FocusLatch.await(FOCUS_TIMEOUT, SECONDS)) { + throw new RuntimeException("Button 4 should get focus"); + } + robot.waitForIdle(); + robot.delay(200); - SwingUtilities.invokeAndWait(() -> { - if( !button4.hasFocus() ) { - frame.dispose(); - throw new RuntimeException( - "Button 4 should get focus"); + if (button2FocusLatch2.await(1, MILLISECONDS)) { + throw new RuntimeException("Focus moved back to Button 2"); } - button3.setSelected(true); - }); - robot.keyPress(KeyEvent.VK_TAB); - robot.keyRelease(KeyEvent.VK_TAB); + SwingUtilities.invokeAndWait(() -> button3.setSelected(true)); + robot.waitForIdle(); + robot.delay(200); - robot.waitForIdle(); - robot.delay(200); + System.out.println("\n\n*** Tab 2nd"); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); - SwingUtilities.invokeAndWait(() -> { - if( !button3.hasFocus() ) { - frame.dispose(); - throw new RuntimeException( - "selected Button 3 should get focus"); + if (!button3FocusLatch.await(FOCUS_TIMEOUT, SECONDS)) { + throw new RuntimeException("Selected Button 3 should get focus"); } - }); + } catch (Exception e) { + BufferedImage image = robot.createScreenCapture(getFrameBounds()); + ImageIO.write(image, "png", + new File("image.png")); + + SwingUtilities.invokeAndWait(() -> + System.err.println("Current focus owner: " + + getCurrentKeyboardFocusManager() + .getFocusOwner())); + + throw e; + } finally { + SwingUtilities.invokeAndWait(frame::dispose); + } + } + + private static Rectangle getFrameBounds() throws Exception { + Rectangle[] bounds = new Rectangle[1]; + SwingUtilities.invokeAndWait(() -> bounds[0] = frame.getBounds()); + return bounds[0]; + } + + private static final class LatchFocusListener extends FocusAdapter { + private final CountDownLatch focusGainedLatch; + + private LatchFocusListener(CountDownLatch focusGainedLatch) { + this.focusGainedLatch = focusGainedLatch; + } - SwingUtilities.invokeLater(frame::dispose); + @Override + public void focusGained(FocusEvent e) { + focusGainedLatch.countDown(); + } } } From 12752b0031643b3bf868de50b4455654162b2ee4 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Fri, 10 Jan 2025 10:51:34 +0000 Subject: [PATCH 007/263] 8347346: Remove redundant ClassForName.java and test.policy from runtime/Dictionary Reviewed-by: coleenp --- .../runtime/Dictionary/ClassForName.java | 47 ------------------- .../jtreg/runtime/Dictionary/test.policy | 6 --- 2 files changed, 53 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/Dictionary/ClassForName.java delete mode 100644 test/hotspot/jtreg/runtime/Dictionary/test.policy diff --git a/test/hotspot/jtreg/runtime/Dictionary/ClassForName.java b/test/hotspot/jtreg/runtime/Dictionary/ClassForName.java deleted file mode 100644 index a2bbbd0369643..0000000000000 --- a/test/hotspot/jtreg/runtime/Dictionary/ClassForName.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - * 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.net.URLClassLoader; - -/* - * This class is loaded by the custom URLClassLoader, and then calls - * Class.forName() with the protection domain for the checkPackageAccess - * call created from the code source jar file. - */ -public class ClassForName { - static { - if (!(ClassForName.class.getClassLoader() instanceof URLClassLoader)) { - throw new RuntimeException("Supposed to be loaded by URLClassLoader"); - } - } - - public ClassForName() { - try { - // class_loader = App$ClassLoader, protection_domain = ClassForName.getProtectionDomain() - Class.forName(java.util.List.class.getName(), false, - ClassLoader.getSystemClassLoader()); - } catch (Throwable e) { - e.printStackTrace(); - } - } -} diff --git a/test/hotspot/jtreg/runtime/Dictionary/test.policy b/test/hotspot/jtreg/runtime/Dictionary/test.policy deleted file mode 100644 index 06998b8bcae85..0000000000000 --- a/test/hotspot/jtreg/runtime/Dictionary/test.policy +++ /dev/null @@ -1,6 +0,0 @@ -grant { - permission java.io.FilePermission "<>", "read, write, delete, execute"; - permission java.lang.RuntimePermission "createClassLoader"; - permission java.lang.RuntimePermission "getClassLoader"; - permission java.util.PropertyPermission "*", "read"; /* for Utils */ -}; From ec7393e9190c1b93ca08e1107f734c869f400b89 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Fri, 10 Jan 2025 13:46:57 +0000 Subject: [PATCH 008/263] 8347287: JFR: Remove use of Security Manager Reviewed-by: mgronlun --- .../share/jfr/support/jfrIntrinsics.hpp | 4 +- .../share/jfr/support/jfrResolution.cpp | 18 +- .../classes/jdk/jfr/AnnotationElement.java | 4 +- .../share/classes/jdk/jfr/EventFactory.java | 5 +- .../share/classes/jdk/jfr/FlightRecorder.java | 14 +- .../jdk/jfr/FlightRecorderPermission.java | 12 +- .../share/classes/jdk/jfr/Recording.java | 14 +- .../share/classes/jdk/jfr/SettingControl.java | 26 +- .../classes/jdk/jfr/ValueDescriptor.java | 4 +- .../classes/jdk/jfr/consumer/EventStream.java | 17 +- .../jdk/jfr/consumer/RecordingFile.java | 9 +- .../jdk/jfr/consumer/RecordingStream.java | 10 +- .../jdk/jfr/internal/ChunkInputStream.java | 5 +- .../classes/jdk/jfr/internal/Control.java | 81 +--- .../jdk/jfr/internal/EventControl.java | 11 +- .../jfr/internal/EventInstrumentation.java | 8 +- .../classes/jdk/jfr/internal/FilePurger.java | 24 +- .../classes/jdk/jfr/internal/JDKEvents.java | 36 +- .../classes/jdk/jfr/internal/JVMSupport.java | 4 +- .../classes/jdk/jfr/internal/JVMUpcalls.java | 8 +- .../jdk/jfr/internal/MetadataLoader.java | 4 +- .../jdk/jfr/internal/MetadataRepository.java | 6 +- .../classes/jdk/jfr/internal/Options.java | 17 +- .../jdk/jfr/internal/PlatformRecorder.java | 61 +-- .../jdk/jfr/internal/PlatformRecording.java | 105 ++-- .../jdk/jfr/internal/PrivateAccess.java | 9 +- .../classes/jdk/jfr/internal/Repository.java | 86 ++-- .../jdk/jfr/internal/RepositoryChunk.java | 32 +- .../jdk/jfr/internal/SecuritySupport.java | 459 +----------------- .../jdk/jfr/internal/ShutdownHook.java | 12 +- .../classes/jdk/jfr/internal/TypeLibrary.java | 4 +- .../JDKEventTask.java => WriteablePath.java} | 56 ++- .../jdk/jfr/internal/WriteableUserPath.java | 148 ------ .../consumer/AbstractEventStream.java | 31 +- .../consumer/EventDirectoryStream.java | 19 +- .../internal/consumer/EventFileStream.java | 9 +- .../jdk/jfr/internal/consumer/FileAccess.java | 97 ---- .../jfr/internal/consumer/OngoingStream.java | 10 +- .../jfr/internal/consumer/RecordingInput.java | 19 +- .../internal/consumer/RepositoryFiles.java | 26 +- .../internal/consumer/filter/ChunkWriter.java | 5 +- .../jdk/jfr/internal/dcmd/AbstractDCmd.java | 33 +- .../jdk/jfr/internal/dcmd/DCmdConfigure.java | 8 +- .../jdk/jfr/internal/dcmd/DCmdDump.java | 18 +- .../jdk/jfr/internal/dcmd/DCmdStart.java | 24 +- .../jdk/jfr/internal/dcmd/DCmdStop.java | 16 +- .../jdk/jfr/internal/event/EventWriter.java | 34 +- .../classes/jdk/jfr/internal/jfc/JFC.java | 65 +-- .../jdk/jfr/internal/jfc/model/JFCModel.java | 10 +- .../internal/management/ChunkFilename.java | 24 +- .../management/ManagementSupport.java | 25 +- .../jfr/internal/periodic/JavaEventTask.java | 11 +- .../jdk/jfr/internal/periodic/LookupKey.java | 9 +- .../jfr/internal/periodic/PeriodicEvents.java | 11 +- .../jfr/internal/periodic/PeriodicTask.java | 9 +- .../jfr/internal/periodic/UserEventTask.java | 71 --- .../jfr/internal/settings/BooleanSetting.java | 5 +- .../jfr/internal/settings/CutoffSetting.java | 5 +- .../internal/settings/JDKSettingControl.java | 35 -- .../jfr/internal/settings/LevelSetting.java | 5 +- .../jfr/internal/settings/PeriodSetting.java | 5 +- .../internal/settings/ThresholdSetting.java | 5 +- .../internal/settings/ThrottleSetting.java | 5 +- .../jdk/jfr/internal/tool/Command.java | 4 +- .../jdk/jfr/internal/tool/Configure.java | 23 +- .../jdk/jfr/internal/tool/Disassemble.java | 5 +- .../jdk/jfr/internal/tool/Summary.java | 5 +- .../DirectoryCleaner.java} | 40 +- .../classes/jdk/jfr/internal/util/Utils.java | 13 +- .../jdk/management/jfr/DiskRepository.java | 4 +- .../jfr/FlightRecorderMXBeanImpl.java | 73 +-- .../jdk/management/jfr/MBeanUtils.java | 23 +- .../management/jfr/RemoteRecordingStream.java | 13 +- test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java | 10 +- .../jfr/jvm/MyCommitRegisteredFalseEvent.java | 4 +- .../jfr/jvm/MyCommitRegisteredTrueEvent.java | 4 +- test/jdk/jdk/jfr/jvm/NonEvent.java | 4 +- .../jdk/jfr/jvm/PlaceholderEventWriter.java | 6 +- .../jvm/PlaceholderEventWriterFactory.java | 35 -- .../jdk/jdk/jfr/jvm/RegisteredFalseEvent.java | 4 +- test/jdk/jdk/jfr/jvm/RegisteredTrueEvent.java | 4 +- test/jdk/jdk/jfr/jvm/StaticCommitEvent.java | 4 +- test/jdk/jdk/jfr/jvm/TestGetEventWriter.java | 32 +- test/jdk/jdk/jfr/tool/TestAssemble.java | 5 +- 84 files changed, 547 insertions(+), 1730 deletions(-) rename src/jdk.jfr/share/classes/jdk/jfr/internal/{periodic/JDKEventTask.java => WriteablePath.java} (52%) delete mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/WriteableUserPath.java delete mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java delete mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/UserEventTask.java delete mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/settings/JDKSettingControl.java rename src/jdk.jfr/share/classes/jdk/jfr/internal/{EventWriterFactoryRecipe.java => util/DirectoryCleaner.java} (56%) delete mode 100644 test/jdk/jdk/jfr/jvm/PlaceholderEventWriterFactory.java diff --git a/src/hotspot/share/jfr/support/jfrIntrinsics.hpp b/src/hotspot/share/jfr/support/jfrIntrinsics.hpp index 77affc69926f0..31a81e7d7b544 100644 --- a/src/hotspot/share/jfr/support/jfrIntrinsics.hpp +++ b/src/hotspot/share/jfr/support/jfrIntrinsics.hpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ class JfrIntrinsicSupport : AllStatic { #define JFR_TEMPLATES(template) \ template(jdk_jfr_internal_management_HiddenWait, "jdk/jfr/internal/management/HiddenWait") \ template(jdk_jfr_internal_JVM, "jdk/jfr/internal/JVM") \ - template(jdk_jfr_internal_event_EventWriterFactory, "jdk/jfr/internal/event/EventWriterFactory") \ + template(jdk_jfr_internal_event_EventWriter, "jdk/jfr/internal/event/EventWriter") \ template(jdk_jfr_internal_event_EventConfiguration_signature, "Ljdk/jfr/internal/event/EventConfiguration;") \ template(getEventWriter_signature, "()Ljdk/jfr/internal/event/EventWriter;") \ template(eventConfiguration_name, "eventConfiguration") \ diff --git a/src/hotspot/share/jfr/support/jfrResolution.cpp b/src/hotspot/share/jfr/support/jfrResolution.cpp index 486067c485a72..0a4c8a1f3f100 100644 --- a/src/hotspot/share/jfr/support/jfrResolution.cpp +++ b/src/hotspot/share/jfr/support/jfrResolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,7 +182,7 @@ static inline const Method* ljf_sender_method(JavaThread* jt) { return ljf.method(); } -static const char* const link_error_msg = "illegal access linking method 'jdk.jfr.internal.event.EventWriterFactory.getEventWriter(long)'"; +static const char* const link_error_msg = "illegal access linking method 'jdk.jfr.internal.event.EventWriter.getEventWriter()'"; void JfrResolution::on_runtime_resolution(const CallInfo & info, TRAPS) { assert(info.selected_method() != nullptr, "invariant"); @@ -199,12 +199,12 @@ void JfrResolution::on_runtime_resolution(const CallInfo & info, TRAPS) { if (method->name() != event_writer_method_name) { return; } - static const Symbol* const event_writer_factory_klass_name = vmSymbols::jdk_jfr_internal_event_EventWriterFactory(); - assert(event_writer_factory_klass_name != nullptr, "invariant"); - if (info.resolved_klass()->name() != event_writer_factory_klass_name) { + static const Symbol* const event_writer_klass_name = vmSymbols::jdk_jfr_internal_event_EventWriter(); + assert(event_writer_klass_name != nullptr, "invariant"); + if (info.resolved_klass()->name() != event_writer_klass_name) { return; } - // Attempting to link against jdk.jfr.internal.event.EventWriterFactory.getEventWriter(). + // Attempting to link against jdk.jfr.internal.event.EventWriter.getEventWriter(). // The sender, i.e. the method attempting to link, is in the ljf (if one exists). const Method* const sender = ljf_sender_method(THREAD); if (sender == nullptr) { @@ -228,9 +228,9 @@ void JfrResolution::on_runtime_resolution(const CallInfo & info, TRAPS) { } static inline bool is_compiler_linking_event_writer(const Symbol* holder, const Symbol* name) { - static const Symbol* const event_writer_factory_klass_name = vmSymbols::jdk_jfr_internal_event_EventWriterFactory(); - assert(event_writer_factory_klass_name != nullptr, "invariant"); - if (holder != event_writer_factory_klass_name) { + static const Symbol* const event_writer_klass_name = vmSymbols::jdk_jfr_internal_event_EventWriter(); + assert(event_writer_klass_name != nullptr, "invariant"); + if (holder != event_writer_klass_name) { return false; } static const Symbol* const event_writer_method_name = vmSymbols::getEventWriter_name(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/AnnotationElement.java b/src/jdk.jfr/share/classes/jdk/jfr/AnnotationElement.java index 108498c340d42..046709fa92e16 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/AnnotationElement.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/AnnotationElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import java.util.Set; import java.util.StringJoiner; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.Type; import jdk.jfr.internal.TypeLibrary; import jdk.jfr.internal.util.Utils; @@ -115,7 +114,6 @@ public final class AnnotationElement { public AnnotationElement(Class annotationType, Map values) { Objects.requireNonNull(annotationType, "annotationType"); Objects.requireNonNull(values, "values"); - SecuritySupport.checkRegisterPermission(); // copy values to avoid modification after validation HashMap map = new HashMap<>(values); for (Map.Entry entry : map.entrySet()) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/EventFactory.java b/src/jdk.jfr/share/classes/jdk/jfr/EventFactory.java index fc7b61e875634..282e1ae598f7f 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/EventFactory.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/EventFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import jdk.jfr.internal.EventClassBuilder; import jdk.jfr.internal.JVMSupport; import jdk.jfr.internal.MetadataRepository; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.Type; import jdk.jfr.internal.util.Utils; @@ -99,8 +98,6 @@ public static EventFactory create(List annotationElements, Li Objects.requireNonNull(fields, "fields"); JVMSupport.ensureWithInternalError(); - SecuritySupport.checkRegisterPermission(); - List sanitizedAnnotation = Utils.sanitizeNullFreeList(annotationElements, AnnotationElement.class); List sanitizedFields = Utils.sanitizeNullFreeList(fields, ValueDescriptor.class); Set nameSet = HashSet.newHashSet(sanitizedFields.size()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java index 774b36b97d796..a7bf3976d14df 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,6 @@ import static jdk.jfr.internal.LogLevel.INFO; import static jdk.jfr.internal.LogTag.JFR; -import java.security.AccessControlContext; -import java.security.AccessController; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -44,7 +42,6 @@ import jdk.jfr.internal.PlatformRecorder; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.Repository; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.util.Utils; import jdk.jfr.internal.periodic.PeriodicEvents; @@ -157,7 +154,6 @@ public static void unregister(Class eventClass) { */ public static FlightRecorder getFlightRecorder() throws IllegalStateException { synchronized (PlatformRecorder.class) { - SecuritySupport.checkAccessFlightRecorder(); JVMSupport.ensureWithIllegalStateException(); if (platformRecorder == null) { try { @@ -213,10 +209,7 @@ public static void addPeriodicEvent(Class eventClass, Runnable } Utils.ensureValidEventSubclass(eventClass); - SecuritySupport.checkRegisterPermission(); - @SuppressWarnings("removal") - AccessControlContext acc = AccessController.getContext(); - PeriodicEvents.addUserEvent(acc, eventClass, hook); + PeriodicEvents.addJavaEvent(eventClass, hook); } /** @@ -227,7 +220,6 @@ public static void addPeriodicEvent(Class eventClass, Runnable */ public static boolean removePeriodicEvent(Runnable hook) { Objects.requireNonNull(hook, "hook"); - SecuritySupport.checkRegisterPermission(); if (JVMSupport.isNotAvailable()) { return false; } @@ -260,7 +252,6 @@ public List getEventTypes() { */ public static void addListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener, "changeListener"); - SecuritySupport.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return; } @@ -280,7 +271,6 @@ public static void addListener(FlightRecorderListener changeListener) { */ public static boolean removeListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener, "changeListener"); - SecuritySupport.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return false; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java index 5a2dc51bc4170..67e844ac269a9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 jdk.jfr; -import java.security.AccessControlContext; import java.util.List; import java.util.Map; import java.util.Objects; @@ -34,7 +33,6 @@ import jdk.jfr.internal.PlatformRecorder; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.Type; import jdk.jfr.internal.management.EventSettingsModifier; @@ -156,12 +154,6 @@ public PlatformRecorder getPlatformRecorder() { return FlightRecorder.getFlightRecorder().getInternal(); } - @SuppressWarnings("removal") - @Override - public AccessControlContext getContext(SettingControl settingControl) { - return settingControl.getContext(); - } - @Override public EventSettings newEventSettings(EventSettingsModifier esm) { return new EventSettings.DelegatedEventSettings(esm); @@ -184,7 +176,7 @@ public boolean isVisible(EventType t) { */ public FlightRecorderPermission(String name) { super(Objects.requireNonNull(name, "name")); - if (!name.equals(SecuritySupport.ACCESS_FLIGHT_RECORDER) && !name.equals(SecuritySupport.REGISTER_EVENT)) { + if (!name.equals("accessFlightRecorder") && !name.equals("registerEvent")) { throw new IllegalArgumentException("name: " + name); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java index 6168ddb28329f..333645f1731ff 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.Type; import jdk.jfr.internal.util.Utils; -import jdk.jfr.internal.WriteableUserPath; +import jdk.jfr.internal.WriteablePath; /** * Provides means to configure, start, stop and dump recording data to disk. @@ -368,7 +368,7 @@ public Recording copy(boolean stop) { */ public void dump(Path destination) throws IOException { Objects.requireNonNull(destination, "destination"); - internal.dump(new WriteableUserPath(destination)); + internal.dump(new WriteablePath(destination)); } /** @@ -461,7 +461,7 @@ public void setMaxAge(Duration maxAge) { * @throws IOException if the path is not writable */ public void setDestination(Path destination) throws IOException { - internal.setDestination(destination != null ? new WriteableUserPath(destination) : null); + internal.setDestination(destination != null ? new WriteablePath(destination) : null); } /** @@ -471,11 +471,11 @@ public void setDestination(Path destination) throws IOException { * @return the destination file, or {@code null} if not set. */ public Path getDestination() { - WriteableUserPath usp = internal.getDestination(); - if (usp == null) { + WriteablePath wp = internal.getDestination(); + if (wp == null) { return null; } else { - return usp.getPotentiallyMaliciousOriginal(); + return wp.getPath(); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java b/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java index 1c699247800c0..ac73f6d4c12b2 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ package jdk.jfr; -import java.security.AccessControlContext; -import java.security.AccessController; import java.util.Set; -import jdk.jfr.internal.settings.JDKSettingControl; - /** * Base class to extend to create setting controls. *

@@ -77,30 +73,10 @@ @MetadataDefinition public abstract class SettingControl { - @SuppressWarnings("removal") - private final AccessControlContext context; - private final boolean initialized; - /** * Constructor for invocation by subclass constructors. */ - @SuppressWarnings("removal") protected SettingControl() { - context = this instanceof JDKSettingControl ? null : AccessController.getContext(); - initialized = true; - } - - @SuppressWarnings("removal") - final AccessControlContext getContext() { - // Ensure object state is safe - if (!initialized) { - throw new InternalError("Object must be initialized before security context can be retrieved"); - } - AccessControlContext c = this.context; - if (c == null && !(this instanceof JDKSettingControl)) { - throw new InternalError("Security context can only be null for trusted setting controls"); - } - return c; } /** diff --git a/src/jdk.jfr/share/classes/jdk/jfr/ValueDescriptor.java b/src/jdk.jfr/share/classes/jdk/jfr/ValueDescriptor.java index ff485aa96e7eb..9994b689d093e 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/ValueDescriptor.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/ValueDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,6 @@ import java.util.Objects; import jdk.jfr.internal.AnnotationConstruct; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.Type; import jdk.jfr.internal.util.Utils; @@ -143,7 +142,6 @@ public ValueDescriptor(Class type, String name, List annot Objects.requireNonNull(type, "type"); Objects.requireNonNull(name, "name"); Objects.requireNonNull(annotations, "annotations"); - SecuritySupport.checkRegisterPermission(); if (!allowArray) { if (type.isArray()) { throw new IllegalArgumentException("Array types are not allowed"); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java index 1a1c468add9c3..ac325f19f222d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,18 +27,14 @@ import java.io.IOException; import java.nio.file.Path; -import java.security.AccessControlContext; -import java.security.AccessController; import java.time.Duration; import java.time.Instant; import java.util.Collections; import java.util.Objects; import java.util.function.Consumer; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.consumer.EventDirectoryStream; import jdk.jfr.internal.consumer.EventFileStream; -import jdk.jfr.internal.consumer.FileAccess; /** * Represents a stream of events. @@ -113,13 +109,9 @@ public interface EventStream extends AutoCloseable { * @throws IOException if a stream can't be opened, or an I/O error occurs * when trying to access the repository */ - @SuppressWarnings("removal") public static EventStream openRepository() throws IOException { - SecuritySupport.checkAccessFlightRecorder(); return new EventDirectoryStream( - AccessController.getContext(), null, - SecuritySupport.PRIVILEGED, null, Collections.emptyList(), false @@ -143,12 +135,8 @@ public static EventStream openRepository() throws IOException { */ public static EventStream openRepository(Path directory) throws IOException { Objects.requireNonNull(directory, "directory"); - @SuppressWarnings("removal") - AccessControlContext acc = AccessController.getContext(); return new EventDirectoryStream( - acc, directory, - FileAccess.UNPRIVILEGED, null, Collections.emptyList(), true @@ -169,10 +157,9 @@ public static EventStream openRepository(Path directory) throws IOException { * @throws IOException if the file can't be opened, or an I/O error occurs * during reading */ - @SuppressWarnings("removal") static EventStream openFile(Path file) throws IOException { Objects.requireNonNull(file, "file"); - return new EventFileStream(AccessController.getContext(), file); + return new EventFileStream(file); } /** diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java index 0437ec5958934..0e51da0411925 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,6 @@ import jdk.jfr.internal.consumer.ParserFilter; import jdk.jfr.internal.consumer.ChunkHeader; import jdk.jfr.internal.consumer.ChunkParser; -import jdk.jfr.internal.consumer.FileAccess; import jdk.jfr.internal.consumer.ParserState; import jdk.jfr.internal.consumer.RecordingInput; import jdk.jfr.internal.consumer.filter.ChunkWriter; @@ -81,7 +80,7 @@ public final class RecordingFile implements Closeable { public RecordingFile(Path file) throws IOException { Objects.requireNonNull(file, "file"); this.file = file.toFile(); - this.input = new RecordingInput(this.file, FileAccess.UNPRIVILEGED); + this.input = new RecordingInput(this.file); this.chunkWriter = null; findNext(); } @@ -146,7 +145,7 @@ public List readEventTypes() throws IOException { MetadataDescriptor previous = null; List types = new ArrayList<>(); HashSet foundIds = new HashSet<>(); - try (RecordingInput ri = new RecordingInput(file, FileAccess.UNPRIVILEGED)) { + try (RecordingInput ri = new RecordingInput(file)) { ChunkHeader ch = new ChunkHeader(ri); aggregateEventTypeForChunk(ch, null, types, foundIds); while (!ch.isLastChunk()) { @@ -162,7 +161,7 @@ List readTypes() throws IOException { MetadataDescriptor previous = null; List types = new ArrayList<>(200); HashSet foundIds = HashSet.newHashSet(types.size()); - try (RecordingInput ri = new RecordingInput(file, FileAccess.UNPRIVILEGED)) { + try (RecordingInput ri = new RecordingInput(file)) { ChunkHeader ch = new ChunkHeader(ri); ch.awaitFinished(); aggregateTypeForChunk(ch, null, types, foundIds); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java index 2e7d23bb84cc5..3d6c8de3015a2 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +27,6 @@ import java.io.IOException; import java.nio.file.Path; -import java.security.AccessControlContext; -import java.security.AccessController; import java.time.Duration; import java.time.Instant; import java.util.Collections; @@ -45,7 +43,6 @@ import jdk.jfr.RecordingState; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.util.Utils; import jdk.jfr.internal.consumer.EventDirectoryStream; import jdk.jfr.internal.management.StreamBarrier; @@ -98,18 +95,13 @@ public RecordingStream() { } private RecordingStream(Map settings) { - SecuritySupport.checkAccessFlightRecorder(); - @SuppressWarnings("removal") - AccessControlContext acc = AccessController.getContext(); this.recording = new Recording(); this.creationTime = Instant.now(); this.recording.setName("Recording Stream: " + creationTime); try { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); this.directoryStream = new EventDirectoryStream( - acc, null, - SecuritySupport.PRIVILEGED, pr, configurations(), false diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java index 7cc399019e697..4c8913e96a088 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -65,7 +66,7 @@ private boolean nextStream() throws IOException { return false; } - stream = new BufferedInputStream(SecuritySupport.newFileInputStream(currentChunk.getFile())); + stream = new BufferedInputStream(Files.newInputStream(currentChunk.getFile())); unstreamedSize -= currentChunk.getSize(); return true; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java index 8f246948710fc..b21b539cab87e 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,23 +25,16 @@ package jdk.jfr.internal; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Collections; import java.util.HashSet; import java.util.Objects; import java.util.Set; import jdk.jfr.SettingControl; -import jdk.jfr.internal.settings.JDKSettingControl; import jdk.jfr.internal.settings.PeriodSetting; import jdk.jfr.internal.settings.StackTraceSetting; import jdk.jfr.internal.settings.ThresholdSetting; final class Control { - @SuppressWarnings("removal") - private final AccessControlContext context; private static final int CACHE_SIZE = 5; private final Set[] cachedUnions = new HashSet[CACHE_SIZE]; private final String[] cachedValues = new String[CACHE_SIZE]; @@ -51,12 +44,8 @@ final class Control { // called by exposed subclass in external API public Control(SettingControl delegate, String defaultValue) { - this.context = PrivateAccess.getInstance().getContext(delegate); this.delegate = delegate; this.defaultValue = defaultValue; - if (this.context == null && !(delegate instanceof JDKSettingControl)) { - throw new InternalError("Security context can only be null for trusted setting controls"); - } } boolean isType(Class clazz) { @@ -74,25 +63,8 @@ final void setDefault() { apply(defaultValue); } - @SuppressWarnings("removal") public String getValue() { - if (context == null) { - // VM events requires no access control context - return delegate.getValue(); - } else { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public String run() { - try { - return delegate.getValue(); - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when trying to get value for " + getClass()); - } - return defaultValue != null ? defaultValue : ""; // Need to return something - } - }, context); - } + return delegate.getValue(); } private void apply(String value) { @@ -102,53 +74,18 @@ private void apply(String value) { setValue(value); } - @SuppressWarnings("removal") public void setValue(String value) { - if (context == null) { - // VM events requires no access control context - try { - delegate.setValue(value); - lastValue = delegate.getValue(); - } catch (Throwable t) { - Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when setting value \"" + value + "\" for " + getClass()); - lastValue = null; - } - } else { - lastValue = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public String run() { - try { - delegate.setValue(value); - return delegate.getValue(); - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when setting value \"" + value + "\" for " + getClass()); - } - return null; - } - }, context); + try { + delegate.setValue(value); + lastValue = delegate.getValue(); + } catch (Throwable t) { + Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when setting value \"" + value + "\". " + t.getMessage()); + lastValue = null; } } - - @SuppressWarnings("removal") public String combine(Set values) { - if (context == null) { - // VM events requires no access control context - return delegate.combine(values); - } - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public String run() { - try { - return delegate.combine(Collections.unmodifiableSet(values)); - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when combining " + values + " for " + getClass()); - } - return null; - } - }, context); + return delegate.combine(values); } private final String findCombine(Set values) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java index f086bbf884701..19e2febf88e24 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,7 +280,7 @@ private SettingControl instantiateSettingControl(Class } catch (Exception e) { throw (Error) new InternalError("Could not get constructor for " + settingControlClass.getName()).initCause(e); } - SecuritySupport.setAccessible(cc); + cc.setAccessible(true); try { return (SettingControl) cc.newInstance(); } catch (IllegalArgumentException | InvocationTargetException e) { @@ -373,13 +373,6 @@ public String getSettingsId() { return idName; } - /** - * A malicious user must never be able to run a callback in the wrong - * context. Methods on SettingControl must therefore never be invoked directly - * by JFR, instead use jdk.jfr.internal.Control. - * - * The returned list is only to be used inside EventConfiguration - */ public List getSettingControls() { return settingControls; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java index d962a535829ef..636ae3756e63b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,6 @@ private record SettingDesc(ClassDesc paramType, String methodName) { private static final ClassDesc TYPE_EVENT_CONFIGURATION = classDesc(EventConfiguration.class); private static final ClassDesc TYPE_ISE = Bytecode.classDesc(IllegalStateException.class); private static final ClassDesc TYPE_EVENT_WRITER = classDesc(EventWriter.class); - private static final ClassDesc TYPE_EVENT_WRITER_FACTORY = ClassDesc.of("jdk.jfr.internal.event.EventWriterFactory"); private static final ClassDesc TYPE_OBJECT = Bytecode.classDesc(Object.class); private static final ClassDesc TYPE_SETTING_DEFINITION = Bytecode.classDesc(SettingDefinition.class); private static final MethodDesc METHOD_BEGIN = MethodDesc.of("begin", "()V"); @@ -100,7 +99,7 @@ private record SettingDesc(ClassDesc paramType, String methodName) { private static final MethodDesc METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT = MethodDesc.of("shouldCommit", "(J)Z"); private static final MethodDesc METHOD_EVENT_CONFIGURATION_GET_SETTING = MethodDesc.of("getSetting", SettingControl.class, int.class); private static final MethodDesc METHOD_EVENT_SHOULD_COMMIT = MethodDesc.of("shouldCommit", "()Z"); - private static final MethodDesc METHOD_GET_EVENT_WRITER_KEY = MethodDesc.of("getEventWriter", "(J)" + TYPE_EVENT_WRITER.descriptorString()); + private static final MethodDesc METHOD_GET_EVENT_WRITER = MethodDesc.of("getEventWriter", "()" + TYPE_EVENT_WRITER.descriptorString()); private static final MethodDesc METHOD_IS_ENABLED = MethodDesc.of("isEnabled", "()Z"); private static final MethodDesc METHOD_RESET = MethodDesc.of("reset", "()V"); private static final MethodDesc METHOD_SHOULD_COMMIT_LONG = MethodDesc.of("shouldCommit", "(J)Z"); @@ -767,8 +766,7 @@ private boolean hasStaticMethod(MethodDesc method) { } private void getEventWriter(CodeBuilder codeBuilder) { - codeBuilder.ldc(EventWriterKey.getKey()); - invokestatic(codeBuilder, TYPE_EVENT_WRITER_FACTORY, METHOD_GET_EVENT_WRITER_KEY); + invokestatic(codeBuilder, TYPE_EVENT_WRITER, METHOD_GET_EVENT_WRITER); } private void getEventConfiguration(CodeBuilder codeBuilder) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/FilePurger.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/FilePurger.java index e643741adf5fe..f6649796a4d6b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/FilePurger.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/FilePurger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,19 +26,19 @@ package jdk.jfr.internal; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.SequencedSet; -import jdk.jfr.internal.SecuritySupport.SafePath; - // This class keeps track of files that can't be deleted // so they can at a later staged be removed. final class FilePurger { - private static final SequencedSet paths = new LinkedHashSet<>(); + private static final SequencedSet paths = new LinkedHashSet<>(); - public static synchronized void add(SafePath p) { + public static synchronized void add(Path p) { paths.add(p); if (paths.size() > 1000) { removeOldest(); @@ -50,7 +50,7 @@ public static synchronized void purge() { return; } - for (SafePath p : new ArrayList<>(paths)) { + for (Path p : new ArrayList<>(paths)) { if (delete(p)) { paths.remove(p); } @@ -61,16 +61,12 @@ private static void removeOldest() { paths.removeFirst(); } - private static boolean delete(SafePath p) { - try { - if (!SecuritySupport.exists(p)) { - return true; - } - } catch (IOException e) { - // ignore + private static boolean delete(Path p) { + if (!Files.exists(p)) { + return true; } try { - SecuritySupport.delete(p); + Files.delete(p); return true; } catch (IOException e) { return false; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JDKEvents.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JDKEvents.java index d0d186e2479d0..f0b7dcc2bf2ba 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JDKEvents.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JDKEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,11 +91,11 @@ public static synchronized void initialize() { try { if (initializationTriggered == false) { for (Class eventClass : eventClasses) { - SecuritySupport.registerEvent((Class) eventClass); + MetadataRepository.getInstance().register((Class) eventClass); } - PeriodicEvents.addJDKEvent(jdk.internal.event.ExceptionStatisticsEvent.class, emitExceptionStatistics); - PeriodicEvents.addJDKEvent(DirectBufferStatisticsEvent.class, emitDirectBufferStatistics); - PeriodicEvents.addJDKEvent(InitialSecurityPropertyEvent.class, emitInitialSecurityProperties); + PeriodicEvents.addJavaEvent(jdk.internal.event.ExceptionStatisticsEvent.class, emitExceptionStatistics); + PeriodicEvents.addJavaEvent(DirectBufferStatisticsEvent.class, emitDirectBufferStatistics); + PeriodicEvents.addJavaEvent(InitialSecurityPropertyEvent.class, emitInitialSecurityProperties); initializeContainerEvents(); JFRTracing.enable(); @@ -116,17 +116,21 @@ private static void initializeContainerEvents() { } // The registration of events and hooks are needed to provide metadata, // even when not running in a container - SecuritySupport.registerEvent(ContainerConfigurationEvent.class); - SecuritySupport.registerEvent(ContainerCPUUsageEvent.class); - SecuritySupport.registerEvent(ContainerCPUThrottlingEvent.class); - SecuritySupport.registerEvent(ContainerMemoryUsageEvent.class); - SecuritySupport.registerEvent(ContainerIOUsageEvent.class); - - PeriodicEvents.addJDKEvent(ContainerConfigurationEvent.class, emitContainerConfiguration); - PeriodicEvents.addJDKEvent(ContainerCPUUsageEvent.class, emitContainerCPUUsage); - PeriodicEvents.addJDKEvent(ContainerCPUThrottlingEvent.class, emitContainerCPUThrottling); - PeriodicEvents.addJDKEvent(ContainerMemoryUsageEvent.class, emitContainerMemoryUsage); - PeriodicEvents.addJDKEvent(ContainerIOUsageEvent.class, emitContainerIOUsage); + registerEvent(ContainerConfigurationEvent.class); + registerEvent(ContainerCPUUsageEvent.class); + registerEvent(ContainerCPUThrottlingEvent.class); + registerEvent(ContainerMemoryUsageEvent.class); + registerEvent(ContainerIOUsageEvent.class); + + PeriodicEvents.addJavaEvent(ContainerConfigurationEvent.class, emitContainerConfiguration); + PeriodicEvents.addJavaEvent(ContainerCPUUsageEvent.class, emitContainerCPUUsage); + PeriodicEvents.addJavaEvent(ContainerCPUThrottlingEvent.class, emitContainerCPUThrottling); + PeriodicEvents.addJavaEvent(ContainerMemoryUsageEvent.class, emitContainerMemoryUsage); + PeriodicEvents.addJavaEvent(ContainerIOUsageEvent.class, emitContainerIOUsage); + } + + private static void registerEvent(Class eventClass) { + MetadataRepository.getInstance().register(eventClass); } private static void emitExceptionStatistics() { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMSupport.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMSupport.java index 7fde28a3d21fc..ded1f78b76eff 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMSupport.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ public final class JVMSupport { private static boolean checkAvailability() { // set jfr.unsupported.vm to true to test API on an unsupported VM try { - if (SecuritySupport.getBooleanProperty("jfr.unsupported.vm")) { + if (Boolean.getBoolean("jfr.unsupported.vm")) { return false; } } catch (NoClassDefFoundError cnfe) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java index 6d1d5cf793823..7adafce6768bb 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,6 @@ static byte[] onRetransform(long traceId, boolean dummy1, boolean dummy2, Class< Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Skipping instrumentation for " + clazz.getName() + " since container support is missing"); return oldBytes; } - EventWriterKey.ensureEventWriterFactory(); EventConfiguration configuration = JVMSupport.getConfiguration(clazz.asSubclass(jdk.internal.event.Event.class)); if (configuration == null) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "No event configuration found for " + clazz.getName() + ". Ignoring instrumentation request."); @@ -124,7 +123,6 @@ static byte[] bytesForEagerInstrumentation(long traceId, boolean forceInstrument return oldBytes; } } - EventWriterKey.ensureEventWriterFactory(); Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding " + (forceInstrumentation ? "forced " : "") + "instrumentation for event type " + eventName + " during initial class load"); byte[] bytes = ei.buildInstrumented(); Bytecode.log(ei.getClassName() + "(" + traceId + ")", bytes); @@ -155,6 +153,8 @@ static void unhideInternalTypes() { * @return a new thread */ static Thread createRecorderThread(ThreadGroup systemThreadGroup, ClassLoader contextClassLoader) { - return SecuritySupport.createRecorderThread(systemThreadGroup, contextClassLoader); + Thread thread = new Thread(systemThreadGroup, "JFR Recorder Thread"); + thread.setContextClassLoader(contextClassLoader); + return thread; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataLoader.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataLoader.java index d0b5385475265..60db375c87686 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataLoader.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -191,7 +191,7 @@ private Class createAnnotationClass(String type) { public static List createTypes() throws IOException { try (DataInputStream dis = new DataInputStream( - SecuritySupport.getResourceAsStream("/jdk/jfr/internal/types/metadata.bin"))) { + MetadataLoader.class.getResourceAsStream("/jdk/jfr/internal/types/metadata.bin"))) { MetadataLoader ml = new MetadataLoader(dis); return ml.buildTypes(); } catch (Exception e) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java index 49afd0082d8a9..951142e2493b7 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,7 +123,6 @@ public synchronized EventType getEventType(Class eventClass) { - SecuritySupport.checkRegisterPermission(); EventConfiguration configuration = getConfiguration(eventClass, false); if (configuration != null) { configuration.getPlatformEventType().setRegistered(false); @@ -135,7 +134,6 @@ public synchronized EventType register(Class } public synchronized EventType register(Class eventClass, List dynamicAnnotations, List dynamicFields) { - SecuritySupport.checkRegisterPermission(); if (JVM.isExcluded(eventClass)) { // Event classes are marked as excluded during class load // if they override methods in the jdk.jfr.Event class, i.e. commit(). @@ -186,7 +184,7 @@ private EventConfiguration newEventConfiguration(EventType eventType, EventContr if (cachedEventConfigurationConstructor == null) { var argClasses = new Class[] { EventType.class, EventControl.class}; Constructor c = EventConfiguration.class.getDeclaredConstructor(argClasses); - SecuritySupport.setAccessible(c); + c.setAccessible(true); cachedEventConfigurationConstructor = c; } return cachedEventConfigurationConstructor.newInstance(eventType, ec); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Options.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Options.java index d07f1e6cb5e71..beeb46e1a60f3 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Options.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Options.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +26,9 @@ package jdk.jfr.internal; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.internal.misc.Unsafe; import static java.nio.file.LinkOption.*; @@ -50,7 +51,7 @@ public final class Options { private static long DEFAULT_THREAD_BUFFER_SIZE; private static final int DEFAULT_STACK_DEPTH = 64; private static final long DEFAULT_MAX_CHUNK_SIZE = 12 * 1024 * 1024; - private static final SafePath DEFAULT_DUMP_PATH = null; + private static final Path DEFAULT_DUMP_PATH = null; private static final boolean DEFAULT_PRESERVE_REPOSITORY = false; private static long memorySize; @@ -115,10 +116,10 @@ public static synchronized void setGlobalBufferSize(long globalBufsize) { globalBufferSize = globalBufsize; } - public static synchronized void setDumpPath(SafePath path) throws IOException { + public static synchronized void setDumpPath(Path path) throws IOException { if (path != null) { - if (SecuritySupport.isWritable(path)) { - path = SecuritySupport.toRealPath(path, NOFOLLOW_LINKS); + if (Files.isWritable(path)) { + path = path.toRealPath(NOFOLLOW_LINKS); } else { throw new IOException("Cannot write JFR emergency dump to " + path.toString()); } @@ -126,8 +127,8 @@ public static synchronized void setDumpPath(SafePath path) throws IOException { JVM.setDumpPath(path == null ? null : path.toString()); } - public static synchronized SafePath getDumpPath() { - return new SafePath(JVM.getDumpPath()); + public static synchronized Path getDumpPath() { + return Path.of(JVM.getDumpPath()); } public static synchronized void setStackDepth(Integer stackTraceDepth) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index b33a894304260..646c53f896134 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,8 +33,7 @@ import static jdk.jfr.internal.LogTag.JFR_SYSTEM; import java.io.IOException; -import java.security.AccessControlContext; -import java.security.AccessController; +import java.nio.file.Path; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -46,7 +45,6 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.CopyOnWriteArrayList; import jdk.jfr.FlightRecorder; import jdk.jfr.FlightRecorderListener; @@ -54,8 +52,6 @@ import jdk.jfr.RecordingState; import jdk.jfr.events.ActiveRecordingEvent; import jdk.jfr.events.ActiveSettingEvent; -import jdk.jfr.internal.SecuritySupport.SafePath; -import jdk.jfr.internal.SecuritySupport.SecureRecorderListener; import jdk.jfr.internal.consumer.EventLog; import jdk.jfr.internal.periodic.PeriodicEvents; import jdk.jfr.internal.util.Utils; @@ -64,7 +60,7 @@ public final class PlatformRecorder { private final ArrayList recordings = new ArrayList<>(); - private static final List changeListeners = new ArrayList<>(); + private static final List changeListeners = new ArrayList<>(); private final Repository repository; private final Thread shutdownHook; @@ -83,25 +79,9 @@ public PlatformRecorder() throws Exception { JDKEvents.initialize(); Logger.log(JFR_SYSTEM, INFO, "Registered JDK events"); startDiskMonitor(); - shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR Shutdown Hook", new ShutdownHook(this)); - SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler()); - SecuritySupport.registerShutdownHook(shutdownHook); - } - - - private static Timer createTimer() { - try { - List result = new CopyOnWriteArrayList<>(); - Thread t = SecuritySupport.createThreadWitNoPermissions("Permissionless thread", ()-> { - result.add(new Timer("JFR Recording Scheduler", true)); - }); - JVM.exclude(t); - t.start(); - t.join(); - return result.getFirst(); - } catch (InterruptedException e) { - throw new IllegalStateException("Not able to create timer task. " + e.getMessage(), e); - } + shutdownHook = new ShutdownHook(this); + shutdownHook.setUncaughtExceptionHandler(new ShutdownHook.ExceptionHandler()); + Runtime.getRuntime().addShutdownHook(shutdownHook); } public synchronized PlatformRecording newRecording(Map settings) { @@ -138,27 +118,18 @@ public synchronized List getRecordings() { } public static synchronized void addListener(FlightRecorderListener changeListener) { - @SuppressWarnings("removal") - AccessControlContext context = AccessController.getContext(); - SecureRecorderListener sl = new SecureRecorderListener(context, changeListener); boolean runInitialized; synchronized (PlatformRecorder.class) { runInitialized = FlightRecorder.isInitialized(); - changeListeners.add(sl); + changeListeners.add(changeListener); } if (runInitialized) { - sl.recorderInitialized(FlightRecorder.getFlightRecorder()); + changeListener.recorderInitialized(FlightRecorder.getFlightRecorder()); } } public static synchronized boolean removeListener(FlightRecorderListener changeListener) { - for (SecureRecorderListener s : new ArrayList<>(changeListeners)) { - if (s.getChangeListener() == changeListener) { - changeListeners.remove(s); - return true; - } - } - return false; + return changeListeners.remove(changeListener); } static synchronized List getListeners() { @@ -167,7 +138,7 @@ static synchronized List getListeners() { synchronized Timer getTimer() { if (timer == null) { - timer = createTimer(); + timer = new Timer("JFR Recording Scheduler", true); } return timer; } @@ -366,7 +337,7 @@ synchronized void stop(PlatformRecording recording) { } private Instant dumpMemoryToDestination(PlatformRecording recording) { - WriteableUserPath dest = recording.getDestination(); + WriteablePath dest = recording.getDestination(); if (dest != null) { Instant t = MetadataRepository.getInstance().setOutput(dest.getRealPathText()); recording.clearDestination(); @@ -441,8 +412,8 @@ public List makeChunkList(Instant startTime, Instant endTime) { } private void startDiskMonitor() { - Thread t = SecuritySupport.createThreadWitNoPermissions("JFR Periodic Tasks", () -> periodicTask()); - SecuritySupport.setDaemonThread(t, true); + Thread t = new Thread(() -> periodicTask(), "JFR Periodic Tasks"); + t.setDaemon(true); t.start(); } @@ -472,7 +443,7 @@ private void writeMetaEvents() { if (ActiveRecordingEvent.enabled()) { for (PlatformRecording r : getRecordings()) { if (r.getState() == RecordingState.RUNNING && r.shouldWriteMetadataEvent()) { - WriteableUserPath path = r.getDestination(); + WriteablePath path = r.getDestination(); Duration age = r.getMaxAge(); Duration flush = r.getFlushInterval(); Long size = r.getMaxSize(); @@ -519,7 +490,7 @@ private void periodicTask() { wait = Math.min(minDelta, Options.getWaitInterval()); } catch (Throwable t) { // Catch everything and log, but don't allow it to end the periodic task - Logger.log(JFR_SYSTEM, ERROR, "Error in Periodic task: " + t.getClass().getName()); + Logger.log(JFR_SYSTEM, WARN, "Error in Periodic task: " + t.getMessage()); } finally { takeNap(wait); } @@ -660,7 +631,7 @@ private void fillWithDiskChunks(PlatformRecording target) { target.setInternalDuration(startTime.until(endTime)); } - public synchronized void migrate(SafePath repo) throws IOException { + public synchronized void migrate(Path repo) throws IOException { // Must set repository while holding recorder lock so // the final chunk in repository gets marked correctly Repository.getRepository().setBasePath(repo); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java index 6014bbbf9d251..025b2878253ed 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,11 +35,8 @@ import java.io.InputStream; import java.nio.channels.FileChannel; import java.nio.file.NoSuchFileException; +import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -59,7 +56,6 @@ import jdk.jfr.FlightRecorderListener; import jdk.jfr.Recording; import jdk.jfr.RecordingState; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.util.Utils; import jdk.jfr.internal.util.ValueFormatter; @@ -73,12 +69,12 @@ public final class PlatformRecording implements AutoCloseable { private Duration maxAge; private long maxSize; - private WriteableUserPath destination; + private WriteablePath destination; private boolean toDisk = true; private String name; private boolean dumpOnExit; - private SafePath dumpDirectory; + private Path dumpDirectory; // Timestamp information private Instant stopTime; private Instant startTime; @@ -90,8 +86,6 @@ public final class PlatformRecording implements AutoCloseable { private volatile Recording recording; private TimerTask stopTask; private TimerTask startTask; - @SuppressWarnings("removal") - private final AccessControlContext dumpDirectoryControlContext; private boolean shouldWriteActiveRecordingEvent = true; private Duration flushInterval = Duration.ofSeconds(1); private long finalStartChunkNanos = Long.MIN_VALUE; @@ -99,13 +93,6 @@ public final class PlatformRecording implements AutoCloseable { @SuppressWarnings("removal") PlatformRecording(PlatformRecorder recorder, long id) { - // Typically the access control context is taken - // when you call dump(Path) or setDestination(Path), - // but if no destination is set and the filename is auto-generated, - // the control context of the recording is taken when the - // Recording object is constructed. This works well for - // -XX:StartFlightRecording and JFR.dump - this.dumpDirectoryControlContext = AccessController.getContext(); this.id = id; this.recorder = recorder; this.name = String.valueOf(id); @@ -175,7 +162,7 @@ public boolean stop(String reason) { Logger.log(LogTag.JFR, LogLevel.INFO, "Stopped recording \"" + getName() + "\" (" + getId() + ")" + endText); newState = getState(); } - WriteableUserPath dest = getDestination(); + WriteablePath dest = getDestination(); if (dest == null && dumpDirectory != null) { dest = makeDumpPath(); } @@ -195,30 +182,18 @@ public boolean stop(String reason) { return true; } - @SuppressWarnings("removal") - public WriteableUserPath makeDumpPath() { + public WriteablePath makeDumpPath() { try { String name = JVMSupport.makeFilename(getRecording()); - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public WriteableUserPath run() throws Exception { - SafePath p = dumpDirectory; - if (p == null) { - p = new SafePath("."); - } - return new WriteableUserPath(p.toPath().resolve(name)); - } - }, dumpDirectoryControlContext); - } catch (PrivilegedActionException e) { - Throwable t = e.getCause(); - if (t instanceof SecurityException) { - Logger.log(LogTag.JFR, LogLevel.WARN, "Not allowed to create dump path for recording " + recording.getId() + " on exit."); - } - if (t instanceof IOException) { - Logger.log(LogTag.JFR, LogLevel.WARN, "Could not dump " + recording.getId() + " on exit."); + Path p = dumpDirectory; + if (p == null) { + p = Path.of("."); } - return null; + return new WriteablePath(p.resolve(name)); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not dump " + recording.getId() + " on exit. " + e.getMessage()); } + return null; } @@ -422,14 +397,16 @@ public void setMaxSize(long maxSize) { } } - public void setDestination(WriteableUserPath userSuppliedPath) throws IOException { + public void setDestination(WriteablePath destination) throws IOException { synchronized (recorder) { - checkSetDestination(userSuppliedPath); - this.destination = userSuppliedPath; + checkSetDestination(destination); + this.destination = destination; } } - public void checkSetDestination(WriteableUserPath userSuppliedPath) throws IOException { + public void checkSetDestination(WriteablePath writeablePath) throws IOException { + // The writeablePath argument is not checked. It's sufficient that an instance has + // been created. synchronized (recorder) { if (Utils.isState(getState(), RecordingState.STOPPED, RecordingState.CLOSED)) { throw new IllegalStateException("Destination can't be set on a recording that has been stopped/closed"); @@ -437,7 +414,7 @@ public void checkSetDestination(WriteableUserPath userSuppliedPath) throws IOExc } } - public WriteableUserPath getDestination() { + public WriteablePath getDestination() { synchronized (recorder) { return destination; } @@ -707,8 +684,7 @@ public void run() { try { stop("End of duration reached"); } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR, LogLevel.ERROR, "Could not stop recording."); + Logger.log(LogTag.JFR, LogLevel.ERROR, "Could not stop recording. " + t.getMessage()); } } }; @@ -737,37 +713,34 @@ boolean shouldWriteMetadataEvent() { } // Dump running and stopped recordings - public void dump(WriteableUserPath writeableUserPath) throws IOException { + public void dump(WriteablePath writeablePath) throws IOException { synchronized (recorder) { try(PlatformRecording p = newSnapshotClone("Dumped by user", null)) { - p.dumpStopped(writeableUserPath); + p.dumpStopped(writeablePath); } } } - public void dumpStopped(WriteableUserPath userPath) throws IOException { + public void dumpStopped(WriteablePath path) throws IOException { synchronized (recorder) { - transferChunksWithRetry(userPath); + transferChunksWithRetry(path); } } - private void transferChunksWithRetry(WriteableUserPath userPath) throws IOException { - userPath.doPrivilegedIO(() -> { - try { - transferChunks(userPath); - } catch (NoSuchFileException nsfe) { - Logger.log(LogTag.JFR, LogLevel.ERROR, "Missing chunkfile when writing recording \"" + name + "\" (" + id + ") to " + userPath.getRealPathText() + "."); - // if one chunkfile was missing, its likely more are missing - removeNonExistantPaths(); - // and try the transfer again - transferChunks(userPath); - } - return null; - }); + private void transferChunksWithRetry(WriteablePath path) throws IOException { + try { + transferChunks(path); + } catch (NoSuchFileException nsfe) { + Logger.log(LogTag.JFR, LogLevel.ERROR, "Missing chunkfile when writing recording \"" + name + "\" (" + id + ") to " + path.getRealPathText() + "."); + // if one chunkfile was missing, its likely more are missing + removeNonExistantPaths(); + // and try the transfer again + transferChunks(path); + } } - private void transferChunks(WriteableUserPath userPath) throws IOException { - try (ChunksChannel cc = new ChunksChannel(chunks); FileChannel fc = FileChannel.open(userPath.getReal(), StandardOpenOption.WRITE, StandardOpenOption.APPEND)) { + private void transferChunks(WriteablePath path) throws IOException { + try (ChunksChannel cc = new ChunksChannel(chunks); FileChannel fc = FileChannel.open(path.getReal(), StandardOpenOption.WRITE, StandardOpenOption.APPEND)) { long bytes = cc.transferTo(fc); Logger.log(LogTag.JFR, LogLevel.INFO, "Transferred " + bytes + " bytes from the disk repository"); // No need to force if no data was transferred, which avoids IOException when device is /dev/null @@ -859,7 +832,7 @@ private static List reduceFromEnd(Long maxSize, List * Only to be used by DCmdStart. */ - public void setDumpDirectory(SafePath directory) { + public void setDumpDirectory(Path directory) { this.dumpDirectory = directory; } @@ -913,7 +886,7 @@ public void removeBefore(Instant timestamp) { } - public void removePath(SafePath path) { + public void removePath(Path path) { synchronized (recorder) { Iterator it = chunks.iterator(); while (it.hasNext()) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java index dd28a27884f6f..e9945f71158c0 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 jdk.jfr.internal; -import java.security.AccessControlContext; import java.util.List; import java.util.Map; @@ -35,7 +34,6 @@ import jdk.jfr.EventType; import jdk.jfr.FlightRecorderPermission; import jdk.jfr.Recording; -import jdk.jfr.SettingControl; import jdk.jfr.SettingDescriptor; import jdk.jfr.ValueDescriptor; import jdk.jfr.internal.management.EventSettingsModifier; @@ -60,7 +58,7 @@ public static PrivateAccess getInstance() { // Will trigger // FlightRecorderPermission. // which will call PrivateAccess.setPrivateAccess - new FlightRecorderPermission(SecuritySupport.REGISTER_EVENT); + new FlightRecorderPermission("accessFlightRecorder"); } return instance; } @@ -99,9 +97,6 @@ public static void setPrivateAccess(PrivateAccess pa) { public abstract PlatformRecorder getPlatformRecorder(); - @SuppressWarnings("removal") - public abstract AccessControlContext getContext(SettingControl sc); - public abstract EventSettings newEventSettings(EventSettingsModifier esm); public abstract boolean isVisible(EventType t); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java index ff09d58a9c059..f2cd873790aa7 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * 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 jdk.jfr.internal; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.time.DateTimeException; import java.time.LocalDateTime; @@ -33,20 +34,20 @@ import java.util.HashSet; import java.util.Set; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.management.ChunkFilename; import jdk.jfr.internal.util.ValueFormatter; +import jdk.jfr.internal.util.DirectoryCleaner; +import jdk.jfr.internal.util.Utils; public final class Repository { + private static final Path JAVA_IO_TMPDIR = Utils.getPathInProperty("java.io.tmpdir", null); private static final int MAX_REPO_CREATION_RETRIES = 1000; private static final Repository instance = new Repository(); - private static final String JFR_REPOSITORY_LOCATION_PROPERTY = "jdk.jfr.repository"; - - private final Set cleanupDirectories = new HashSet<>(); - private SafePath baseLocation; - private SafePath repository; + private final Set cleanupDirectories = new HashSet<>(); + private Path baseLocation; + private Path repository; private ChunkFilename chunkFilename; private Repository() { @@ -56,7 +57,7 @@ public static Repository getRepository() { return instance; } - public synchronized void setBasePath(SafePath baseLocation) throws IOException { + public synchronized void setBasePath(Path baseLocation) throws IOException { if(baseLocation.equals(this.baseLocation)) { Logger.log(LogTag.JFR, LogLevel.INFO, "Same base repository path " + baseLocation.toString() + " is set"); return; @@ -68,7 +69,7 @@ public synchronized void setBasePath(SafePath baseLocation) throws IOException { try { // Remove so we don't "leak" repositories, if JFR is never started // and shutdown hook not added. - SecuritySupport.delete(repository); + Files.delete(repository); } catch (IOException ioe) { Logger.log(LogTag.JFR, LogLevel.INFO, "Could not delete disk repository " + repository); } @@ -77,25 +78,25 @@ public synchronized void setBasePath(SafePath baseLocation) throws IOException { public synchronized void ensureRepository() throws IOException { if (baseLocation == null) { - setBasePath(SecuritySupport.JAVA_IO_TMPDIR); + setBasePath(JAVA_IO_TMPDIR); } } synchronized RepositoryChunk newChunk() { LocalDateTime timestamp = timestamp(); try { - if (!SecuritySupport.existDirectory(repository)) { + if (!Files.exists(repository)) { this.repository = createRepository(baseLocation); JVM.setRepositoryLocation(repository.toString()); - SecuritySupport.setProperty(JFR_REPOSITORY_LOCATION_PROPERTY, repository.toString()); + System.setProperty(JFR_REPOSITORY_LOCATION_PROPERTY, repository.toString()); cleanupDirectories.add(repository); chunkFilename = null; } if (chunkFilename == null) { - chunkFilename = ChunkFilename.newPriviliged(repository.toPath()); + chunkFilename = new ChunkFilename(repository); } String filename = chunkFilename.next(timestamp); - return new RepositoryChunk(new SafePath(filename)); + return new RepositoryChunk(Path.of(filename)); } catch (Exception e) { String errorMsg = String.format("Could not create chunk in repository %s, %s: %s", repository, e.getClass(), e.getMessage()); Logger.log(LogTag.JFR, LogLevel.ERROR, errorMsg); @@ -113,16 +114,16 @@ private static LocalDateTime timestamp() { } } - private static SafePath createRepository(SafePath basePath) throws IOException { - SafePath canonicalBaseRepositoryPath = createRealBasePath(basePath); - SafePath f = null; + private static Path createRepository(Path basePath) throws IOException { + Path canonicalBaseRepositoryPath = createRealBasePath(basePath); + Path f = null; String basename = ValueFormatter.formatDateTime(timestamp()) + "_" + JVM.getPid(); String name = basename; int i = 0; for (; i < MAX_REPO_CREATION_RETRIES; i++) { - f = new SafePath(canonicalBaseRepositoryPath.toPath().resolve(name)); + f = canonicalBaseRepositoryPath.resolve(name); if (tryToUseAsRepository(f)) { break; } @@ -132,41 +133,36 @@ private static SafePath createRepository(SafePath basePath) throws IOException { if (i == MAX_REPO_CREATION_RETRIES) { throw new IOException("Unable to create JFR repository directory using base location (" + basePath + ")"); } - return SecuritySupport.toRealPath(f); + return f.toRealPath(); } - private static SafePath createRealBasePath(SafePath safePath) throws IOException { - if (SecuritySupport.exists(safePath)) { - if (!SecuritySupport.isWritable(safePath)) { - throw new IOException("JFR repository directory (" + safePath.toString() + ") exists, but isn't writable"); + private static Path createRealBasePath(Path path) throws IOException { + if (Files.exists(path)) { + if (!Files.isWritable(path)) { + throw new IOException("JFR repository directory (" + path.toString() + ") exists, but isn't writable"); } - return SecuritySupport.toRealPath(safePath); + return path.toRealPath(); } - SafePath p = SecuritySupport.createDirectories(safePath); - return SecuritySupport.toRealPath(p); + return Files.createDirectories(path).toRealPath(); } - private static boolean tryToUseAsRepository(final SafePath path) { - Path parent = path.toPath().getParent(); + private static boolean tryToUseAsRepository(Path path) { + Path parent = path.getParent(); if (parent == null) { return false; } try { - try { - SecuritySupport.createDirectories(path); - } catch (Exception e) { - // file already existed or some other problem occurred - } - if (!SecuritySupport.exists(path)) { - return false; - } - if (!SecuritySupport.isDirectory(path)) { - return false; - } - return true; - } catch (IOException io) { + Files.createDirectories(path); + } catch (Exception e) { + // file already existed or some other problem occurred + } + if (!Files.exists(path)) { + return false; + } + if (!Files.isDirectory(path)) { return false; } + return true; } synchronized void clear() { @@ -174,9 +170,9 @@ synchronized void clear() { return; } - for (SafePath p : cleanupDirectories) { + for (Path p : cleanupDirectories) { try { - SecuritySupport.clearDirectory(p); + DirectoryCleaner.clear(p); Logger.log(LogTag.JFR, LogLevel.INFO, "Removed repository " + p); } catch (IOException e) { Logger.log(LogTag.JFR, LogLevel.INFO, "Repository " + p + " could not be removed at shutdown: " + e.getMessage()); @@ -184,11 +180,11 @@ synchronized void clear() { } } - public synchronized SafePath getRepositoryPath() { + public synchronized Path getRepositoryPath() { return repository; } - public synchronized SafePath getBaseLocation() { + public synchronized Path getBaseLocation() { return baseLocation; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java index e46b6020d5dbd..6507c5f666854 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +27,14 @@ import java.io.IOException; import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; import java.time.Instant; import java.util.Comparator; -import jdk.jfr.internal.SecuritySupport.SafePath; - public final class RepositoryChunk { static final Comparator END_TIME_COMPARATOR = new Comparator() { @@ -42,7 +44,7 @@ public int compare(RepositoryChunk c1, RepositoryChunk c2) { } }; - private final SafePath chunkFile; + private final Path chunkFile; private final RandomAccessFile unFinishedRAF; private Instant endTime = null; // unfinished @@ -50,15 +52,15 @@ public int compare(RepositoryChunk c1, RepositoryChunk c2) { private int refCount = 1; private long size; - RepositoryChunk(SafePath path) throws Exception { + RepositoryChunk(Path path) throws Exception { this.chunkFile = path; - this.unFinishedRAF = SecuritySupport.createRandomAccessFile(chunkFile); + this.unFinishedRAF = new RandomAccessFile(path.toFile(), "rw"); } boolean finish(Instant endTime) { try { unFinishedRAF.close(); - size = SecuritySupport.getFileSize(chunkFile); + size = Files.size(chunkFile); this.endTime = endTime; if (Logger.shouldLog(LogTag.JFR_SYSTEM, LogLevel.DEBUG)) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, "Chunk finished: " + chunkFile); @@ -89,9 +91,9 @@ public Instant getEndTime() { return endTime; } - private void delete(SafePath f) { + private void delete(Path f) { try { - SecuritySupport.delete(f); + Files.delete(f); if (Logger.shouldLog(LogTag.JFR, LogLevel.DEBUG)) { Logger.log(LogTag.JFR, LogLevel.DEBUG, "Repository chunk " + f + " deleted"); } @@ -153,7 +155,7 @@ ReadableByteChannel newChannel() throws IOException { if (!isFinished()) { throw new IOException("Chunk not finished"); } - return ((SecuritySupport.newFileChannelToRead(chunkFile))); + return FileChannel.open(chunkFile, StandardOpenOption.READ); } public boolean inInterval(Instant startTime, Instant endTime) { @@ -166,23 +168,19 @@ public boolean inInterval(Instant startTime, Instant endTime) { return true; } - public SafePath getFile() { + public Path getFile() { return chunkFile; } public long getCurrentFileSize() { try { - return SecuritySupport.getFileSize(chunkFile); + return Files.size(chunkFile); } catch (IOException e) { return 0L; } } boolean isMissingFile() { - try { - return !SecuritySupport.exists(chunkFile); - } catch (IOException ioe) { - return true; - } + return !Files.exists(chunkFile); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java index 7398b6a91b7ad..98bc0c86bfaf5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,63 +25,13 @@ package jdk.jfr.internal; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.io.Reader; import java.lang.invoke.MethodHandles; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.ReflectPermission; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.file.DirectoryStream; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.StandardOpenOption; -import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.FileTime; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.Permission; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.PropertyPermission; -import java.util.concurrent.Callable; - import jdk.internal.module.Modules; import jdk.jfr.Event; -import jdk.jfr.FlightRecorder; -import jdk.jfr.FlightRecorderListener; -import jdk.jfr.FlightRecorderPermission; -import jdk.jfr.Recording; -import jdk.jfr.internal.consumer.FileAccess; -/** - * Contains JFR code that does - * {@link AccessController#doPrivileged(PrivilegedAction)} - */ public final class SecuritySupport { - private static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events"; - private static final String EVENT_PACKAGE_NAME = "jdk.jfr.internal.event"; - - public static final String REGISTER_EVENT = "registerEvent"; - public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder"; - private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); private static final Module JFR_MODULE = Event.class.getModule(); - public static final SafePath JFC_DIRECTORY = getPathInProperty("java.home", "lib/jfr"); - public static final FileAccess PRIVILEGED = new Privileged(); - static final SafePath JAVA_IO_TMPDIR = getPathInProperty("java.io.tmpdir", null); + private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); static { // ensure module java.base can read module jdk.jfr as early as possible @@ -90,215 +40,6 @@ public final class SecuritySupport { addEventsExport(Object.class); } - static final class SecureRecorderListener implements FlightRecorderListener { - - @SuppressWarnings("removal") - private final AccessControlContext context; - private final FlightRecorderListener changeListener; - - SecureRecorderListener(@SuppressWarnings("removal") AccessControlContext context, FlightRecorderListener changeListener) { - this.context = Objects.requireNonNull(context); - this.changeListener = Objects.requireNonNull(changeListener); - } - - @SuppressWarnings("removal") - @Override - public void recordingStateChanged(Recording recording) { - AccessController.doPrivileged((PrivilegedAction) () -> { - try { - changeListener.recordingStateChanged(recording); - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR, LogLevel.WARN, "Unexpected exception in listener " + changeListener.getClass()+ " at recording state change"); - } - return null; - }, context); - } - - @SuppressWarnings("removal") - @Override - public void recorderInitialized(FlightRecorder recorder) { - AccessController.doPrivileged((PrivilegedAction) () -> { - try { - changeListener.recorderInitialized(recorder); - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR, LogLevel.WARN, "Unexpected exception in listener " + changeListener.getClass()+ " when initializing FlightRecorder"); - } - return null; - }, context); - } - - public FlightRecorderListener getChangeListener() { - return changeListener; - } - } - - private static final class DirectoryCleaner extends SimpleFileVisitor { - @Override - public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { - Files.delete(path); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - if (exc != null) { - throw exc; - } - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - } - - /** - * Path created by the default file provider, and not - * a malicious provider. - * - */ - public static final class SafePath implements Comparable { - private final Path path; - private final String text; - - public SafePath(Path p) { - // sanitize - text = p.toString(); - path = Paths.get(text); - } - - public SafePath(String path) { - this(Paths.get(path)); - } - - public Path toPath() { - return path; - } - - public File toFile() { - return path.toFile(); - } - - @Override - public String toString() { - return text; - } - - @Override - public int compareTo(SafePath that) { - return that.text.compareTo(this.text); - } - - @Override - public boolean equals(Object other) { - if(other != null && other instanceof SafePath s){ - return this.toPath().equals(s.toPath()); - } - return false; - } - - @Override - public int hashCode() { - return this.toPath().hashCode(); - } - } - - private interface RunnableWithCheckedException { - public void run() throws Exception; - } - - private interface CallableWithoutCheckException { - public T call(); - } - - public static void checkAccessFlightRecorder() throws SecurityException { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new FlightRecorderPermission(ACCESS_FLIGHT_RECORDER)); - } - } - - public static void checkRegisterPermission() throws SecurityException { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new FlightRecorderPermission(REGISTER_EVENT)); - } - } - - @SuppressWarnings("removal") - private static U doPrivilegedIOWithReturn(Callable function) throws IOException { - try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public U run() throws Exception { - return function.call(); - } - }, null); - } catch (PrivilegedActionException e) { - Throwable t = e.getCause(); - if (t instanceof IOException) { - throw (IOException) t; - } - throw new IOException("Unexpected error during I/O operation. " + t.getMessage(), t); - } - } - - private static void doPriviligedIO(RunnableWithCheckedException function) throws IOException { - doPrivilegedIOWithReturn(() -> { - function.run(); - return null; - }); - } - - @SuppressWarnings("removal") - private static void doPrivileged(Runnable function, Permission... perms) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - function.run(); - return null; - } - }, null, perms); - } - - @SuppressWarnings("removal") - private static void doPrivileged(Runnable function) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - function.run(); - return null; - } - }); - } - - @SuppressWarnings("removal") - private static T doPrivilegedWithReturn(CallableWithoutCheckException function, Permission... perms) { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public T run() { - return function.call(); - } - }, null, perms); - } - - public static List getPredefinedJFCFiles() { - List list = new ArrayList<>(); - try (var ds = doPrivilegedIOWithReturn(() -> Files.newDirectoryStream(JFC_DIRECTORY.toPath()))) { - for (Path path : ds) { - SafePath s = new SafePath(path); - String text = s.toString(); - if (text.endsWith(".jfc") && !SecuritySupport.isDirectory(s)) { - list.add(s); - } - } - } catch (IOException ioe) { - Logger.log(LogTag.JFR, LogLevel.WARN, "Could not access .jfc-files in " + JFC_DIRECTORY + ", " + ioe.getMessage()); - } - return list; - } - static void makeVisibleToJFR(Class clazz) { Module classModule = clazz.getModule(); Modules.addReads(JFR_MODULE, classModule); @@ -314,213 +55,31 @@ static void makeVisibleToJFR(Class clazz) { * (for EventConfiguration and EventWriter) */ static void addInternalEventExport(Class clazz) { - Modules.addExports(JFR_MODULE, EVENT_PACKAGE_NAME, clazz.getModule()); + Modules.addExports(JFR_MODULE, "jdk.jfr.internal.event", clazz.getModule()); } static void addEventsExport(Class clazz) { - Modules.addExports(JFR_MODULE, EVENTS_PACKAGE_NAME, clazz.getModule()); + Modules.addExports(JFR_MODULE, "jdk.jfr.events", clazz.getModule()); } static void addReadEdge(Class clazz) { Modules.addReads(clazz.getModule(), JFR_MODULE); } - public static void registerEvent(Class eventClass) { - doPrivileged(() -> MetadataRepository.getInstance().register(eventClass), new FlightRecorderPermission(REGISTER_EVENT)); - } - - public static void setProperty(String propertyName, String value) { - doPrivileged(() -> System.setProperty(propertyName, value), new PropertyPermission(propertyName, "write")); - } - - static boolean getBooleanProperty(String propertyName) { - return doPrivilegedWithReturn(() -> Boolean.getBoolean(propertyName), new PropertyPermission(propertyName, "read")); - } - - private static SafePath getPathInProperty(String prop, String subPath) { - return doPrivilegedWithReturn(() -> { - String path = System.getProperty(prop); - if (path == null) { - return null; - } - File file = subPath == null ? new File(path) : new File(path, subPath); - return new SafePath(file.getAbsolutePath()); - }, new PropertyPermission("*", "read")); - } - - // Called by JVM during initialization of JFR - static Thread createRecorderThread(ThreadGroup systemThreadGroup, ClassLoader contextClassLoader) { - // The thread should have permission = new Permission[0], and not "modifyThreadGroup" and "modifyThread" on the stack, - // but it's hard circumvent if we are going to pass in system thread group in the constructor - Thread thread = doPrivilegedWithReturn(() -> new Thread(systemThreadGroup, "JFR Recorder Thread"), new RuntimePermission("modifyThreadGroup"), new RuntimePermission("modifyThread")); - doPrivileged(() -> thread.setContextClassLoader(contextClassLoader), new RuntimePermission("setContextClassLoader"), new RuntimePermission("modifyThread")); - return thread; - } - - static void registerShutdownHook(Thread shutdownHook) { - doPrivileged(() -> Runtime.getRuntime().addShutdownHook(shutdownHook), new RuntimePermission("shutdownHooks")); - } - - static void setUncaughtExceptionHandler(Thread thread, Thread.UncaughtExceptionHandler eh) { - doPrivileged(() -> thread.setUncaughtExceptionHandler(eh), new RuntimePermission("modifyThread")); - } - - static void clearDirectory(SafePath safePath) throws IOException { - doPriviligedIO(() -> Files.walkFileTree(safePath.toPath(), new DirectoryCleaner())); - } - - static SafePath toRealPath(SafePath safePath, LinkOption... options) throws IOException { - return new SafePath(doPrivilegedIOWithReturn(() -> safePath.toPath().toRealPath(options))); - } - - static boolean existDirectory(SafePath directory) throws IOException { - return doPrivilegedIOWithReturn(() -> Files.exists(directory.toPath())); - } - - static RandomAccessFile createRandomAccessFile(SafePath path) throws Exception { - return doPrivilegedIOWithReturn(() -> new RandomAccessFile(path.toPath().toFile(), "rw")); - } - - public static InputStream newFileInputStream(SafePath safePath) throws IOException { - return doPrivilegedIOWithReturn(() -> Files.newInputStream(safePath.toPath())); - } - - public static long getFileSize(SafePath safePath) throws IOException { - return doPrivilegedIOWithReturn(() -> Files.size(safePath.toPath())); - } - - static SafePath createDirectories(SafePath safePath) throws IOException { - Path p = doPrivilegedIOWithReturn(() -> Files.createDirectories(safePath.toPath())); - return new SafePath(p); - } - - public static boolean exists(SafePath safePath) throws IOException { - // Files.exist(path) is allocation intensive - return doPrivilegedIOWithReturn(() -> safePath.toPath().toFile().exists()); - } - - public static boolean isDirectory(SafePath safePath) throws IOException { - return doPrivilegedIOWithReturn(() -> Files.isDirectory(safePath.toPath())); - } - - static void delete(SafePath localPath) throws IOException { - doPriviligedIO(() -> Files.delete(localPath.toPath())); - } - - static boolean isWritable(SafePath safePath) throws IOException { - return doPrivilegedIOWithReturn(() -> Files.isWritable(safePath.toPath())); - } - - static ReadableByteChannel newFileChannelToRead(SafePath safePath) throws IOException { - return doPrivilegedIOWithReturn(() -> FileChannel.open(safePath.toPath(), StandardOpenOption.READ)); - } - - public static InputStream getResourceAsStream(String name) throws IOException { - return doPrivilegedIOWithReturn(() -> SecuritySupport.class.getResourceAsStream(name)); - } - - public static Reader newFileReader(SafePath safePath) throws FileNotFoundException, IOException { - return doPrivilegedIOWithReturn(() -> Files.newBufferedReader(safePath.toPath())); - } - - static void setAccessible(Method method) { - doPrivileged(() -> method.setAccessible(true), new ReflectPermission("suppressAccessChecks")); - } - - static void setAccessible(Constructor constructor) { - doPrivileged(() -> constructor.setAccessible(true), new ReflectPermission("suppressAccessChecks")); - } - - @SuppressWarnings("removal") public static void ensureClassIsInitialized(Class clazz) { try { - MethodHandles.Lookup lookup; - if (System.getSecurityManager() == null) { - lookup = MethodHandles.privateLookupIn(clazz, LOOKUP); - } else { - lookup = AccessController.doPrivileged(new PrivilegedExceptionAction<>() { - @Override - public MethodHandles.Lookup run() throws IllegalAccessException { - return MethodHandles.privateLookupIn(clazz, LOOKUP); - } - }, null, new ReflectPermission("suppressAccessChecks")); - } + MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(clazz, LOOKUP); lookup.ensureInitialized(clazz); } catch (IllegalAccessException e) { throw new InternalError(e); - } catch (PrivilegedActionException e) { - throw new InternalError(e.getCause()); } } - @SuppressWarnings("removal") static Class defineClass(Class lookupClass, byte[] bytes) { - return AccessController.doPrivileged(new PrivilegedAction>() { - @Override - public Class run() { - try { - return MethodHandles.privateLookupIn(lookupClass, LOOKUP).defineClass(bytes); - } catch (IllegalAccessException e) { - throw new InternalError(e); - } - } - }); - } - - public static Thread createThreadWitNoPermissions(String threadName, Runnable runnable) { - return doPrivilegedWithReturn(() -> new Thread(runnable, threadName), new Permission[0]); - } - - public static void setDaemonThread(Thread t, boolean daemon) { - doPrivileged(()-> t.setDaemon(daemon), new RuntimePermission("modifyThread")); - } - - public static SafePath getAbsolutePath(SafePath path) throws IOException { - return new SafePath(doPrivilegedIOWithReturn((()-> path.toPath().toAbsolutePath()))); - } - - private static final class Privileged extends FileAccess { - @Override - public RandomAccessFile openRAF(File f, String mode) throws IOException { - return doPrivilegedIOWithReturn( () -> new RandomAccessFile(f, mode)); - } - - @Override - public DirectoryStream newDirectoryStream(Path directory) throws IOException { - return doPrivilegedIOWithReturn( () -> Files.newDirectoryStream(directory)); - } - - @Override - public String getAbsolutePath(File f) throws IOException { - return doPrivilegedIOWithReturn( () -> f.getAbsolutePath()); - } - @Override - public long length(File f) throws IOException { - return doPrivilegedIOWithReturn( () -> f.length()); - } - - @Override - public long fileSize(Path p) throws IOException { - return doPrivilegedIOWithReturn( () -> Files.size(p)); - } - - @Override - public boolean exists(Path p) throws IOException { - return doPrivilegedIOWithReturn( () -> Files.exists(p)); - } - - @Override - public boolean isDirectory(Path p) { - return doPrivilegedWithReturn( () -> Files.isDirectory(p)); - } - - @Override - public FileTime getLastModified(Path p) throws IOException { - // Timestamp only needed when examining repository for other JVMs, - // in which case an unprivileged mode should be used. - throw new InternalError("Should not reach here"); + try { + return MethodHandles.privateLookupIn(lookupClass, LOOKUP).defineClass(bytes); + } catch (IllegalAccessException e) { + throw new InternalError(e); } } - - } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java index 8375dab0bcce3..ef9e5d53bf951 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/ShutdownHook.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,22 +25,18 @@ package jdk.jfr.internal; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - import jdk.jfr.RecordingState; /** * Class responsible for dumping recordings on exit * */ -final class ShutdownHook implements Runnable { +final class ShutdownHook extends Thread { private final PlatformRecorder recorder; Object tlabDummyObject; ShutdownHook(PlatformRecorder recorder) { + super("JFR Shutdown Hook"); this.recorder = recorder; } @@ -61,7 +57,7 @@ public void run() { private void dump(PlatformRecording recording) { try { - WriteableUserPath dest = recording.getDestination(); + WriteablePath dest = recording.getDestination(); if (dest == null) { dest = recording.makeDumpPath(); recording.setDestination(dest); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java index 350bf55ccd4ee..bf26294ef579b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -189,7 +189,7 @@ private static Object invokeAnnotation(Annotation annotation, String methodName) Modules.addExports(proxyModule, proxyPackage, jfrModule); } } - SecuritySupport.setAccessible(m); + m.setAccessible(true); try { return m.invoke(annotation, new Object[0]); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JDKEventTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/WriteablePath.java similarity index 52% rename from src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JDKEventTask.java rename to src/jdk.jfr/share/classes/jdk/jfr/internal/WriteablePath.java index a891b1c3775c1..5f3672d5d4cc5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JDKEventTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/WriteablePath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,34 +22,42 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.jfr.internal.periodic; -import jdk.internal.event.Event; -import jdk.jfr.internal.util.Utils; +package jdk.jfr.internal; -/** - * Periodic task that runs trusted code that doesn't require an access control - * context. - *

- * This class can be removed once the Security Manager is no longer supported. - */ -final class JDKEventTask extends JavaEventTask { +import java.io.BufferedWriter; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; - public JDKEventTask(Class eventClass, Runnable runnable) { - super(eventClass, runnable); - if (!getEventType().isJDK()) { - throw new InternalError("Must be a JDK event"); - } - if (!Utils.isJDKClass(eventClass)) { - throw new SecurityException("Periodic task can only be registered for event classes that belongs to the JDK"); - } - if (!Utils.isJDKClass(runnable.getClass())) { - throw new SecurityException("Runnable class must belong to the JDK"); +public final class WriteablePath { + private final Path path; + private final Path real; + + public WriteablePath(Path path) throws IOException { + // verify that the path is writeable + if (Files.exists(path) && !Files.isWritable(path)) { + // throw same type of exception as FileOutputStream + // constructor, if file can't be opened. + throw new FileNotFoundException("Could not write to file: " + path.toAbsolutePath()); } + // will throw if non-writeable + BufferedWriter fw = Files.newBufferedWriter(path); + fw.close(); + this.path = path; + this.real = path.toRealPath(); + } + + public Path getPath() { + return path; + } + + public Path getReal() { + return real; } - @Override - public void execute(long timestamp, PeriodicType periodicType) { - getRunnable().run(); + public String getRealPathText() { + return real.toString(); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/WriteableUserPath.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/WriteableUserPath.java deleted file mode 100644 index b53ff48d606c0..0000000000000 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/WriteableUserPath.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jfr.internal; - -import java.io.BufferedWriter; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.util.concurrent.Callable; - -/** - * Purpose of this class is to simplify analysis of security risks. - *

- * Paths in the public API should be wrapped in this class so we - * at all time know what kind of paths we are dealing with. - *

- * A user supplied path must never be used in an unsafe context, such as a - * shutdown hook or any other thread created by JFR. - *

- * All operation using this path must happen in {@link #doPrivilegedIO(Callable)} - */ -public final class WriteableUserPath { - @SuppressWarnings("removal") - private final AccessControlContext controlContext; - private final Path original; - private final Path real; - private final String realPathText; - private final String originalText; - - // Not to ensure security, but to help - // against programming errors - private volatile boolean inPrivileged; - - @SuppressWarnings("removal") - public WriteableUserPath(Path path) throws IOException { - controlContext = AccessController.getContext(); - // verify that the path is writeable - if (Files.exists(path) && !Files.isWritable(path)) { - // throw same type of exception as FileOutputStream - // constructor, if file can't be opened. - throw new FileNotFoundException("Could not write to file: " + path.toAbsolutePath()); - } - // will throw if non-writeable - BufferedWriter fw = Files.newBufferedWriter(path); - fw.close(); - this.original = path; - this.originalText = path.toString(); - this.real = path.toRealPath(); - this.realPathText = real.toString(); - } - - /** - * Returns a potentially malicious path where the user may have implemented - * their own version of Path. This method should never be called in an - * unsafe context and the Path value should never be passed along to other - * methods. - * - * @return path from a potentially malicious user - */ - public Path getPotentiallyMaliciousOriginal() { - return original; - } - - /** - * Returns a string representation of the real path. - * - * @return path as text - */ - public String getRealPathText() { - return realPathText; - } - - /** - * Returns a string representation of the original path. - * - * @return path as text - */ - public String getOriginalText() { - return originalText; - } - - - /** - * Returns a potentially malicious path where the user may have implemented - * their own version of Path. This method should never be called in an - * unsafe context and the Path value should never be passed along to other - * methods. - * - * @return path from a potentially malicious user - */ - public Path getReal() { - if (!inPrivileged) { - throw new InternalError("A user path was accessed outside the context it was supplied in"); - } - return real; - } - - @SuppressWarnings("removal") - public void doPrivilegedIO(Callable function) throws IOException { - try { - inPrivileged = true; - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Void run() throws Exception { - function.call(); - return null; - } - }, controlContext); - } catch (Throwable t) { - // prevent malicious user to propagate exception callback - // in the wrong context - Throwable cause = null; - if (System.getSecurityManager() == null) { - cause = t; - } - throw new IOException("Unexpected error during I/O operation", cause); - } finally { - inPrivileged = false; - } - } -} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java index cdfc8f017a657..b9994c1e51cbe 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +26,6 @@ package jdk.jfr.internal.consumer; import java.io.IOException; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.time.Duration; import java.time.Instant; import java.util.List; @@ -46,7 +43,6 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; -import jdk.jfr.internal.SecuritySupport; /* * Purpose of this class is to simplify the implementation of @@ -57,8 +53,6 @@ public abstract class AbstractEventStream implements EventStream { private final CountDownLatch terminated = new CountDownLatch(1); private final Runnable flushOperation = () -> dispatcher().runFlushActions(); - @SuppressWarnings("removal") - private final AccessControlContext accessControllerContext; private final StreamConfiguration streamConfiguration = new StreamConfiguration(); private final List configurations; private final ParserState parserState = new ParserState(); @@ -67,8 +61,7 @@ public abstract class AbstractEventStream implements EventStream { private boolean daemon = false; - AbstractEventStream(@SuppressWarnings("removal") AccessControlContext acc, List configurations) throws IOException { - this.accessControllerContext = Objects.requireNonNull(acc); + AbstractEventStream(List configurations) throws IOException { this.configurations = configurations; } @@ -221,22 +214,21 @@ protected final ParserState parserState() { public final void startAsync(long startNanos) { startInternal(startNanos); - Runnable r = () -> run(accessControllerContext); - Thread thread = SecuritySupport.createThreadWitNoPermissions(nextThreadName(), r); - SecuritySupport.setDaemonThread(thread, daemon); + Runnable r = () -> execute(); + Thread thread = new Thread(r, nextThreadName()); + thread.setDaemon(daemon); thread.start(); } public final void start(long startNanos) { startInternal(startNanos); - run(accessControllerContext); + execute(); } protected final Runnable getFlushOperation() { return flushOperation; } - protected final void onFlush() { Runnable r = getFlushOperation(); if (r != null) { @@ -276,17 +268,6 @@ private void execute() { } } - @SuppressWarnings("removal") - private void run(AccessControlContext accessControlContext) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - execute(); - return null; - } - }, accessControlContext); - } - private String nextThreadName() { return "JFR Event Stream " + counter.incrementAndGet(); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java index bc9aa7987c3b5..8560efb9347a7 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +27,10 @@ import java.io.IOException; import java.nio.file.Path; -import java.security.AccessControlContext; import java.time.Instant; import java.util.Arrays; import java.util.Comparator; import java.util.List; -import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; @@ -44,7 +42,6 @@ import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; import jdk.jfr.internal.PlatformRecording; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.util.Utils; import jdk.jfr.internal.management.StreamBarrier; @@ -58,7 +55,6 @@ public final class EventDirectoryStream extends AbstractEventStream { private static final Comparator EVENT_COMPARATOR = JdkJfrConsumer.instance().eventComparator(); private final RepositoryFiles repositoryFiles; - private final FileAccess fileAccess; private final PlatformRecording recording; private final StreamBarrier barrier = new StreamBarrier(); private final AtomicLong streamId = new AtomicLong(); @@ -69,20 +65,13 @@ public final class EventDirectoryStream extends AbstractEventStream { private volatile Consumer onCompleteHandler; public EventDirectoryStream( - @SuppressWarnings("removal") - AccessControlContext acc, Path p, - FileAccess fileAccess, PlatformRecording recording, List configurations, boolean allowSubDirectories) throws IOException { - super(acc, configurations); + super(configurations); this.recording = recording; - if (p != null && SecuritySupport.PRIVILEGED == fileAccess) { - throw new SecurityException("Priviliged file access not allowed with potentially malicious Path implementation"); - } - this.fileAccess = Objects.requireNonNull(fileAccess); - this.repositoryFiles = new RepositoryFiles(fileAccess, p, allowSubDirectories); + this.repositoryFiles = new RepositoryFiles(p, allowSubDirectories); this.streamId.incrementAndGet(); Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Stream " + streamId + " started."); } @@ -153,7 +142,7 @@ protected void processRecursionSafe() throws IOException { return; } currentChunkStartNanos = repositoryFiles.getTimestamp(path); - try (RecordingInput input = new RecordingInput(path.toFile(), fileAccess)) { + try (RecordingInput input = new RecordingInput(path.toFile())) { input.setStreamed(); currentParser = new ChunkParser(input, disp.parserConfiguration, parserState()); long segmentStart = currentParser.getStartNanos() + currentParser.getChunkDuration(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java index f03e8d8acb48e..56d9fe01d790c 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +27,6 @@ import java.io.IOException; import java.nio.file.Path; -import java.security.AccessControlContext; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -45,9 +44,9 @@ public final class EventFileStream extends AbstractEventStream { private ChunkParser currentParser; private RecordedEvent[] cacheSorted; - public EventFileStream(@SuppressWarnings("removal") AccessControlContext acc, Path file) throws IOException { - super(acc, Collections.emptyList()); - this.input = new RecordingInput(file.toFile(), FileAccess.UNPRIVILEGED); + public EventFileStream(Path file) throws IOException { + super(Collections.emptyList()); + this.input = new RecordingInput(file.toFile()); this.input.setStreamed(); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java deleted file mode 100644 index 74a783b0d19b4..0000000000000 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package jdk.jfr.internal.consumer; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.FileTime; - -// Protected by modular boundaries. -public abstract class FileAccess { - public static final FileAccess UNPRIVILEGED = new UnPrivileged(); - - public abstract RandomAccessFile openRAF(File f, String mode) throws IOException; - - public abstract DirectoryStream newDirectoryStream(Path repository) throws IOException; - - public abstract String getAbsolutePath(File f) throws IOException; - - public abstract long length(File f) throws IOException; - - public abstract long fileSize(Path p) throws IOException; - - public abstract boolean exists(Path s) throws IOException; - - public abstract boolean isDirectory(Path p); - - public abstract FileTime getLastModified(Path p) throws IOException; - - private static class UnPrivileged extends FileAccess { - @Override - public RandomAccessFile openRAF(File f, String mode) throws IOException { - return new RandomAccessFile(f, mode); - } - - @Override - public DirectoryStream newDirectoryStream(Path dir) throws IOException { - return Files.newDirectoryStream(dir); - } - - @Override - public String getAbsolutePath(File f) throws IOException { - return f.getAbsolutePath(); - } - - @Override - public long length(File f) throws IOException { - return f.length(); - } - - @Override - public long fileSize(Path p) throws IOException { - return Files.size(p); - } - - @Override - public boolean exists(Path p) { - return Files.exists(p); - } - - @Override - public boolean isDirectory(Path p) { - return Files.isDirectory(p); - } - - @Override - public FileTime getLastModified(Path p) throws IOException { - return Files.getLastModifiedTime(p); - } - } -} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java index e0dd7fa2ad8d5..83d8b8c5f17d5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +26,12 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.file.Files; import java.nio.file.Path; import jdk.jfr.Recording; import jdk.jfr.RecordingState; import jdk.jfr.internal.SecuritySupport; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.management.EventByteStream; import jdk.jfr.internal.management.HiddenWait; import jdk.jfr.internal.management.ManagementSupport; @@ -63,7 +63,7 @@ public OngoingStream(Recording recording, int blockSize, long startTimeNanos, lo this.blockSize = blockSize; this.startTimeNanos = startTimeNanos; this.endTimeNanos = endTimeNanos; - this.repositoryFiles = new RepositoryFiles(SecuritySupport.PRIVILEGED, null, false); + this.repositoryFiles = new RepositoryFiles(null, false); } @Override @@ -206,10 +206,10 @@ private byte[] readWithHeader(int size) throws IOException { private boolean ensureInput() throws IOException { if (input == null) { - if (SecuritySupport.getFileSize(new SafePath(path)) < HEADER_SIZE) { + if (Files.size(path) < HEADER_SIZE) { return false; } - input = new RecordingInput(path.toFile(), SecuritySupport.PRIVILEGED); + input = new RecordingInput(path.toFile()); input.setStreamed(); header = new ChunkHeader(input); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java index 69ec73f57fd6f..33cb928bbbfd7 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.nio.file.Path; import jdk.jfr.internal.management.HiddenWait; -import jdk.jfr.internal.util.Utils; public final class RecordingInput implements DataInput, AutoCloseable { @@ -68,7 +67,6 @@ public void reset() { } } private final int blockSize; - private final FileAccess fileAccess; private final HiddenWait threadSleeper = new HiddenWait(); private long pollCount = 1000; private RandomAccessFile file; @@ -79,26 +77,25 @@ public void reset() { private long size = -1; // Fail fast if setSize(...) has not been called // before parsing - RecordingInput(File f, FileAccess fileAccess, int blockSize) throws IOException { + RecordingInput(File f, int blockSize) throws IOException { this.blockSize = blockSize; - this.fileAccess = fileAccess; initialize(f); } private void initialize(File f) throws IOException { - this.filename = fileAccess.getAbsolutePath(f); - this.file = fileAccess.openRAF(f, "r"); + this.filename = f.getAbsolutePath(); + this.file = new RandomAccessFile(f, "r"); this.position = 0; this.size = -1; this.currentBlock.reset(); previousBlock.reset(); - if (fileAccess.length(f) < 8) { - throw new IOException("Not a valid Flight Recorder file. File length is only " + fileAccess.length(f) + " bytes."); + if (f.length() < 8) { + throw new IOException("Not a valid Flight Recorder file. File length is only " + f.length() + " bytes."); } } - public RecordingInput(File f, FileAccess fileAccess) throws IOException { - this(f, fileAccess, DEFAULT_BLOCK_SIZE); + public RecordingInput(File f) throws IOException { + this(f, DEFAULT_BLOCK_SIZE); } void positionPhysical(long position) throws IOException { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java index 2cf56c67cb558..09b64efbdd0ef 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ import java.io.IOException; import java.nio.file.DirectoryIteratorException; import java.nio.file.DirectoryStream; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.util.ArrayList; @@ -45,7 +46,6 @@ import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; import jdk.jfr.internal.Repository; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.management.HiddenWait;; public final class RepositoryFiles { @@ -57,7 +57,6 @@ public static void notifyNewFile() { } } - private final FileAccess fileAccess; private final NavigableMap pathSet = new TreeMap<>(); private final Map pathLookup = new HashMap<>(); private final HiddenWait waitObject; @@ -65,9 +64,8 @@ public static void notifyNewFile() { private volatile boolean closed; private Path repository; - public RepositoryFiles(FileAccess fileAccess, Path repository, boolean allowSubDirectory) { + public RepositoryFiles(Path repository, boolean allowSubDirectory) { this.repository = repository; - this.fileAccess = fileAccess; this.waitObject = repository == null ? WAIT_OBJECT : new HiddenWait(); this.allowSubDirectory = allowSubDirectory; } @@ -172,14 +170,14 @@ private boolean updatePaths() throws IOException, DirectoryIteratorException { if (repoPath == null) { // Always get the latest repository if 'jcmd JFR.configure // repositorypath=...' has been executed - SafePath sf = Repository.getRepository().getRepositoryPath(); - if (sf == null) { + Path path = Repository.getRepository().getRepositoryPath(); + if (path == null) { return false; // not initialized } - repoPath = sf.toPath(); + repoPath = path; } - try (DirectoryStream dirStream = fileAccess.newDirectoryStream(repoPath)) { + try (DirectoryStream dirStream = Files.newDirectoryStream(repoPath)) { List added = new ArrayList<>(); Set current = new HashSet<>(); for (Path p : dirStream) { @@ -208,7 +206,7 @@ private boolean updatePaths() throws IOException, DirectoryIteratorException { for (Path p : added) { // Only add files that have a complete header // as the JVM may be in progress writing the file - long size = fileAccess.fileSize(p); + long size = Files.size(p); if (size >= ChunkHeader.headerSize()) { long startNanos = readStartTime(p); if (startNanos != -1) { @@ -232,10 +230,10 @@ private boolean updatePaths() throws IOException, DirectoryIteratorException { private Path findSubDirectory(Path repoPath) { FileTime latestTimestamp = null; Path latestPath = null; - try (DirectoryStream dirStream = fileAccess.newDirectoryStream(repoPath)) { + try (DirectoryStream dirStream = Files.newDirectoryStream(repoPath)) { for (Path p : dirStream) { String filename = p.getFileName().toString(); - if (isRepository(filename) && fileAccess.isDirectory(p)) { + if (isRepository(filename) && Files.isDirectory(p)) { FileTime timestamp = getLastModified(p); if (timestamp != null) { if (latestPath == null || latestTimestamp.compareTo(timestamp) <= 0) { @@ -253,7 +251,7 @@ private Path findSubDirectory(Path repoPath) { private FileTime getLastModified(Path p) { try { - return fileAccess.getLastModified(p); + return Files.getLastModifiedTime(p); } catch (IOException e) { return null; } @@ -277,7 +275,7 @@ private static boolean isRepository(String filename) { } private long readStartTime(Path p) { - try (RecordingInput in = new RecordingInput(p.toFile(), fileAccess, 100)) { + try (RecordingInput in = new RecordingInput(p.toFile(), 100)) { Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Parsing header for chunk start time"); ChunkHeader c = new ChunkHeader(in); return c.getStartNanos(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/filter/ChunkWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/filter/ChunkWriter.java index d38a5872adedb..5e3940e7d11d1 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/filter/ChunkWriter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/filter/ChunkWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ import jdk.jfr.internal.LongMap; import jdk.jfr.internal.Type; import jdk.jfr.internal.consumer.ChunkHeader; -import jdk.jfr.internal.consumer.FileAccess; import jdk.jfr.internal.Logger; import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; @@ -67,7 +66,7 @@ public final class ChunkWriter implements Closeable { public ChunkWriter(Path source, Path destination, Predicate filter) throws IOException { this.destination = destination; this.output = new RecordingOutput(destination.toFile()); - this.input = new RecordingInput(source.toFile(), FileAccess.UNPRIVILEGED); + this.input = new RecordingInput(source.toFile()); this.filter = filter; } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java index 516d094b5daa8..e5b70f40a6cbc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,8 +43,6 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; -import jdk.jfr.internal.SecuritySupport; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.util.ValueFormatter; /** @@ -134,7 +132,7 @@ public String getPid() { return JVM.getPid(); } - protected final SafePath resolvePath(Recording recording, String filename) throws InvalidPathException { + protected Path resolvePath(Recording recording, String filename) throws InvalidPathException { if (filename == null) { return makeGenerated(recording, Paths.get(".")); } @@ -142,11 +140,11 @@ protected final SafePath resolvePath(Recording recording, String filename) throw if (Files.isDirectory(path)) { return makeGenerated(recording, path); } - return new SafePath(path.toAbsolutePath().normalize()); + return path.toAbsolutePath().normalize(); } - private SafePath makeGenerated(Recording recording, Path directory) { - return new SafePath(directory.toAbsolutePath().resolve(JVMSupport.makeFilename(recording)).normalize()); + private Path makeGenerated(Recording recording, Path directory) { + return directory.toAbsolutePath().resolve(JVMSupport.makeFilename(recording)).normalize(); } protected final Recording findRecording(String name) throws DCmdException { @@ -158,7 +156,7 @@ protected final Recording findRecording(String name) throws DCmdException { } } - protected final void reportOperationComplete(String actionPrefix, String name, SafePath file) { + protected final void reportOperationComplete(String actionPrefix, String name, Path file) { print(actionPrefix); print(" recording"); if (name != null) { @@ -168,7 +166,7 @@ protected final void reportOperationComplete(String actionPrefix, String name, S print(","); try { print(" "); - long bytes = SecuritySupport.getFileSize(file); + long bytes = Files.size(file); printBytes(bytes); } catch (IOException e) { // Ignore, not essential @@ -219,16 +217,12 @@ protected final void printTimespan(Duration timespan, String separator) { print(ValueFormatter.formatTimespan(timespan, separator)); } - protected final void printPath(SafePath path) { + protected final void printPath(Path path) { if (path == null) { print("N/A"); return; } - try { - printPath(SecuritySupport.getAbsolutePath(path).toPath()); - } catch (IOException ioe) { - printPath(path.toPath()); - } + println(path.toAbsolutePath().toString()); } protected final void printHelpText() { @@ -237,15 +231,6 @@ protected final void printHelpText() { } } - protected final void printPath(Path path) { - try { - println(path.toAbsolutePath().toString()); - } catch (SecurityException e) { - // fall back on filename - println(path.toString()); - } - } - private Recording findRecordingById(int id) throws DCmdException { for (Recording r : getFlightRecorder().getRecordings()) { if (r.getId() == id) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java index 8ea49cbd3a52c..1d2bad2e9df82 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 jdk.jfr.internal.dcmd; import java.io.IOException; +import java.nio.file.Path; import jdk.jfr.FlightRecorder; import jdk.jfr.internal.LogLevel; @@ -34,7 +35,6 @@ import jdk.jfr.internal.Options; import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.Repository; -import jdk.jfr.internal.SecuritySupport.SafePath; /** * JFR.configure - invoked from native @@ -89,7 +89,7 @@ final class DCmdConfigure extends AbstractDCmd { boolean updated = false; if (repositoryPath != null) { try { - SafePath s = new SafePath(repositoryPath); + Path s = Path.of(repositoryPath); if (FlightRecorder.isInitialized()) { PrivateAccess.getInstance().getPlatformRecorder().migrate(s); } else { @@ -115,7 +115,7 @@ final class DCmdConfigure extends AbstractDCmd { if (dumpPath != null) { try { - Options.setDumpPath(new SafePath(dumpPath)); + Options.setDumpPath(Path.of(dumpPath)); } catch (IOException e) { throw new DCmdException("Could not set " + dumpPath + " to emergency dump path. " + e.getMessage(), e); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java index 7f68ba7ee7951..f2397f44ea45b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,8 @@ import jdk.jfr.internal.PlatformRecorder; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.util.ValueParser; -import jdk.jfr.internal.WriteableUserPath; +import jdk.jfr.internal.WriteablePath; /** * JFR.dump @@ -126,17 +125,16 @@ public void dump(PlatformRecorder recorder, Recording recording, String name, St // If a filename exist, use it // if a filename doesn't exist, use destination set earlier // if destination doesn't exist, generate a filename - WriteableUserPath wup = null; + WriteablePath wp = null; if (recording != null) { PlatformRecording pRecording = PrivateAccess.getInstance().getPlatformRecording(recording); - wup = pRecording.getDestination(); + wp = pRecording.getDestination(); } - if (filename != null || (filename == null && wup == null) ) { - SafePath safe = resolvePath(recording, filename); - wup = new WriteableUserPath(safe.toPath()); + if (filename != null || (filename == null && wp == null) ) { + wp = new WriteablePath(resolvePath(recording, filename)); } - r.dumpStopped(wup); - reportOperationComplete("Dumped", name, new SafePath(wup.getRealPathText())); + r.dumpStopped(wp); + reportOperationComplete("Dumped", name, wp.getReal()); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java index 26c095541b6aa..634bcd3331593 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,6 @@ import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; -import java.security.AccessControlContext; -import java.security.AccessController; import java.text.ParseException; import java.time.Duration; import java.util.HashSet; @@ -48,8 +46,6 @@ import jdk.jfr.internal.OldObjectSample; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport.SafePath; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.Type; import jdk.jfr.internal.jfc.JFC; import jdk.jfr.internal.jfc.model.JFCModel; @@ -154,7 +150,7 @@ public void execute(ArgumentParser parser) throws DCmdException { } recording.setSettings(s); - SafePath safePath = null; + Path dumpPath = null; // Generate dump filename if user has specified a time-bound recording if (duration != null && path == null) { @@ -173,10 +169,10 @@ public void execute(ArgumentParser parser) throws DCmdException { // Purposely avoid generating filename in Recording#setDestination due to // security concerns PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); - pr.setDumpDirectory(new SafePath(p)); + pr.setDumpDirectory(p); } else { - safePath = resolvePath(recording, path); - recording.setDestination(safePath.toPath()); + dumpPath = resolvePath(recording, path); + recording.setDestination(dumpPath); } } catch (IOException | InvalidPathException e) { recording.close(); @@ -221,10 +217,10 @@ public void execute(ArgumentParser parser) throws DCmdException { recording.setMaxSize(250*1024L*1024L); } - if (safePath != null && duration != null) { + if (dumpPath != null && duration != null) { println(" The result will be written to:"); println(); - printPath(safePath); + printPath(dumpPath); } else { println(); println(); @@ -256,7 +252,7 @@ private LinkedHashMap configureExtended(String[] settings, Argum JFCModel model = new JFCModel(l -> logWarning(l)); for (String setting : settings) { try { - model.parse(JFC.createSafePath(setting)); + model.parse(JFC.ofPath(setting)); } catch (InvalidPathException | IOException | JFCModelException | ParseException e) { throw new DCmdException(JFC.formatException("Could not", e, setting), e); } @@ -463,8 +459,8 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value private static String jfcOptions() { try { StringBuilder sb = new StringBuilder(); - for (SafePath s : SecuritySupport.getPredefinedJFCFiles()) { - String name = JFC.nameFromPath(s.toPath()); + for (Path s : JFC.getPredefined()) { + String name = JFC.nameFromPath(s); JFCModel model = JFCModel.create(s, l -> {}); sb.append('\n'); sb.append("Options for ").append(name).append(":\n"); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java index 5cf983645c65c..cda6a03e596d4 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +26,12 @@ import java.io.IOException; import java.nio.file.InvalidPathException; +import java.nio.file.Path; import java.nio.file.Paths; import jdk.jfr.Recording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport.SafePath; -import jdk.jfr.internal.WriteableUserPath; +import jdk.jfr.internal.WriteablePath; /** * JFR.stop @@ -47,20 +47,20 @@ protected void execute(ArgumentParser parser) throws DCmdException { String filename = parser.getOption("filename"); try { Recording recording = findRecording(name); - WriteableUserPath path = PrivateAccess.getInstance().getPlatformRecording(recording).getDestination(); - SafePath safePath = path == null ? null : new SafePath(path.getRealPathText()); + WriteablePath wp = PrivateAccess.getInstance().getPlatformRecording(recording).getDestination(); + Path path = wp == null ? null : wp.getReal(); if (filename != null) { try { - // Ensure path is valid. Don't generate safePath if filename == null, as a user may + // Ensure path is valid. Don't generate path if filename == null, as a user may // want to stop recording without a dump - safePath = resolvePath(null, filename); + path = resolvePath(null, filename); recording.setDestination(Paths.get(filename)); } catch (IOException | InvalidPathException e) { throw new DCmdException("Failed to stop %s. Could not set destination for \"%s\" to file %s", recording.getName(), filename, e.getMessage()); } } recording.stop(); - reportOperationComplete("Stopped", recording.getName(), safePath); + reportOperationComplete("Stopped", recording.getName(), path); recording.close(); } catch (InvalidPathException | DCmdException e) { if (filename != null) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java index 970365ef73dfe..719fa4e1b4d70 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +27,6 @@ import jdk.internal.misc.Unsafe; import jdk.jfr.internal.Bits; -import jdk.jfr.internal.EventWriterKey; import jdk.jfr.internal.StringPool; import jdk.jfr.internal.JVM; import jdk.jfr.internal.PlatformEventType; @@ -37,21 +36,8 @@ // would allow it to write arbitrary data into buffers, potentially from // different threads. // -// This is prevented in three ways: -// -// 1. For code to access the jdk.jfr.internal.event package -// at least one event class (for a particular module) must be -// registered having FlightRecorderPermission("registerEvent"). -// -// 2. The EventWriter EventWriterFactory::getEventWriter(long) method can only be linked from -// the UserEvent::commit() method instrumented by JFR. This is ensured by the JVM. -// (The EventWriterFactory class is dynamically generated before the first event -// is instrumented. See EventWriterFactoryRecipe) -// -// 3. Steps 1 and 2 are sufficient to make it fully secure, with or without a Security -// Manager, but as an additional measure, the method EventWriterFactory::getEventWriter(long) -// requires the caller to provide a key that is hard to guess. The key is generated -// into the bytecode of the method invoking getEventWriter(long). +// The EventWriter EventWriterFactory::getEventWriter(long) method can only be linked from +// the UserEvent::commit() method instrumented by JFR. This is ensured by the JVM. // public final class EventWriter { @@ -71,6 +57,14 @@ public final class EventWriter { private PlatformEventType eventType; private boolean largeSize = false; + public static EventWriter getEventWriter() { + EventWriter ew = JVM.getEventWriter(); + if (ew != null) { + return ew; + } + return JVM.newEventWriter(); + } + // User code must not be able to instantiate private EventWriter() { threadID = 0; @@ -239,11 +233,9 @@ private void flush(int usedSize, int requestedSize) { } public boolean beginEvent(EventConfiguration configuration, long typeId) { - // Malicious code could take the EventConfiguration object from one - // event class field and assign it to another. This check makes sure - // the event type matches what was added by instrumentation. + // This check makes sure the event type matches what was added by instrumentation. if (configuration.getId() != typeId) { - EventWriterKey.block(); + throw new InternalError("Unexpected type id " + typeId); } if (excluded) { // thread is excluded from writing events diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java index 0511ce57001c6..d89f527ae4b8d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,18 +46,33 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; -import jdk.jfr.internal.SecuritySupport; -import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.util.Utils; /** * {@link Configuration} factory for JFC files. * */ public final class JFC { + private static final Path JFC_DIRECTORY = Utils.getPathInProperty("java.home", "lib/jfr"); private static final int BUFFER_SIZE = 8192; private static final int MAXIMUM_FILE_SIZE = 1024 * 1024; private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; private static volatile List knownConfigurations; + public static List getPredefined() { + List list = new ArrayList<>(); + try (var ds = Files.newDirectoryStream(JFC_DIRECTORY)) { + for (Path path : ds) { + String text = path.toString(); + if (text.endsWith(".jfc") && !Files.isDirectory(path)) { + list.add(path); + } + } + } catch (IOException ioe) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not access .jfc-files in " + JFC_DIRECTORY + ", " + ioe.getMessage()); + } + return list; + } + /** * Reads a known configuration file (located into a string, but doesn't * parse it until it's being used. @@ -66,14 +81,14 @@ private static final class KnownConfiguration { private final String content; private final String filename; private final String name; - private final SafePath path; + private final Path path; private Configuration configuration; - public KnownConfiguration(SafePath knownPath) throws IOException { + public KnownConfiguration(Path knownPath) throws IOException { this.path = knownPath; this.content = readContent(knownPath); - this.name = nameFromPath(knownPath.toPath()); - this.filename = nullSafeFileName(knownPath.toPath()); + this.name = nameFromPath(knownPath); + this.filename = nullSafeFileName(knownPath); } public boolean isNamed(String name) { @@ -91,12 +106,12 @@ public String getName() { return name; } - private static String readContent(SafePath knownPath) throws IOException { - if (SecuritySupport.getFileSize(knownPath) > MAXIMUM_FILE_SIZE) { + private static String readContent(Path knownPath) throws IOException { + if (Files.size(knownPath) > MAXIMUM_FILE_SIZE) { throw new IOException("Configuration with more than " + MAXIMUM_FILE_SIZE + " characters can't be read."); } - try (InputStream r = SecuritySupport.newFileInputStream(knownPath)) { + try (InputStream r = Files.newInputStream(knownPath)) { return JFC.readContent(r); } } @@ -114,10 +129,7 @@ private JFC() { * @throws ParseException if the file can't be parsed * @throws IOException if the file can't be read * - * @throws SecurityException if a security manager exists and its - * {@code checkRead} method denies read access to the file * @see java.io.File#getPath() - * @see java.lang.SecurityManager#checkRead(java.lang.String) */ public static Configuration create(String name, Reader reader) throws IOException, ParseException { try { @@ -136,12 +148,12 @@ public static Configuration create(String name, Reader reader) throws IOExceptio * * @param path textual representation of the path * - * @return a safe path, not null + * @return a path, not null */ - public static SafePath createSafePath(String path) { - for (SafePath predefined : SecuritySupport.getPredefinedJFCFiles()) { + public static Path ofPath(String path) { + for (Path predefined : JFC.getPredefined()) { try { - String name = JFC.nameFromPath(predefined.toPath()); + String name = JFC.nameFromPath(predefined); if (name.equals(path) || (name + ".jfc").equals(path)) { return predefined; } @@ -149,7 +161,7 @@ public static SafePath createSafePath(String path) { throw new InternalError("Error in predefined .jfc file", e); } } - return new SafePath(path); + return Path.of(path); } @@ -172,20 +184,19 @@ public static String nameFromPath(Path file) throws IOException { // Invoked by DCmdStart public static Configuration createKnown(String name) throws IOException, ParseException { - // Known name, no need for permission for (KnownConfiguration known : getKnownConfigurations()) { if (known.isNamed(name)) { return known.getConfigurationFile(); } } // Check JFC directory - SafePath path = SecuritySupport.JFC_DIRECTORY; - if (path != null && SecuritySupport.exists(path)) { + Path path = JFC_DIRECTORY; + if (path != null && Files.exists(path)) { for (String extension : Arrays.asList("", JFCParser.FILE_EXTENSION)) { - SafePath file = new SafePath(path.toPath().resolveSibling(name + extension)); - if (SecuritySupport.exists(file) && !SecuritySupport.isDirectory(file)) { - try (Reader r = SecuritySupport.newFileReader(file)) { - String jfcName = nameFromPath(file.toPath()); + Path file = path.resolveSibling(name + extension); + if (Files.exists(file) && !Files.isDirectory(file)) { + try (Reader r = Files.newBufferedReader(file)) { + String jfcName = nameFromPath(file); return JFCParser.createConfiguration(jfcName, r); } } @@ -260,7 +271,7 @@ public static List getConfigurations() { private static List getKnownConfigurations() { if (knownConfigurations == null) { List configProxies = new ArrayList<>(); - for (SafePath p : SecuritySupport.getPredefinedJFCFiles()) { + for (Path p : JFC.getPredefined()) { try { configProxies.add(new KnownConfiguration(p)); } catch (IOException ioe) { @@ -281,7 +292,7 @@ public static Configuration getPredefined(String name) throws IOException, Parse throw new NoSuchFileException("Could not locate configuration with name " + name); } - public static Reader newReader(SafePath sf) throws IOException { + public static Reader newReader(Path sf) throws IOException { for (KnownConfiguration c : getKnownConfigurations()) { if (c.path.equals(sf)) { return new StringReader(c.content); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/JFCModel.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/JFCModel.java index e9b4208c148d3..e0b5fb4a6f306 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/JFCModel.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/model/JFCModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; +import java.nio.file.Path; import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; @@ -35,7 +36,6 @@ import java.util.Map; import java.util.function.Consumer; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.jfc.JFC; import static java.nio.charset.StandardCharsets.UTF_8; @@ -65,7 +65,7 @@ public JFCModel(Consumer logger) { this.logger = logger; } - public void parse(SafePath file) throws IOException, JFCModelException, ParseException { + public void parse(Path file) throws IOException, JFCModelException, ParseException { JFCModel model = JFCModel.create(file, logger); for (var entry : model.controls.entrySet()) { String name = entry.getKey(); @@ -80,7 +80,7 @@ public void parse(SafePath file) throws IOException, JFCModelException, ParseExc } } - public static JFCModel create(SafePath file, Consumer logger) throws IOException, JFCModelException, ParseException{ + public static JFCModel create(Path file, Consumer logger) throws IOException, JFCModelException, ParseException{ if (file.toString().equals("none")) { XmlConfiguration configuration = new XmlConfiguration(); configuration.setAttribute("version", "2.0"); @@ -154,7 +154,7 @@ public LinkedHashMap getSettings() { return result; } - public void saveToFile(SafePath path) throws IOException { + public void saveToFile(Path path) throws IOException { try (PrintWriter p = new PrintWriter(path.toFile(), UTF_8)) { PrettyPrinter pp = new PrettyPrinter(p); pp.print(configuration); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java index 66cd982bb51bd..0d8290b206ee9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,12 @@ package jdk.jfr.internal.management; import java.nio.file.Paths; +import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.io.IOException; -import jdk.jfr.internal.SecuritySupport; import jdk.jfr.internal.util.ValueFormatter; -import jdk.jfr.internal.consumer.FileAccess; // Allows a remote streaming client to create chunk files // with same naming scheme as the JVM. @@ -40,23 +39,12 @@ public final class ChunkFilename { private static final String FILE_EXTENSION = ".jfr"; private final Path directory; - private final FileAccess fileAcess; private Path lastPath; private int counter; - public static ChunkFilename newUnpriviliged(Path directory) { - return new ChunkFilename(directory, FileAccess.UNPRIVILEGED); - } - - public static ChunkFilename newPriviliged(Path directory) { - return new ChunkFilename(directory, SecuritySupport.PRIVILEGED); - } - - private ChunkFilename(Path directory, FileAccess fileAccess) { - // Avoid malicious implementations of Path interface - this.directory = Paths.get(directory.toString()); - this.fileAcess = fileAccess; + public ChunkFilename(Path directory) { + this.directory = directory; } public String next(LocalDateTime time) throws IOException { @@ -65,7 +53,7 @@ public String next(LocalDateTime time) throws IOException { // If less than one file per second (typically case) if (lastPath == null || !p.equals(lastPath)) { - if (!fileAcess.exists(p)) { + if (!Files.exists(p)) { counter = 1; // reset counter lastPath = p; return p.toString(); @@ -77,7 +65,7 @@ public String next(LocalDateTime time) throws IOException { String extendedName = makeExtendedName(filename, counter); p = directory.resolve(extendedName); counter++; - if (!fileAcess.exists(p)) { + if (!Files.exists(p)) { return p.toString(); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java index 165419cc34a52..1f5963d027771 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +34,6 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import java.security.AccessControlContext; - import jdk.jfr.Configuration; import jdk.jfr.EventSettings; import jdk.jfr.EventType; @@ -49,15 +47,12 @@ import jdk.jfr.internal.MetadataRepository; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; -import jdk.jfr.internal.SecuritySupport; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.util.Utils; import jdk.jfr.internal.util.ValueFormatter; import jdk.jfr.internal.util.ValueParser; -import jdk.jfr.internal.WriteableUserPath; +import jdk.jfr.internal.WriteablePath; import jdk.jfr.internal.consumer.AbstractEventStream; import jdk.jfr.internal.consumer.EventDirectoryStream; -import jdk.jfr.internal.consumer.FileAccess; /** * The management API in module jdk.management.jfr should be built on top of the @@ -84,7 +79,6 @@ public final class ManagementSupport { // public static List getEventTypes() { // would normally be checked when a Flight Recorder instance is created - SecuritySupport.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return List.of(); } @@ -121,17 +115,16 @@ public static void logDebug(String message) { // requires access to jdk.jfr.internal.PlatformRecording public static String getDestinationOriginalText(Recording recording) { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); - WriteableUserPath wup = pr.getDestination(); - return wup == null ? null : wup.getOriginalText(); + WriteablePath wp = pr.getDestination(); + return wp == null ? null : wp.getPath().toString(); } // Needed to check if destination can be set, so FlightRecorderMXBean::setRecordingOption // can abort if not all data is valid - public static void checkSetDestination(Recording recording, String destination) throws IOException{ + public static void checkSetDestination(Recording recording, String destination) throws IOException { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); if(destination != null){ - WriteableUserPath wup = new WriteableUserPath(Paths.get(destination)); - pr.checkSetDestination(wup); + pr.checkSetDestination(new WriteablePath(Paths.get(destination))); } } @@ -143,7 +136,7 @@ public static EventSettings newEventSettings(EventSettingsModifier esm) { // Needed callback to detect when a chunk has been parsed. public static void removePath(Recording recording, Path path) { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); - pr.removePath(new SafePath(path)); + pr.removePath(path); } // Needed callback to detect when a chunk has been parsed. @@ -169,14 +162,10 @@ public static Configuration newConfiguration(String name, String label, String d // EventStream::onMetadataData need to supply MetadataEvent // with configuration objects public static EventStream newEventDirectoryStream( - @SuppressWarnings("removal") - AccessControlContext acc, Path directory, List confs) throws IOException { return new EventDirectoryStream( - acc, directory, - FileAccess.UNPRIVILEGED, null, confs, false diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JavaEventTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JavaEventTask.java index 18729685a6d4b..55113f7d3f42a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JavaEventTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/JavaEventTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +30,9 @@ import jdk.jfr.internal.PlatformEventType; import jdk.jfr.internal.PrivateAccess; /** - * Base class for periodic Java events. + * Class for periodic Java events. */ -abstract class JavaEventTask extends EventTask { +final class JavaEventTask extends EventTask { private final Runnable runnable; public JavaEventTask(Class eventClass, Runnable runnable) { @@ -48,7 +48,8 @@ private static PlatformEventType toPlatformEventType(Class even return PrivateAccess.getInstance().getPlatformEventType(eventType); } - protected final Runnable getRunnable() { - return runnable; + @Override + public void execute(long timestamp, PeriodicType periodicType) { + runnable.run(); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/LookupKey.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/LookupKey.java index 5bbfbef70ae6f..bc4006aaff613 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/LookupKey.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/LookupKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,11 +25,8 @@ package jdk.jfr.internal.periodic; /** - * Lookup key that can safely be used in a {@code Map}. - *

- * {@code Runnable} objects can't be used with {@code LinkedHashMap} as it - * invokes {@code hashCode} and {@code equals}, for example when resizing the - * {@code Map}, possibly in a non-secure context. + * Lookup key that can be used in a {@code Map} in + * case hashCode and equals are incorrectly overridden. *

* {@code IdentityHashMap} can't be used as it will not preserve order. */ diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicEvents.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicEvents.java index a68af8ad25be3..8cbf6334e64a5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicEvents.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ */ package jdk.jfr.internal.periodic; -import java.security.AccessControlContext; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; @@ -58,18 +57,14 @@ public final class PeriodicEvents { // State only to be read and modified by periodic task thread private static long lastTimeMillis; - public static void addJDKEvent(Class eventClass, Runnable runnable) { - taskRepository.add(new JDKEventTask(eventClass, runnable)); + public static void addJavaEvent(Class eventClass, Runnable runnable) { + taskRepository.add(new JavaEventTask(eventClass, runnable)); } public static void addJVMEvent(PlatformEventType eventType) { taskRepository.add(new JVMEventTask(eventType)); } - public static void addUserEvent(@SuppressWarnings("removal") AccessControlContext acc, Class eventClass, Runnable runnable) { - taskRepository.add(new UserEventTask(acc, eventClass, runnable)); - } - public static boolean removeEvent(Runnable runnable) { return taskRepository.removeTask(runnable); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicTask.java index 876b9ecbc920a..b180d5074811e 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/PeriodicTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,6 @@ * / \ * / \ * JVMEventTask JavaEventTask - * / \ - * / \ - * UserEventTask JDKEventTask * *

* State modifications should only be done from the periodic task thread. @@ -127,8 +124,8 @@ public final void run(long timestamp, PeriodicType periodicType) { try { execute(timestamp, periodicType); } catch (Throwable e) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Exception occurred during execution of " + name); + String msg = "Exception occurred during execution of " + name + ". " + e.getMessage(); + Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, msg); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/UserEventTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/UserEventTask.java deleted file mode 100644 index 1241cd7fb0b26..0000000000000 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/UserEventTask.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.jfr.internal.periodic; - -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Objects; - -import jdk.internal.event.Event; -import jdk.jfr.internal.LogLevel; -import jdk.jfr.internal.LogTag; -import jdk.jfr.internal.Logger; - -/** - * Class to be used with user-defined events that runs untrusted code. - *

- * This class can be removed once the Security Manager is no longer supported. - */ -final class UserEventTask extends JavaEventTask { - @SuppressWarnings("removal") - private final AccessControlContext controlContext; - - public UserEventTask(@SuppressWarnings("removal") AccessControlContext controlContext, Class eventClass, Runnable runnable) { - super(eventClass, runnable); - this.controlContext = Objects.requireNonNull(controlContext); - } - - @SuppressWarnings("removal") - @Override - public void execute(long timestamp, PeriodicType periodicType) { - AccessController.doPrivileged((PrivilegedAction) () -> { - execute(); - return null; - }, controlContext); - } - - private void execute() { - try { - getRunnable().run(); - if (Logger.shouldLog(LogTag.JFR_EVENT, LogLevel.DEBUG)) { - Logger.log(LogTag.JFR_EVENT, LogLevel.DEBUG, "Executed periodic task for " + getEventType().getLogName()); - } - } catch (Throwable t) { - // Prevent malicious user to propagate exception callback in the wrong context - Logger.log(LogTag.JFR_EVENT, LogLevel.WARN, "Exception occurred during execution of period task for " + getEventType().getLogName()); - } - } -} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/BooleanSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/BooleanSetting.java index 72ffcac72c926..f5cc1495738ff 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/BooleanSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/BooleanSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +28,10 @@ import java.util.Objects; import java.util.Set; +import jdk.jfr.SettingControl; import jdk.jfr.internal.PlatformEventType; -abstract class BooleanSetting extends JDKSettingControl { +abstract class BooleanSetting extends SettingControl { private final PlatformEventType eventType; private final String defaultValue; private String value; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/CutoffSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/CutoffSetting.java index 68950d71b63d7..2f7d9f8e872c1 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/CutoffSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/CutoffSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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.util.Set; import jdk.jfr.Description; +import jdk.jfr.SettingControl; import jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; @@ -44,7 +45,7 @@ @Description("Limit running time of event") @Name(Type.SETTINGS_PREFIX + "Cutoff") @Timespan -public final class CutoffSetting extends JDKSettingControl { +public final class CutoffSetting extends SettingControl { public static final String DEFAULT_VALUE = ValueParser.INFINITY; private String value = DEFAULT_VALUE; private final PlatformEventType eventType; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/JDKSettingControl.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/JDKSettingControl.java deleted file mode 100644 index 46f224bada607..0000000000000 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/JDKSettingControl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jfr.internal.settings; - -import jdk.jfr.SettingControl; - -/** - * SettingControls that derive from this class avoids executing settings - * modifications in a AccessController.doPrivilege(...) block. - */ -public abstract class JDKSettingControl extends SettingControl { -} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java index 9531f75c9257a..750e20d9cdddd 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/LevelSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,13 +33,14 @@ import jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; +import jdk.jfr.SettingControl; import jdk.jfr.internal.PlatformEventType; import jdk.jfr.internal.Type; @MetadataDefinition @Label("Level") @Name(Type.SETTINGS_PREFIX + "Level") -public final class LevelSetting extends JDKSettingControl { +public final class LevelSetting extends SettingControl { private final PlatformEventType eventType; private final List levels; private String value; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java index 22fef2691aa91..902584a8819ac 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; +import jdk.jfr.SettingControl; import jdk.jfr.internal.PlatformEventType; import jdk.jfr.internal.Type; import jdk.jfr.internal.util.ValueParser; @@ -41,7 +42,7 @@ @Label("Period") @Description("Record event at interval") @Name(Type.SETTINGS_PREFIX + "Period") -public final class PeriodSetting extends JDKSettingControl { +public final class PeriodSetting extends SettingControl { private static final long typeId = Type.getTypeId(PeriodSetting.class); public static final String EVERY_CHUNK = "everyChunk"; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java index 8870417f9dd35..83a5572670753 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; +import jdk.jfr.SettingControl; import jdk.jfr.Timespan; import jdk.jfr.internal.PlatformEventType; import jdk.jfr.internal.Type; @@ -44,7 +45,7 @@ @Name(Type.SETTINGS_PREFIX + "Threshold") @Description("Record event with duration above or equal to threshold") @Timespan -public final class ThresholdSetting extends JDKSettingControl { +public final class ThresholdSetting extends SettingControl { public static final String DEFAULT_VALUE = "0 ns"; private static final long typeId = Type.getTypeId(ThresholdSetting.class); private String value = DEFAULT_VALUE; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThrottleSetting.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThrottleSetting.java index c18031d514f98..0527d7e8689be 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThrottleSetting.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/ThrottleSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Datadog, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; +import jdk.jfr.SettingControl; import jdk.jfr.internal.PlatformEventType; import jdk.jfr.internal.Throttle; import jdk.jfr.internal.Type; @@ -47,7 +48,7 @@ @Label("Throttle") @Description("Throttles the emission rate for an event") @Name(Type.SETTINGS_PREFIX + "Throttle") -public final class ThrottleSetting extends JDKSettingControl { +public final class ThrottleSetting extends SettingControl { public static final String DEFAULT_VALUE = Throttle.DEFAULT; private final PlatformEventType eventType; private String value = DEFAULT_VALUE; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java index 974e8846aa4d0..d76f182a8a804 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ private static List createCommands() { List commands = new ArrayList<>(); commands.add(new Print()); // Uncomment when developing new queries for the view command - // commands.add(new Query()); + commands.add(new Query()); commands.add(new View()); commands.add(new Configure()); commands.add(new Metadata()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Configure.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Configure.java index 63b2d8fe74f08..048763c4cc115 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Configure.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Configure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ import java.util.List; import java.util.Map; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.jfc.JFC; import jdk.jfr.internal.jfc.model.AbortException; import jdk.jfr.internal.jfc.model.JFCModel; @@ -129,7 +128,7 @@ private void displayParameters(PrintStream stream, String name) { stream.println("Options for " + name + ":"); stream.println(); try { - SafePath path = JFC.createSafePath(name); + Path path = JFC.ofPath(name); JFCModel parameters = JFCModel.create(path, l -> stream.println("Warning! " + l)); for (XmlInput input : parameters.getInputs()) { stream.println(" " + input.getOptionSyntax()); @@ -144,7 +143,7 @@ private void displayParameters(PrintStream stream, String name) { public void execute(Deque options) throws UserSyntaxException, UserDataException { boolean interactive = false; boolean log = false; - SafePath output = null; + Path output = null; Map keyValues = new LinkedHashMap<>(); int optionCount = options.size(); while (optionCount > 0) { @@ -192,7 +191,7 @@ private boolean acceptKeyValue(Deque options) { return false; } - private void configure(boolean interactive, boolean log, SafePath output, Map options) throws UserDataException { + private void configure(boolean interactive, boolean log, Path output, Map options) throws UserDataException { UserInterface ui = new UserInterface(); if (log) { SettingsLog.enable(); @@ -201,14 +200,14 @@ private void configure(boolean interactive, boolean log, SafePath output, Map options) throws UserSyntaxException, UserDataE } private List findChunkSizes(Path p) throws IOException { - try (RecordingInput input = new RecordingInput(p.toFile(), FileAccess.UNPRIVILEGED)) { + try (RecordingInput input = new RecordingInput(p.toFile())) { List sizes = new ArrayList<>(); ChunkHeader ch = new ChunkHeader(input); sizes.add(ch.getSize()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java index 12a468b2e89e4..08ab475fa680b 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,6 @@ import jdk.jfr.internal.MetadataDescriptor; import jdk.jfr.internal.Type; import jdk.jfr.internal.consumer.ChunkHeader; -import jdk.jfr.internal.consumer.FileAccess; import jdk.jfr.internal.consumer.RecordingInput; import jdk.jfr.internal.util.UserDataException; import jdk.jfr.internal.util.UserSyntaxException; @@ -93,7 +92,7 @@ private void printInformation(Path p) throws IOException { long totalDuration = 0; long chunks = 0; - try (RecordingInput input = new RecordingInput(p.toFile(), FileAccess.UNPRIVILEGED)) { + try (RecordingInput input = new RecordingInput(p.toFile())) { ChunkHeader first = new ChunkHeader(input); ChunkHeader ch = first; String eventPrefix = Type.EVENT_NAME_PREFIX; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriterFactoryRecipe.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/DirectoryCleaner.java similarity index 56% rename from src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriterFactoryRecipe.java rename to src/jdk.jfr/share/classes/jdk/jfr/internal/util/DirectoryCleaner.java index de59ea92d69a5..2067a8ebec186 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriterFactoryRecipe.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/DirectoryCleaner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * 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,23 +22,33 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.jfr.internal; +package jdk.jfr.internal.util; -import jdk.jfr.internal.event.EventWriter; +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; -// This class is not directly used but renamed to -// jdk.jfr.internal.event.EventWriterFactory and loaded dynamically -// when the first event class is bytecode instrumented. -// See JVMUpcalls and EventWriterKey::ensureEventWriterFactory() -public final class EventWriterFactoryRecipe { - private static final long KEY = EventWriterKey.getKey(); +public final class DirectoryCleaner extends SimpleFileVisitor { - public static EventWriter getEventWriter(long key) { - if (key == KEY) { - EventWriter ew = JVM.getEventWriter(); - return ew != null ? ew : JVM.newEventWriter(); + public static void clear(Path path) throws IOException { + Files.walkFileTree(path, new DirectoryCleaner()); + } + + @Override + public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { + Files.delete(path); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (exc != null) { + throw exc; } - EventWriterKey.block(); - return null; // Can't reach here. + Files.delete(dir); + return FileVisitResult.CONTINUE; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java index c15e87709c5a8..777725f88d426 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 @@ package jdk.jfr.internal.util; +import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.RandomAccessFile; import java.lang.annotation.Annotation; import java.lang.annotation.Repeatable; @@ -448,4 +450,13 @@ public static ValueDescriptor findField(List fields, String nam } return null; } + + public static Path getPathInProperty(String prop, String subPath) { + String path = System.getProperty(prop); + if (path == null) { + return null; + } + File file = subPath == null ? new File(path) : new File(path, subPath); + return file.toPath().toAbsolutePath(); + } } diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java index 24fd768dd414c..1ed2a2a05aef8 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +151,7 @@ public State next() { public DiskRepository(Path path, boolean deleteDirectory) throws IOException { this.directory = path; this.deleteDirectory = deleteDirectory; - this.chunkFilename = ChunkFilename.newUnpriviliged(path); + this.chunkFilename = new ChunkFilename(path); } public synchronized void write(byte[] bytes) throws IOException { diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java index e65b114d7aabf..bb2470d5a0bbb 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +30,6 @@ import java.io.StringReader; import java.nio.file.Path; import java.nio.file.Paths; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.ParseException; import java.time.Instant; import java.util.ArrayList; @@ -67,7 +64,6 @@ import jdk.jfr.EventType; import jdk.jfr.FlightRecorder; import jdk.jfr.FlightRecorderListener; -import jdk.jfr.FlightRecorderPermission; import jdk.jfr.Recording; import jdk.jfr.RecordingState; import jdk.jfr.internal.management.ManagementSupport; @@ -80,12 +76,9 @@ final class MXBeanListener implements FlightRecorderListener { private final NotificationListener listener; private final NotificationFilter filter; private final Object handback; - @SuppressWarnings("removal") - private final AccessControlContext context; @SuppressWarnings("removal") public MXBeanListener(NotificationListener listener, NotificationFilter filter, Object handback) { - this.context = AccessController.getContext(); this.listener = listener; this.filter = filter; this.handback = handback; @@ -93,13 +86,7 @@ public MXBeanListener(NotificationListener listener, NotificationFilter filter, @SuppressWarnings("removal") public void recordingStateChanged(Recording recording) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - sendNotification(createNotification(recording)); - return null; - } - }, context); + sendNotification(createNotification(recording)); } } @@ -124,25 +111,21 @@ public Void run() { @Override public void startRecording(long id) { - MBeanUtils.checkControl(); getExistingRecording(id).start(); } @Override public boolean stopRecording(long id) { - MBeanUtils.checkControl(); return getExistingRecording(id).stop(); } @Override public void closeRecording(long id) { - MBeanUtils.checkControl(); getExistingRecording(id).close(); } @Override public long openStream(long id, Map options) throws IOException { - MBeanUtils.checkControl(); if (!FlightRecorder.isInitialized()) { throw new IllegalArgumentException("No recording available with id " + id); } @@ -169,19 +152,16 @@ public long openStream(long id, Map options) throws IOException @Override public void closeStream(long streamIdentifier) throws IOException { - MBeanUtils.checkControl(); streamHandler.getStream(streamIdentifier).close(); } @Override public byte[] readStream(long streamIdentifier) throws IOException { - MBeanUtils.checkMonitor(); return streamHandler.getStream(streamIdentifier).read(); } @Override public List getRecordings() { - MBeanUtils.checkMonitor(); if (!FlightRecorder.isInitialized()) { return Collections.emptyList(); } @@ -190,60 +170,39 @@ public List getRecordings() { @Override public List getConfigurations() { - MBeanUtils.checkMonitor(); return MBeanUtils.transformList(Configuration.getConfigurations(), ConfigurationInfo::new); } @Override public List getEventTypes() { - MBeanUtils.checkMonitor(); - @SuppressWarnings("removal") - List eventTypes = AccessController.doPrivileged(new PrivilegedAction>() { - @Override - public List run() { - return ManagementSupport.getEventTypes(); - } - }, null, new FlightRecorderPermission("accessFlightRecorder")); - - return MBeanUtils.transformList(eventTypes, EventTypeInfo::new); + return MBeanUtils.transformList(ManagementSupport.getEventTypes(), EventTypeInfo::new); } @Override public Map getRecordingSettings(long recording) throws IllegalArgumentException { - MBeanUtils.checkMonitor(); return getExistingRecording(recording).getSettings(); } @Override public void setRecordingSettings(long recording, Map settings) throws IllegalArgumentException { Objects.requireNonNull(settings, "settings"); - MBeanUtils.checkControl(); getExistingRecording(recording).setSettings(settings); } - @SuppressWarnings("removal") @Override public long newRecording() { - MBeanUtils.checkControl(); getRecorder(); // ensure notification listener is setup - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Recording run() { - return new Recording(); - } - }, null, new FlightRecorderPermission("accessFlightRecorder")).getId(); + return new Recording().getId(); } @Override public long takeSnapshot() { - MBeanUtils.checkControl(); return getRecorder().takeSnapshot().getId(); } @Override public void setConfiguration(long recording, String contents) throws IllegalArgumentException { Objects.requireNonNull(contents, "contents"); - MBeanUtils.checkControl(); try { Configuration c = Configuration.create(new StringReader(contents)); getExistingRecording(recording).setSettings(c.getSettings()); @@ -255,7 +214,6 @@ public void setConfiguration(long recording, String contents) throws IllegalArgu @Override public void setPredefinedConfiguration(long recording, String configurationName) throws IllegalArgumentException { Objects.requireNonNull(configurationName, "configurationName"); - MBeanUtils.checkControl(); Recording r = getExistingRecording(recording); for (Configuration c : Configuration.getConfigurations()) { if (c.getName().equals(configurationName)) { @@ -269,14 +227,12 @@ public void setPredefinedConfiguration(long recording, String configurationName) @Override public void copyTo(long recording, String outputFile) throws IOException { Objects.requireNonNull(outputFile, "outputFile"); - MBeanUtils.checkControl(); getExistingRecording(recording).dump(Paths.get(outputFile)); } @Override public void setRecordingOptions(long recording, Map options) throws IllegalArgumentException { Objects.requireNonNull(options, "options"); - MBeanUtils.checkControl(); // Make local copy to prevent concurrent modification Map ops = new HashMap(options); for (Map.Entry entry : ops.entrySet()) { @@ -315,7 +271,6 @@ public void setRecordingOptions(long recording, Map options) thr @Override public Map getRecordingOptions(long recording) throws IllegalArgumentException { - MBeanUtils.checkMonitor(); Recording r = getExistingRecording(recording); Map options = HashMap.newHashMap(10); options.put(OPTION_DUMP_ON_EXIT, String.valueOf(r.getDumpOnExit())); @@ -330,8 +285,7 @@ public Map getRecordingOptions(long recording) throws IllegalArg } @Override - public long cloneRecording(long id, boolean stop) throws IllegalStateException, SecurityException { - MBeanUtils.checkControl(); + public long cloneRecording(long id, boolean stop) throws IllegalStateException { return getRecording(id).copy(stop).getId(); } @@ -397,16 +351,11 @@ private static void validateOption(Map options, String na } @SuppressWarnings("removal") - private FlightRecorder getRecorder() throws SecurityException { + private FlightRecorder getRecorder() { // Synchronize on some private object that is always available synchronized (streamHandler) { if (recorder == null) { - recorder = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public FlightRecorder run() { - return FlightRecorder.getFlightRecorder(); - } - }, null, new FlightRecorderPermission("accessFlightRecorder")); + recorder = FlightRecorder.getFlightRecorder(); } return recorder; } @@ -425,13 +374,7 @@ private static MBeanNotificationInfo[] createNotificationInfo() { public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) { MXBeanListener mxbeanListener = new MXBeanListener(listener, filter, handback); listeners.add(mxbeanListener); - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run(){ - FlightRecorder.addListener(mxbeanListener); - return null; - } - }, null, new FlightRecorderPermission("accessFlightRecorder")); + FlightRecorder.addListener(mxbeanListener); super.addNotificationListener(listener, filter, handback); } diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/MBeanUtils.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/MBeanUtils.java index 05d2166329f71..cf05f840cbe10 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/MBeanUtils.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/MBeanUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +25,6 @@ package jdk.management.jfr; import java.io.IOException; -import java.lang.management.ManagementPermission; -import java.security.Permission; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; @@ -43,9 +41,6 @@ final class MBeanUtils { - private static final Permission monitor = new ManagementPermission("monitor"); - private static final Permission control = new ManagementPermission("control"); - static ObjectName createObjectName() { try { return new ObjectName(FlightRecorderMXBean.MXBEAN_NAME); @@ -54,22 +49,6 @@ static ObjectName createObjectName() { } } - static void checkControl() { - @SuppressWarnings("removal") - SecurityManager secManager = System.getSecurityManager(); - if (secManager != null) { - secManager.checkPermission(control); - } - } - - static void checkMonitor() { - @SuppressWarnings("removal") - SecurityManager secManager = System.getSecurityManager(); - if (secManager != null) { - secManager.checkPermission(monitor); - } - } - static List transformList(List source, Function function) { return source.stream().map(function).collect(Collectors.toList()); } diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java index e6dc9700c00f2..662fe8912446d 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +32,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; -import java.security.AccessControlContext; -import java.security.AccessController; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -44,7 +42,6 @@ import java.util.Objects; import java.util.concurrent.Future; import java.util.function.Consumer; -import java.security.AccessControlException; import javax.management.JMX; import javax.management.MBeanServerConnection; import javax.management.ObjectName; @@ -149,8 +146,6 @@ public void accept(Long endNanos) { final FlightRecorderMXBean mbean; final long recordingId; final EventStream stream; - @SuppressWarnings("removal") - final AccessControlContext accessControllerContext; final DiskRepository repository; final Instant creationTime; final Object lock = new Object(); @@ -205,9 +200,7 @@ public RemoteRecordingStream(MBeanServerConnection connection, Path directory) t private RemoteRecordingStream(MBeanServerConnection connection, Path directory, boolean delete) throws IOException { Objects.requireNonNull(connection, "connection"); Objects.requireNonNull(directory, "directory"); - accessControllerContext = AccessController.getContext(); - // Make sure users can't implement malicious version of a Path object. - path = Paths.get(directory.toString()); + path = directory; if (!Files.exists(path)) { throw new IOException("Download directory doesn't exist"); } @@ -219,7 +212,7 @@ private RemoteRecordingStream(MBeanServerConnection connection, Path directory, creationTime = Instant.now(); mbean = createProxy(connection); recordingId = createRecording(); - stream = ManagementSupport.newEventDirectoryStream(accessControllerContext, path, configurations(mbean)); + stream = ManagementSupport.newEventDirectoryStream(path, configurations(mbean)); stream.setStartTime(Instant.MIN); repository = new DiskRepository(path, delete); ManagementSupport.setOnChunkCompleteHandler(stream, new ChunkConsumer(repository)); diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java index 2780f396f0562..29e666a830c01 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 @@ import java.io.File; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import jdk.jfr.internal.Repository; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.Options; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; @@ -131,17 +131,17 @@ private static void testRepository(){ try { JcmdHelper.jcmd("JFR.configure", REPOSITORYPATH_SETTING_1); - SafePath initialPath = Repository.getRepository().getRepositoryPath(); + Path initialPath = Repository.getRepository().getRepositoryPath(); JcmdHelper.jcmd("JFR.configure", REPOSITORYPATH_SETTING_1); - SafePath samePath = Repository.getRepository().getRepositoryPath(); + Path samePath = Repository.getRepository().getRepositoryPath(); Asserts.assertTrue(samePath.equals(initialPath)); List lines = Files.readAllLines(Paths.get(JFR_UNIFIED_LOG_FILE)); Asserts.assertTrue(lines.stream().anyMatch(l->l.contains(findWhat))); JcmdHelper.jcmd("JFR.configure", REPOSITORYPATH_SETTING_2); - SafePath changedPath = Repository.getRepository().getRepositoryPath(); + Path changedPath = Repository.getRepository().getRepositoryPath(); Asserts.assertFalse(changedPath.equals(initialPath)); diff --git a/test/jdk/jdk/jfr/jvm/MyCommitRegisteredFalseEvent.java b/test/jdk/jdk/jfr/jvm/MyCommitRegisteredFalseEvent.java index d09d3067dafa8..5da979ad6450b 100644 --- a/test/jdk/jdk/jfr/jvm/MyCommitRegisteredFalseEvent.java +++ b/test/jdk/jdk/jfr/jvm/MyCommitRegisteredFalseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ @Registered(false) public class MyCommitRegisteredFalseEvent extends E implements Runnable { public void myCommit() { - PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter.getEventWriter(); throw new RuntimeException("Should not reach here"); } diff --git a/test/jdk/jdk/jfr/jvm/MyCommitRegisteredTrueEvent.java b/test/jdk/jdk/jfr/jvm/MyCommitRegisteredTrueEvent.java index 87014bcd72b48..0af8a8f41ccef 100644 --- a/test/jdk/jdk/jfr/jvm/MyCommitRegisteredTrueEvent.java +++ b/test/jdk/jdk/jfr/jvm/MyCommitRegisteredTrueEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ @Registered(true) public class MyCommitRegisteredTrueEvent extends E implements Runnable { public void myCommit() { - PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter.getEventWriter(); throw new RuntimeException("Should not reach here"); } diff --git a/test/jdk/jdk/jfr/jvm/NonEvent.java b/test/jdk/jdk/jfr/jvm/NonEvent.java index 9134d25c08c98..e98d995acdbff 100644 --- a/test/jdk/jdk/jfr/jvm/NonEvent.java +++ b/test/jdk/jdk/jfr/jvm/NonEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ // Class used by TestGetEventWriter public class NonEvent implements Runnable { public void commit() { - PlaceholderEventWriter ew = PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter ew = PlaceholderEventWriter.getEventWriter();; throw new RuntimeException("Should not reach here " + ew); } diff --git a/test/jdk/jdk/jfr/jvm/PlaceholderEventWriter.java b/test/jdk/jdk/jfr/jvm/PlaceholderEventWriter.java index 8f0c543334757..87cffc5127592 100644 --- a/test/jdk/jdk/jfr/jvm/PlaceholderEventWriter.java +++ b/test/jdk/jdk/jfr/jvm/PlaceholderEventWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,4 +30,8 @@ // will be replaced with "jdk.jfr.internal.event.EventWriter" public class PlaceholderEventWriter { + public static PlaceholderEventWriter getEventWriter() { + return null; + } + } diff --git a/test/jdk/jdk/jfr/jvm/PlaceholderEventWriterFactory.java b/test/jdk/jdk/jfr/jvm/PlaceholderEventWriterFactory.java deleted file mode 100644 index 8083bc16a53ba..0000000000000 --- a/test/jdk/jdk/jfr/jvm/PlaceholderEventWriterFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.jfr.jvm; - -// Purpose of this class is to have something to -// statically link against for TestGetEventWriter. -// -// When the class is loaded "jdk.jfr.jvm.PlaceholderEventWriterFactory" -// will be replaced with "jdk.jfr.internal.event.EventWriterFactory" -public class PlaceholderEventWriterFactory { - - public static PlaceholderEventWriter getEventWriter(long value) { - throw new RuntimeException("Test error, PlaceholderEventWriterFactory class should have been replaced with EventWriterFactory"); - } -} diff --git a/test/jdk/jdk/jfr/jvm/RegisteredFalseEvent.java b/test/jdk/jdk/jfr/jvm/RegisteredFalseEvent.java index 6174bace86628..d20a045450036 100644 --- a/test/jdk/jdk/jfr/jvm/RegisteredFalseEvent.java +++ b/test/jdk/jdk/jfr/jvm/RegisteredFalseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ @Registered(false) public class RegisteredFalseEvent extends E { public void commit() { - PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter.getEventWriter(); throw new RuntimeException("Should not reach here"); } } \ No newline at end of file diff --git a/test/jdk/jdk/jfr/jvm/RegisteredTrueEvent.java b/test/jdk/jdk/jfr/jvm/RegisteredTrueEvent.java index 3fe2ce8a1190f..fb2964e68e9f8 100644 --- a/test/jdk/jdk/jfr/jvm/RegisteredTrueEvent.java +++ b/test/jdk/jdk/jfr/jvm/RegisteredTrueEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ @Registered(true) public class RegisteredTrueEvent extends E { public void commit() { - PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter.getEventWriter(); throw new RuntimeException("Should not reach here"); } } \ No newline at end of file diff --git a/test/jdk/jdk/jfr/jvm/StaticCommitEvent.java b/test/jdk/jdk/jfr/jvm/StaticCommitEvent.java index 6adeb6cb9c51e..8c07c5bf9b6ae 100644 --- a/test/jdk/jdk/jfr/jvm/StaticCommitEvent.java +++ b/test/jdk/jdk/jfr/jvm/StaticCommitEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ public class StaticCommitEvent implements Runnable { int value; public static void commit(long start, long duration, String message, int value) { - PlaceholderEventWriterFactory.getEventWriter(4711L); + PlaceholderEventWriter.getEventWriter(); throw new RuntimeException("Should not reach here"); } diff --git a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java index 298114b14e14a..7920678b7f0e6 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java +++ b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +46,6 @@ * jdk.internal.vm.ci/jdk.vm.ci.runtime * * @compile PlaceholderEventWriter.java - * @compile PlaceholderEventWriterFactory.java * @compile E.java * @compile NonEvent.java * @compile RegisteredTrueEvent.java @@ -80,7 +79,6 @@ * jdk.internal.vm.ci/jdk.vm.ci.runtime * * @compile PlaceholderEventWriter.java - * @compile PlaceholderEventWriterFactory.java * @compile E.java * @compile NonEvent.java * @compile RegisteredTrueEvent.java @@ -105,10 +103,10 @@ public static void main(String... args) throws Throwable { InitializationEvent e = new InitializationEvent(); e.commit(); } - // Make sure EventWriterFactory can be accessed. - Class clazz = Class.forName("jdk.jfr.internal.event.EventWriterFactory"); + // Make sure EventWriter class can be accessed. + Class clazz = Class.forName("jdk.jfr.internal.event.EventWriter"); if (clazz == null) { - throw new Exception("Test error, not able to access jdk.jfr.internal.event.EventWriterFactory class"); + throw new Exception("Test error, not able to access jdk.jfr.internal.event.EventWriter class"); } testRegisteredTrueEvent(); testRegisteredFalseEvent(); @@ -122,7 +120,7 @@ public static void main(String... args) throws Throwable { // The class does not inherit jdk.jfr.Event and, as such, does not implement the // API. It has its own stand-alone "commit()V", which is not an override, that - // attempts to resolve and link against EventWriterFactory. This user implementation + // attempts to resolve and link against EventWriter. This user implementation // is not blessed for linkage. private static void testNonEvent() throws Throwable { Runnable e = newEventObject("NonEvent"); @@ -178,7 +176,7 @@ private static void testRegisteredFalseEvent() throws Throwable { } // The user has implemented another method, "myCommit()V", not an override nor - // overload. that attempts to resolve and link EventWriterFactory. This will fail, + // overload. that attempts to resolve and link EventWriter. This will fail, // because "myCommit()V" is not blessed for linkage. private static void testMyCommitRegisteredTrue() throws Throwable { Runnable e = newEventObject("MyCommitRegisteredTrueEvent"); @@ -230,10 +228,9 @@ static class MethodHandleEvent extends Event { public void myCommit() throws Throwable { try { Class ew = Class.forName("jdk.jfr.internal.event.EventWriter"); - MethodType t = MethodType.methodType(ew, List.of(long.class)); - Class factory = Class.forName("jdk.jfr.internal.event.EventWriterFactory"); - MethodHandle mh = MethodHandles.lookup().findStatic(factory, "getEventWriter", t); - mh.invoke(Long.valueOf(4711)); // throws IllegalAccessException + MethodType t = MethodType.methodType(ew, List.of()); + MethodHandle mh = MethodHandles.lookup().findStatic(ew, "getEventWriter", t); + mh.invoke(); // throws IllegalAccessException } catch (ClassNotFoundException | SecurityException e) { throw new RuntimeException(e); } @@ -262,8 +259,8 @@ static class ReflectionEvent extends Event { public void myCommit() throws Throwable { Class c; try { - c = Class.forName("jdk.jfr.internal.event.EventWriterFactory"); - Method m = c.getMethod("getEventWriter", new Class[] {long.class}); + c = Class.forName("jdk.jfr.internal.event.EventWriter"); + Method m = c.getMethod("getEventWriter", new Class[0]); m.invoke(null, Long.valueOf(4711)); // throws InternalError } catch (ClassNotFoundException | SecurityException e) { throw new RuntimeException(e); @@ -283,7 +280,7 @@ private static void testReflectionEvent() throws Throwable { } catch (InternalError ie) { if (ie.getCause() instanceof IllegalAccessException iaex) { if (iaex.getCause() instanceof IllegalAccessError iae) { - if (iae.getMessage().contains("getEventWriter(long)")) { + if (iae.getMessage().contains("getEventWriter()")) { // OK, as expected return; } @@ -345,7 +342,6 @@ private static T newEventObject(String name) throws Throwable { byte[] bytes = is.readAllBytes(); is.close(); bytes = replace(bytes, "jdk/jfr/jvm/E", "jdk/jfr/Event"); - bytes = replace(bytes, "jdk/jfr/jvm/PlaceholderEventWriterFactory", "jdk/jfr/internal/event/EventWriterFactory"); bytes = replace(bytes, "jdk/jfr/jvm/PlaceholderEventWriter", "jdk/jfr/internal/event/EventWriter"); BytesClassLoader bc = new BytesClassLoader(bytes, fullName); Class clazz = bc.loadClass(fullName); @@ -372,7 +368,7 @@ private static void maybeCheckJVMCI(Class eventClass, String commitName) thro } /** - * Checks that JVMCI prevents unblessed access to {@code EventWriterFactory.getEventWriter(long)}. + * Checks that JVMCI prevents unblessed access to {@code EventWriter.getEventWriter()}. */ private static void checkJVMCI(Class eventClass, String commitName) throws Throwable { MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); @@ -380,7 +376,7 @@ private static void checkJVMCI(Class eventClass, String commitName) throws Th ConstantPool cp = commit.getConstantPool(); // Search for first INVOKESTATIC instruction in commit method which is expected - // to be the call to jdk.jfr.internal.event.EventWriterFactory.getEventWriter(long). + // to be the call to jdk.jfr.internal.event.EventWriter.getEventWriter(). final int INVOKESTATIC = 184; byte[] code = commit.getCode(); for (int bci = 0; bci < code.length; bci++) { diff --git a/test/jdk/jdk/jfr/tool/TestAssemble.java b/test/jdk/jdk/jfr/tool/TestAssemble.java index ccc95498de437..2ac90b535a526 100644 --- a/test/jdk/jdk/jfr/tool/TestAssemble.java +++ b/test/jdk/jdk/jfr/tool/TestAssemble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import jdk.jfr.consumer.RecordedEvent; import jdk.jfr.consumer.RecordingFile; import jdk.jfr.internal.Repository; -import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; @@ -80,7 +79,7 @@ public static void main(String[] args) throws Throwable { expectedCount += countEventInRecording(tmp); } - SafePath repository = Repository.getRepository().getRepositoryPath(); + Path repository = Repository.getRepository().getRepositoryPath(); Path destinationPath = Paths.get("reconstructed.jfr"); String directory = repository.toString(); From c5c4efdaa1d04b1441fd96712b71cdb43e5d86df Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 10 Jan 2025 13:57:52 +0000 Subject: [PATCH 009/263] 8347120: Launchers should not have java headers on include path Reviewed-by: dholmes, ihse --- make/common/JdkNativeCompilation.gmk | 9 +++++++-- make/common/modules/LauncherCommon.gmk | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/make/common/JdkNativeCompilation.gmk b/make/common/JdkNativeCompilation.gmk index ca0f1429c6165..a4f48385f4189 100644 --- a/make/common/JdkNativeCompilation.gmk +++ b/make/common/JdkNativeCompilation.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -266,6 +266,9 @@ JDK_RCFLAGS=$(RCFLAGS) \ # will be replaced with proper values for hotspot. # HEADERS_FROM_SRC -- if false, does not add source dirs automatically as # header include dirs. (Defaults to true.) +# JAVA_HEADERS -- if false, does not add the directory with the generated +# headers from the Java compilation of the current module to the search +# path for include files. (Defaults to true.) # JDK_LIBS -- libraries generated by the JDK build system to link against. # These take the form :. For the current module, the # module name and colon can be omitted. The basename should be specified @@ -385,7 +388,9 @@ define SetupJdkNativeCompilationBody # Add the module specific java header dir ifneq ($$(MODULE), ) - $1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE))) + ifneq ($$($1_JAVA_HEADERS), false) + $1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE))) + endif endif $1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS)) diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index 38485283dcb98..eb8621092c0d5 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -145,6 +145,7 @@ define SetupBuildLauncherBody $$($1_CFLAGS), \ CFLAGS_windows := $$($1_CFLAGS_windows), \ EXTRA_HEADER_DIRS := java.base:libjvm, \ + JAVA_HEADERS := false, \ DISABLED_WARNINGS_gcc := unused-function unused-variable, \ DISABLED_WARNINGS_clang := unused-function, \ LDFLAGS := $$($1_LDFLAGS), \ From beb0e607d3b66b9e97c263cd8f2e23f447ebfc50 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Fri, 10 Jan 2025 14:47:01 +0000 Subject: [PATCH 010/263] 8347397: Cleanup of JDK-8169880 Reviewed-by: liach, alanb --- .../share/classes/java/lang/Class.java | 87 +++++++------------ 1 file changed, 31 insertions(+), 56 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 7929dd1a09f11..4250910c84b24 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1205,18 +1205,13 @@ public Class[] getInterfaces() { private Class[] getInterfaces(boolean cloneArray) { ReflectionData rd = reflectionData(); - if (rd == null) { - // no cloning required - return getInterfaces0(); - } else { - Class[] interfaces = rd.interfaces; - if (interfaces == null) { - interfaces = getInterfaces0(); - rd.interfaces = interfaces; - } - // defensively copy if requested - return cloneArray ? interfaces.clone() : interfaces; + Class[] interfaces = rd.interfaces; + if (interfaces == null) { + interfaces = getInterfaces0(); + rd.interfaces = interfaces; } + // defensively copy if requested + return cloneArray ? interfaces.clone() : interfaces; } private native Class[] getInterfaces0(); @@ -2922,18 +2917,14 @@ static byte[] getExecutableTypeAnnotationBytes(Executable ex) { private Field[] privateGetDeclaredFields(boolean publicOnly) { Field[] res; ReflectionData rd = reflectionData(); - if (rd != null) { - res = publicOnly ? rd.declaredPublicFields : rd.declaredFields; - if (res != null) return res; - } + res = publicOnly ? rd.declaredPublicFields : rd.declaredFields; + if (res != null) return res; // No cached value available; request value from VM res = Reflection.filterFields(this, getDeclaredFields0(publicOnly)); - if (rd != null) { - if (publicOnly) { - rd.declaredPublicFields = res; - } else { - rd.declaredFields = res; - } + if (publicOnly) { + rd.declaredPublicFields = res; + } else { + rd.declaredFields = res; } return res; } @@ -2944,10 +2935,8 @@ private Field[] privateGetDeclaredFields(boolean publicOnly) { private Field[] privateGetPublicFields() { Field[] res; ReflectionData rd = reflectionData(); - if (rd != null) { - res = rd.publicFields; - if (res != null) return res; - } + res = rd.publicFields; + if (res != null) return res; // Use a linked hash set to ensure order is preserved and // fields from common super interfaces are not duplicated @@ -2968,9 +2957,7 @@ private Field[] privateGetPublicFields() { } res = fields.toArray(new Field[0]); - if (rd != null) { - rd.publicFields = res; - } + rd.publicFields = res; return res; } @@ -2993,10 +2980,8 @@ private static void addAll(Collection c, Field[] o) { private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { Constructor[] res; ReflectionData rd = reflectionData(); - if (rd != null) { - res = publicOnly ? rd.publicConstructors : rd.declaredConstructors; - if (res != null) return res; - } + res = publicOnly ? rd.publicConstructors : rd.declaredConstructors; + if (res != null) return res; // No cached value available; request value from VM if (isInterface()) { @SuppressWarnings("unchecked") @@ -3005,12 +2990,10 @@ private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { } else { res = getDeclaredConstructors0(publicOnly); } - if (rd != null) { - if (publicOnly) { - rd.publicConstructors = res; - } else { - rd.declaredConstructors = res; - } + if (publicOnly) { + rd.publicConstructors = res; + } else { + rd.declaredConstructors = res; } return res; } @@ -3027,18 +3010,14 @@ private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { private Method[] privateGetDeclaredMethods(boolean publicOnly) { Method[] res; ReflectionData rd = reflectionData(); - if (rd != null) { - res = publicOnly ? rd.declaredPublicMethods : rd.declaredMethods; - if (res != null) return res; - } + res = publicOnly ? rd.declaredPublicMethods : rd.declaredMethods; + if (res != null) return res; // No cached value available; request value from VM res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly)); - if (rd != null) { - if (publicOnly) { - rd.declaredPublicMethods = res; - } else { - rd.declaredMethods = res; - } + if (publicOnly) { + rd.declaredPublicMethods = res; + } else { + rd.declaredMethods = res; } return res; } @@ -3049,10 +3028,8 @@ private Method[] privateGetDeclaredMethods(boolean publicOnly) { private Method[] privateGetPublicMethods() { Method[] res; ReflectionData rd = reflectionData(); - if (rd != null) { - res = rd.publicMethods; - if (res != null) return res; - } + res = rd.publicMethods; + if (res != null) return res; // No cached value available; compute value recursively. // Start by fetching public declared methods... @@ -3078,9 +3055,7 @@ private Method[] privateGetPublicMethods() { } res = pms.toArray(); - if (rd != null) { - rd.publicMethods = res; - } + rd.publicMethods = res; return res; } From 1bf2f5c8a92b30eabb530737158f57c63a81fef6 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Fri, 10 Jan 2025 15:58:50 +0000 Subject: [PATCH 011/263] 8343510: JFR: Remove AccessControlContext from FlightRecorder::addListener specification Reviewed-by: mgronlun --- src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java index a7bf3976d14df..6ea6f87f2afff 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorder.java @@ -241,8 +241,7 @@ public List getEventTypes() { } /** - * Adds a recorder listener and captures the {@code AccessControlContext} to - * use when invoking the listener. + * Adds a recorder listener. *

* If Flight Recorder is already initialized when the listener is added, then the method * {@link FlightRecorderListener#recorderInitialized(FlightRecorder)} method is From 9cf7d42b65cfecfe27d0267f971acb743c02b675 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 10 Jan 2025 16:47:51 +0000 Subject: [PATCH 012/263] 8346184: C2: assert(has_node(i)) failed during split thru phi Reviewed-by: thartmann, chagedorn --- src/hotspot/share/opto/memnode.cpp | 25 +++---- .../compiler/c2/TestLoadSplitThruPhiNull.java | 68 +++++++++++++++++++ 2 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/c2/TestLoadSplitThruPhiNull.java diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 78ffbe05ae492..ab57ee37cc6e2 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -2014,6 +2014,17 @@ const Type* LoadNode::Value(PhaseGVN* phase) const { assert(off != Type::OffsetTop, "case covered by TypePtr::empty"); Compile* C = phase->C; + // If we are loading from a freshly-allocated object, produce a zero, + // if the load is provably beyond the header of the object. + // (Also allow a variable load from a fresh array to produce zero.) + const TypeOopPtr* tinst = tp->isa_oopptr(); + bool is_instance = (tinst != nullptr) && tinst->is_known_instance_field(); + Node* value = can_see_stored_value(mem, phase); + if (value != nullptr && value->is_Con()) { + assert(value->bottom_type()->higher_equal(_type), "sanity"); + return value->bottom_type(); + } + // Try to guess loaded type from pointer type if (tp->isa_aryptr()) { const TypeAryPtr* ary = tp->is_aryptr(); @@ -2220,20 +2231,6 @@ const Type* LoadNode::Value(PhaseGVN* phase) const { } } - // If we are loading from a freshly-allocated object, produce a zero, - // if the load is provably beyond the header of the object. - // (Also allow a variable load from a fresh array to produce zero.) - const TypeOopPtr *tinst = tp->isa_oopptr(); - bool is_instance = (tinst != nullptr) && tinst->is_known_instance_field(); - bool is_boxed_value = (tinst != nullptr) && tinst->is_ptr_to_boxed_value(); - if (ReduceFieldZeroing || is_instance || is_boxed_value) { - Node* value = can_see_stored_value(mem,phase); - if (value != nullptr && value->is_Con()) { - assert(value->bottom_type()->higher_equal(_type),"sanity"); - return value->bottom_type(); - } - } - bool is_vect = (_type->isa_vect() != nullptr); if (is_instance && !is_vect) { // If we have an instance type and our memory input is the diff --git a/test/hotspot/jtreg/compiler/c2/TestLoadSplitThruPhiNull.java b/test/hotspot/jtreg/compiler/c2/TestLoadSplitThruPhiNull.java new file mode 100644 index 0000000000000..5c927fbefb1e4 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestLoadSplitThruPhiNull.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024, 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 8346184 + * @summary C2: assert(has_node(i)) failed during split thru phi + * + * @run main/othervm -XX:-BackgroundCompilation TestLoadSplitThruPhiNull + * @run main/othervm -XX:-BackgroundCompilation -XX:-ReduceFieldZeroing TestLoadSplitThruPhiNull + * @run main TestLoadSplitThruPhiNull + * + */ + +public class TestLoadSplitThruPhiNull { + private static Object[] fieldArray; + private static Object fieldObject; + + public static void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + test1(true); + test1(false); + } + } + + private static Object test1(boolean flag) { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 10; k++) { + + } + } + } + Object[] array = new Object[10]; + fieldArray = array; + int i; + for (i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + + } + } + Object v = array[i-10]; + if (flag) { + array[0] = new Object(); + } + return array[i-10]; + } +} From e7e8f60c9bedd5622525cc4339300b438eedc9fd Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 10 Jan 2025 16:50:21 +0000 Subject: [PATCH 013/263] 8347302: Mark test tools/jimage/JImageToolTest.java as flagless Reviewed-by: alanb, shade --- test/jdk/tools/jimage/JImageToolTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/tools/jimage/JImageToolTest.java b/test/jdk/tools/jimage/JImageToolTest.java index b1006c896794b..d7d1ee35ba1e0 100644 --- a/test/jdk/tools/jimage/JImageToolTest.java +++ b/test/jdk/tools/jimage/JImageToolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @library /test/lib + * @requires vm.flagless * @build jdk.test.lib.process.ProcessTools * @summary Test to check if jimage tool exists and is working * @run main/timeout=360 JImageToolTest From 46ba515c4989de7545d409570315274e0ea1c5ac Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 10 Jan 2025 17:59:27 +0000 Subject: [PATCH 014/263] 8346669: Increase abstraction in SetupBuildLauncher and remove extra args Reviewed-by: erikj --- make/StaticLibs.gmk | 3 +- make/common/modules/LauncherCommon.gmk | 40 +++++++-------- make/modules/java.base/Launcher.gmk | 7 ++- make/modules/jdk.compiler/Launcher.gmk | 4 +- make/modules/jdk.javadoc/Launcher.gmk | 2 +- make/modules/jdk.jconsole/Launcher.gmk | 2 +- make/modules/jdk.jdeps/Launcher.gmk | 8 +-- make/modules/jdk.jfr/Launcher.gmk | 2 +- make/modules/jdk.jlink/Launcher.gmk | 8 +-- make/modules/jdk.jshell/Launcher.gmk | 2 +- src/java.base/share/native/launcher/defines.h | 11 +--- src/java.base/share/native/launcher/main.c | 50 +++---------------- 12 files changed, 48 insertions(+), 91 deletions(-) diff --git a/make/StaticLibs.gmk b/make/StaticLibs.gmk index d54c67b50b3ea..900fbbbbad4f6 100644 --- a/make/StaticLibs.gmk +++ b/make/StaticLibs.gmk @@ -107,7 +107,8 @@ else endif $(eval $(call SetupBuildLauncher, java, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ + ENABLE_ARG_FILES := true, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ OPTIMIZATION := HIGH, \ diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index eb8621092c0d5..48b523428240a 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -48,15 +48,11 @@ JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest # used as the name of the executable. # # Remaining parameters are named arguments. These include: -# MAIN_MODULE The module of the main class to launch if different from the -# current module # MAIN_CLASS The Java main class to launch -# JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS -# EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended -# before JAVA_ARGS to CFLAGS, primarily to allow long string literal -# compile time defines exceeding Visual Studio 2013 limitations. -# CFLAGS Additional CFLAGS -# CFLAGS_windows Additional CFLAGS_windows +# JAVA_ARGS Additional arguments to pass to Java when launching the main class +# EXPAND_CLASSPATH_WILDCARDS Set to true to pass EXPAND_CLASSPATH_WILDCARDS +# ENABLE_ARG_FILES Set to true to pass ENABLE_ARG_FILES +# WINDOWS_JAVAW Set to true to pass JAVAW on Windows # EXTRA_RCFLAGS Additional EXTRA_RCFLAGS # MACOSX_PRIVILEGED On macosx, allow to access other processes # OPTIMIZATION Override default optimization level (LOW) @@ -70,19 +66,25 @@ define SetupBuildLauncherBody $1_OPTIMIZATION := LOW endif - ifeq ($$($1_MAIN_MODULE), ) - $1_MAIN_MODULE := $(MODULE) - endif + $1_MAIN_MODULE := $(MODULE) ifneq ($$($1_MAIN_CLASS), ) $1_JAVA_ARGS += -Xms8m $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS) endif - ifneq ($$($1_EXTRA_JAVA_ARGS), ) - $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ - $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }' - $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR) + ifeq ($$($1_EXPAND_CLASSPATH_WILDCARDS), true) + $1_CFLAGS += -DEXPAND_CLASSPATH_WILDCARDS + endif + + ifeq ($$($1_ENABLE_ARG_FILES), true) + $1_CFLAGS += -DENABLE_ARG_FILES + endif + + ifeq ($(call isTargetOs, windows), true) + ifeq ($$($1_WINDOWS_JAVAW), true) + $1_CFLAGS += -DJAVAW + endif endif ifneq ($$($1_JAVA_ARGS), ) @@ -143,7 +145,6 @@ define SetupBuildLauncherBody -DLAUNCHER_NAME='"$$(LAUNCHER_NAME)"' \ -DPROGNAME='"$1"' \ $$($1_CFLAGS), \ - CFLAGS_windows := $$($1_CFLAGS_windows), \ EXTRA_HEADER_DIRS := java.base:libjvm, \ JAVA_HEADERS := false, \ DISABLED_WARNINGS_gcc := unused-function unused-variable, \ @@ -154,13 +155,6 @@ define SetupBuildLauncherBody LDFLAGS_FILTER_OUT := $$($1_LDFLAGS_FILTER_OUT), \ JDK_LIBS := $$($1_JDK_LIBS), \ JDK_LIBS_windows := $$($1_JDK_LIBS_windows), \ - LIBS := $$($1_LIBS), \ - LIBS_unix := $(LIBZ_LIBS), \ - LIBS_linux := $(LIBDL) -lpthread, \ - LIBS_macosx := \ - -framework ApplicationServices \ - -framework Cocoa \ - -framework Security, \ LINK_TYPE := $$($1_LINK_TYPE), \ OUTPUT_DIR := $$($1_OUTPUT_DIR), \ OBJECT_DIR := $$($1_OBJECT_DIR), \ diff --git a/make/modules/java.base/Launcher.gmk b/make/modules/java.base/Launcher.gmk index 024c1c4731b0c..246767f393718 100644 --- a/make/modules/java.base/Launcher.gmk +++ b/make/modules/java.base/Launcher.gmk @@ -38,7 +38,8 @@ JAVA_RCFLAGS ?= -I$(TOPDIR)/src/java.base/windows/native/launcher/icons ################################################################################ $(eval $(call SetupBuildLauncher, java, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ + ENABLE_ARG_FILES := true, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ OPTIMIZATION := HIGH, \ @@ -50,7 +51,9 @@ $(eval $(call SetupBuildLauncher, java, \ ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupBuildLauncher, javaw, \ - CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ + ENABLE_ARG_FILES := true, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ + WINDOWS_JAVAW := true, \ EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ )) diff --git a/make/modules/jdk.compiler/Launcher.gmk b/make/modules/jdk.compiler/Launcher.gmk index e80c31bcb18f3..e5c4bbe4b8cdb 100644 --- a/make/modules/jdk.compiler/Launcher.gmk +++ b/make/modules/jdk.compiler/Launcher.gmk @@ -32,7 +32,7 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, javac, \ MAIN_CLASS := com.sun.tools.javac.Main, \ JAVA_ARGS := --add-modules ALL-DEFAULT, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) ################################################################################ @@ -41,5 +41,5 @@ $(eval $(call SetupBuildLauncher, javac, \ $(eval $(call SetupBuildLauncher, serialver, \ MAIN_CLASS := sun.tools.serialver.SerialVer, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/make/modules/jdk.javadoc/Launcher.gmk b/make/modules/jdk.javadoc/Launcher.gmk index 30d714be30d6a..608468962f382 100644 --- a/make/modules/jdk.javadoc/Launcher.gmk +++ b/make/modules/jdk.javadoc/Launcher.gmk @@ -32,5 +32,5 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, javadoc, \ MAIN_CLASS := jdk.javadoc.internal.tool.Main, \ JAVA_ARGS := --add-modules ALL-DEFAULT, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/make/modules/jdk.jconsole/Launcher.gmk b/make/modules/jdk.jconsole/Launcher.gmk index 3e65c3cccc37a..35d93d6feb917 100644 --- a/make/modules/jdk.jconsole/Launcher.gmk +++ b/make/modules/jdk.jconsole/Launcher.gmk @@ -36,5 +36,5 @@ $(eval $(call SetupBuildLauncher, jconsole, \ --add-modules ALL-DEFAULT \ -Djconsole.showOutputViewer \ -Djdk.attach.allowAttachSelf=true, \ - CFLAGS_windows := -DJAVAW, \ + WINDOWS_JAVAW := true, \ )) diff --git a/make/modules/jdk.jdeps/Launcher.gmk b/make/modules/jdk.jdeps/Launcher.gmk index 1aa54e16f4564..812d690a91d34 100644 --- a/make/modules/jdk.jdeps/Launcher.gmk +++ b/make/modules/jdk.jdeps/Launcher.gmk @@ -31,7 +31,7 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, javap, \ MAIN_CLASS := com.sun.tools.javap.Main, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) ################################################################################ @@ -40,7 +40,7 @@ $(eval $(call SetupBuildLauncher, javap, \ $(eval $(call SetupBuildLauncher, jdeps, \ MAIN_CLASS := com.sun.tools.jdeps.Main, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) ################################################################################ @@ -49,7 +49,7 @@ $(eval $(call SetupBuildLauncher, jdeps, \ $(eval $(call SetupBuildLauncher, jdeprscan, \ MAIN_CLASS := com.sun.tools.jdeprscan.Main, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) ################################################################################ @@ -58,5 +58,5 @@ $(eval $(call SetupBuildLauncher, jdeprscan, \ $(eval $(call SetupBuildLauncher, jnativescan, \ MAIN_CLASS := com.sun.tools.jnativescan.Main, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/make/modules/jdk.jfr/Launcher.gmk b/make/modules/jdk.jfr/Launcher.gmk index 2dd3586a92072..ad07c839f9073 100644 --- a/make/modules/jdk.jfr/Launcher.gmk +++ b/make/modules/jdk.jfr/Launcher.gmk @@ -31,5 +31,5 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, jfr, \ MAIN_CLASS := jdk.jfr.internal.tool.Main, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/make/modules/jdk.jlink/Launcher.gmk b/make/modules/jdk.jlink/Launcher.gmk index d427906519357..ef6f5ad1665bd 100644 --- a/make/modules/jdk.jlink/Launcher.gmk +++ b/make/modules/jdk.jlink/Launcher.gmk @@ -31,7 +31,7 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, jimage, \ MAIN_CLASS := jdk.tools.jimage.Main, \ - CFLAGS := -DENABLE_ARG_FILES, \ + ENABLE_ARG_FILES := true, \ )) ################################################################################ @@ -41,7 +41,8 @@ $(eval $(call SetupBuildLauncher, jimage, \ $(eval $(call SetupBuildLauncher, jlink, \ MAIN_CLASS := jdk.tools.jlink.internal.Main, \ JAVA_ARGS := --add-modules ALL-DEFAULT, \ - CFLAGS := -DENABLE_ARG_FILES -DEXPAND_CLASSPATH_WILDCARDS, \ + ENABLE_ARG_FILES := true, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) ################################################################################ @@ -50,5 +51,6 @@ $(eval $(call SetupBuildLauncher, jlink, \ $(eval $(call SetupBuildLauncher, jmod, \ MAIN_CLASS := jdk.tools.jmod.Main, \ - CFLAGS := -DENABLE_ARG_FILES -DEXPAND_CLASSPATH_WILDCARDS, \ + ENABLE_ARG_FILES := true, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/make/modules/jdk.jshell/Launcher.gmk b/make/modules/jdk.jshell/Launcher.gmk index bf555d7f64c13..66da3a9e5fcae 100644 --- a/make/modules/jdk.jshell/Launcher.gmk +++ b/make/modules/jdk.jshell/Launcher.gmk @@ -31,5 +31,5 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, jshell, \ MAIN_CLASS := jdk.internal.jshell.tool.JShellToolProvider, \ - CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \ + EXPAND_CLASSPATH_WILDCARDS := true, \ )) diff --git a/src/java.base/share/native/launcher/defines.h b/src/java.base/share/native/launcher/defines.h index ef0d6eecef9c6..a07a1db17a6fc 100644 --- a/src/java.base/share/native/launcher/defines.h +++ b/src/java.base/share/native/launcher/defines.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,18 +50,9 @@ static const char* const_progname = PROGNAME; static char* const_progname = NULL; #endif static const char* const_jargs[] = JAVA_ARGS; -#ifdef EXTRA_JAVA_ARGS -static const char* const_extra_jargs[] = EXTRA_JAVA_ARGS; -#else -static const char** const_extra_jargs = NULL; -#endif #else /* !JAVA_ARGS */ -#ifdef EXTRA_JAVA_ARGS -#error "EXTRA_JAVA_ARGS defined without JAVA_ARGS" -#endif static const char* const_progname = "java"; static const char** const_jargs = NULL; -static const char** const_extra_jargs = NULL; #endif /* JAVA_ARGS */ #ifdef LAUNCHER_NAME diff --git a/src/java.base/share/native/launcher/main.c b/src/java.base/share/native/launcher/main.c index c504c13154f5b..4e42e03dfc7c6 100644 --- a/src/java.base/share/native/launcher/main.c +++ b/src/java.base/share/native/launcher/main.c @@ -44,10 +44,6 @@ char **__initenv; int WINAPI WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow) { - int margc; - char** margv; - int jargc; - char** jargv; const jboolean const_javaw = JNI_TRUE; __initenv = _environ; @@ -56,47 +52,17 @@ WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow) JNIEXPORT int main(int argc, char **argv) { - int margc; - char** margv; - int jargc; - char** jargv; const jboolean const_javaw = JNI_FALSE; #endif /* JAVAW */ - { - int i, main_jargc, extra_jargc; - JLI_List list; - - main_jargc = (sizeof(const_jargs) / sizeof(char *)) > 1 - ? sizeof(const_jargs) / sizeof(char *) - : 0; // ignore the null terminator index - - extra_jargc = (sizeof(const_extra_jargs) / sizeof(char *)) > 1 - ? sizeof(const_extra_jargs) / sizeof(char *) - : 0; // ignore the null terminator index - if (main_jargc > 0 && extra_jargc > 0) { // combine extra java args - jargc = main_jargc + extra_jargc; - list = JLI_List_new(jargc + 1); - - for (i = 0 ; i < extra_jargc; i++) { - JLI_List_add(list, JLI_StringDup(const_extra_jargs[i])); - } - - for (i = 0 ; i < main_jargc ; i++) { - JLI_List_add(list, JLI_StringDup(const_jargs[i])); - } + int margc; + char** margv; + int jargc; + const char** jargv = const_jargs; - // terminate the list - JLI_List_add(list, NULL); - jargv = list->elements; - } else if (extra_jargc > 0) { // should never happen - fprintf(stderr, "EXTRA_JAVA_ARGS defined without JAVA_ARGS"); - abort(); - } else { // no extra args, business as usual - jargc = main_jargc; - jargv = (char **) const_jargs; - } - } + jargc = (sizeof(const_jargs) / sizeof(char *)) > 1 + ? sizeof(const_jargs) / sizeof(char *) + : 0; // ignore the null terminator index JLI_InitArgProcessing(jargc > 0, const_disable_argfile); @@ -182,7 +148,7 @@ main(int argc, char **argv) } #endif /* WIN32 */ return JLI_Launch(margc, margv, - jargc, (const char**) jargv, + jargc, jargv, 0, NULL, VERSION_STRING, DOT_VERSION, From 4b554b52e627b3a0f5e15a623b12089bff6bfafa Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 10 Jan 2025 18:50:40 +0000 Subject: [PATCH 015/263] 8346722: (fs) Files.probeContentType throws ClassCastException with custom file system provider Reviewed-by: alanb --- .../unix/classes/sun/nio/fs/DefaultFileTypeDetector.java | 7 ++----- test/jdk/java/nio/file/spi/SetDefaultProvider.java | 3 ++- test/jdk/java/nio/file/spi/testapp/testapp/Main.java | 5 ++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/java.base/unix/classes/sun/nio/fs/DefaultFileTypeDetector.java b/src/java.base/unix/classes/sun/nio/fs/DefaultFileTypeDetector.java index 295146d755e45..c3fa9a852e3f7 100644 --- a/src/java.base/unix/classes/sun/nio/fs/DefaultFileTypeDetector.java +++ b/src/java.base/unix/classes/sun/nio/fs/DefaultFileTypeDetector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. * 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,15 +25,12 @@ package sun.nio.fs; -import java.nio.file.FileSystems; import java.nio.file.spi.FileTypeDetector; -import java.nio.file.spi.FileSystemProvider; public class DefaultFileTypeDetector { private DefaultFileTypeDetector() { } public static FileTypeDetector create() { - FileSystemProvider provider = FileSystems.getDefault().provider(); - return ((UnixFileSystemProvider)provider).getFileTypeDetector(); + return DefaultFileSystemProvider.instance().getFileTypeDetector(); } } diff --git a/test/jdk/java/nio/file/spi/SetDefaultProvider.java b/test/jdk/java/nio/file/spi/SetDefaultProvider.java index f4486885b6a7e..4d74c8fee934e 100644 --- a/test/jdk/java/nio/file/spi/SetDefaultProvider.java +++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java @@ -23,7 +23,8 @@ /* * @test - * @bug 4313887 7006126 8142968 8178380 8183320 8210112 8266345 8263940 8331467 8346573 + * @bug 4313887 7006126 8142968 8178380 8183320 8210112 8266345 8263940 8331467 + * 8346573 8346722 * @modules jdk.jartool jdk.jlink * @library /test/lib * @build testfsp/* testapp/* CustomSystemClassLoader diff --git a/test/jdk/java/nio/file/spi/testapp/testapp/Main.java b/test/jdk/java/nio/file/spi/testapp/testapp/Main.java index f9c3b1e273eff..6f61d431707e1 100644 --- a/test/jdk/java/nio/file/spi/testapp/testapp/Main.java +++ b/test/jdk/java/nio/file/spi/testapp/testapp/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * 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,5 +58,8 @@ public static void main(String[] args) throws Exception { throw new RuntimeException("'path' not in default file system"); if (!path.equals(foo)) throw new RuntimeException(path + " not equal to " + foo); + + // exercise the file type detector + String fileType = Files.probeContentType(Path.of(".")); } } From d69463e4bcbddd346b9486059c5ad3a1cb555632 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Fri, 10 Jan 2025 19:30:27 +0000 Subject: [PATCH 016/263] 8347300: Don't exclude the "PATH" var from the environment when running app launchers in jpackage tests Reviewed-by: almatvee --- .../helpers/jdk/jpackage/test/Executor.java | 19 +++++++++-------- .../helpers/jdk/jpackage/test/HelloApp.java | 21 ++++++++++++++----- .../jpackage/share/AppLauncherEnvTest.java | 6 ++++-- .../jpackage/windows/WinChildProcessTest.java | 8 ++++--- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java index 7a0878d826b43..706e26668b191 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,6 @@ public static Executor of(String... cmdline) { public Executor() { saveOutputType = new HashSet<>(Set.of(SaveOutputType.NONE)); - removePathEnvVar = false; winEnglishOutput = false; } @@ -86,8 +85,8 @@ public Executor setExecutable(JavaTool v) { return setExecutable(v.getPath()); } - public Executor setRemovePathEnvVar(boolean value) { - removePathEnvVar = value; + public Executor removeEnvVar(String envVarName) { + removeEnvVars.add(Objects.requireNonNull(envVarName)); return this; } @@ -372,10 +371,12 @@ private Result runExecutable() throws IOException, InterruptedException { builder.directory(directory.toFile()); sb.append(String.format("; in directory [%s]", directory)); } - if (removePathEnvVar) { - // run this with cleared Path in Environment - TKit.trace("Clearing PATH in environment"); - builder.environment().remove("PATH"); + if (!removeEnvVars.isEmpty()) { + final var envComm = Comm.compare(builder.environment().keySet(), removeEnvVars); + builder.environment().keySet().removeAll(envComm.common()); + envComm.common().forEach(envVar -> { + TKit.trace(String.format("Clearing %s in environment", envVar)); + }); } trace("Execute " + sb.toString() + "..."); @@ -504,7 +505,7 @@ private static void trace(String msg) { private Path executable; private Set saveOutputType; private Path directory; - private boolean removePathEnvVar; + private Set removeEnvVars = new HashSet<>(); private boolean winEnglishOutput; private String winTmpDir = null; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java index 0c7476e863dc4..15fb41ca1e243 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -472,14 +472,14 @@ private Executor getExecutor(String...args) { } } - final List launcherArgs = List.of(args); - return new Executor() + final var executor = new Executor() .setDirectory(outputFile.getParent()) .saveOutput(saveOutput) .dumpOutput() - .setRemovePathEnvVar(removePathEnvVar) .setExecutable(executablePath) - .addArguments(launcherArgs); + .addArguments(List.of(args)); + + return configureEnvironment(executor); } private boolean launcherNoExit; @@ -496,6 +496,14 @@ public static AppOutputVerifier assertApp(Path helloAppLauncher) { return new AppOutputVerifier(helloAppLauncher); } + public static Executor configureEnvironment(Executor executor) { + if (CLEAR_JAVA_ENV_VARS) { + executor.removeEnvVar("JAVA_TOOL_OPTIONS"); + executor.removeEnvVar("_JAVA_OPTIONS"); + } + return executor; + } + static final String OUTPUT_FILENAME = "appOutput.txt"; private final JavaAppDesc appDesc; @@ -505,4 +513,7 @@ public static AppOutputVerifier assertApp(Path helloAppLauncher) { private static final String CLASS_NAME = HELLO_JAVA.getFileName().toString().split( "\\.", 2)[0]; + + private static final boolean CLEAR_JAVA_ENV_VARS = Optional.ofNullable( + TKit.getConfigProperty("clear-app-launcher-java-env-vars")).map(Boolean::parseBoolean).orElse(false); } diff --git a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java index a16ff9c18f96d..52016e6f4ab6a 100644 --- a/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java +++ b/test/jdk/tools/jpackage/share/AppLauncherEnvTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; +import static jdk.jpackage.test.HelloApp.configureEnvironment; import jdk.jpackage.test.TKit; /** @@ -53,6 +54,7 @@ public static void test() throws Exception { JPackageCommand cmd = JPackageCommand .helloAppImage(TEST_APP_JAVA + "*Hello") + .ignoreFakeRuntime() .addArguments("--java-options", "-D" + testAddDirProp + "=$APPDIR"); @@ -62,7 +64,7 @@ public static void test() throws Exception { final int attempts = 3; final int waitBetweenAttemptsSeconds = 5; - List output = new Executor() + List output = configureEnvironment(new Executor()) .saveOutput() .setExecutable(cmd.appLauncherPath().toAbsolutePath()) .addArguments("--print-env-var=" + envVarName) diff --git a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java index 5565d3dc50352..5b0ff9b1f01b4 100644 --- a/test/jdk/tools/jpackage/windows/WinChildProcessTest.java +++ b/test/jdk/tools/jpackage/windows/WinChildProcessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import java.nio.file.Path; import jdk.jpackage.test.JPackageCommand; +import static jdk.jpackage.test.HelloApp.configureEnvironment; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; import jdk.jpackage.test.TKit; @@ -54,14 +55,15 @@ public static void test() { long childPid = 0; try { JPackageCommand cmd = JPackageCommand - .helloAppImage(TEST_APP_JAVA + "*Hello"); + .helloAppImage(TEST_APP_JAVA + "*Hello") + .ignoreFakeRuntime(); // Create the image of the third party application launcher cmd.executeAndAssertImageCreated(); // Start the third party application launcher and dump and save the // output of the application - List output = new Executor().saveOutput().dumpOutput() + List output = configureEnvironment(new Executor()).saveOutput().dumpOutput() .setExecutable(cmd.appLauncherPath().toAbsolutePath()) .execute(0).getOutput(); String pidStr = output.get(0); From 01c8ba2cde881c3d483cb776ca17a5aa13123b23 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Fri, 10 Jan 2025 19:31:48 +0000 Subject: [PATCH 017/263] 8347298: Bug in JPackageCommand.ignoreFakeRuntime() Reviewed-by: almatvee --- .../helpers/jdk/jpackage/test/JPackageCommand.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index 68f26bfb261f1..bbf7d429f08cf 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -593,7 +593,7 @@ public Path appLauncherCfgPath(String launcherName) { } public boolean isFakeRuntime(String msg) { - if (isFakeRuntime()) { + if (isFakeRuntime(appRuntimeDirectory())) { // Fake runtime Path runtimeDir = appRuntimeDirectory(); TKit.trace(String.format( @@ -604,7 +604,7 @@ public boolean isFakeRuntime(String msg) { return false; } - private boolean isFakeRuntime() { + private static boolean isFakeRuntime(Path runtimeDir) { final Collection criticalRuntimeFiles; if (TKit.isWindows()) { criticalRuntimeFiles = WindowsHelper.CRITICAL_RUNTIME_FILES; @@ -616,7 +616,6 @@ private boolean isFakeRuntime() { throw TKit.throwUnknownPlatformError(); } - Path runtimeDir = appRuntimeDirectory(); return !criticalRuntimeFiles.stream().map(runtimeDir::resolve).allMatch( Files::exists); } @@ -690,10 +689,8 @@ public JPackageCommand ignoreDefaultRuntime(boolean v) { } public JPackageCommand ignoreFakeRuntime() { - if (isFakeRuntime()) { - ignoreDefaultRuntime(true); - } - return this; + return ignoreDefaultRuntime(Optional.ofNullable(DEFAULT_RUNTIME_IMAGE) + .map(JPackageCommand::isFakeRuntime).orElse(false)); } public JPackageCommand ignoreDefaultVerbose(boolean v) { From 10f7142dce296fedbb4d945378473d44ecde34b7 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Fri, 10 Jan 2025 19:32:05 +0000 Subject: [PATCH 018/263] 8347295: Fix WinResourceTest to make it work with WiX v4.0+ Reviewed-by: almatvee --- .../jdk/tools/jpackage/windows/WinResourceTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/jdk/tools/jpackage/windows/WinResourceTest.java b/test/jdk/tools/jpackage/windows/WinResourceTest.java index 72e805d0a48b5..db897e1aa694d 100644 --- a/test/jdk/tools/jpackage/windows/WinResourceTest.java +++ b/test/jdk/tools/jpackage/windows/WinResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,8 @@ import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Annotations.Parameters; import java.util.List; +import static jdk.jpackage.test.WindowsHelper.WixType.WIX3; +import static jdk.jpackage.test.WindowsHelper.getWixTypeFromVerboseJPackageOutput; /** * Test --resource-dir option. The test should set --resource-dir to point to @@ -83,11 +85,18 @@ public void test() throws IOException { .addBundleVerifier((cmd, result) -> { // Assert jpackage picked custom main.wxs and failed as expected by // examining its output + final String expectedWixErrorMsg; + if (getWixTypeFromVerboseJPackageOutput(result) == WIX3) { + expectedWixErrorMsg = "error CNDL0104 : Not a valid source file"; + } else { + expectedWixErrorMsg = "error WIX0104: Not a valid source file"; + } + TKit.assertTextStream(expectedLogMessage) .predicate(String::startsWith) .apply(JPackageCommand.stripTimestamps( result.getOutput().stream())); - TKit.assertTextStream("error CNDL0104 : Not a valid source file") + TKit.assertTextStream(expectedWixErrorMsg) .apply(result.getOutput().stream()); }) .setExpectedExitCode(1) From 6f1f2f2537cd921e2c13c333c78c2ad8c599dcc3 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Fri, 10 Jan 2025 21:23:50 +0000 Subject: [PATCH 019/263] 8347063: Add comments in ClassFileFormatVersion for class file format evolution history Reviewed-by: darcy, iris --- .../lang/reflect/ClassFileFormatVersion.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java b/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java index b2fa39e166170..70eb921a12454 100644 --- a/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java +++ b/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,47 @@ */ @SuppressWarnings("doclint:reference") // cross-module links public enum ClassFileFormatVersion { + /* + * Summary of class file format evolution; previews are listed for + * convenience, but they are not modeled by this enum. + * 1.1: InnerClasses, Synthetic, Deprecated attributes + * 1.2: ACC_STRICT modifier + * 1.3: no changes + * 1.4: no changes + * 1.5: Annotations (Runtime(Inv/V)isible(Parameter)Annotations attributes); + * Generics (Signature, LocalVariableTypeTable attributes); + * EnclosingMethod attribute + * 1.6: Verification by type checking (StackMapTable attribute) + * 1.7: Verification by type checking enforced (jsr and ret opcodes + * obsolete); java.lang.invoke support (JSR 292) (CONSTANT_MethodHandle, + * CONSTANT_MethodType, CONSTANT_InvokeDynamic constant pool entries, + * BoostrapMethods attribute); method must be ACC_STATIC + * 1.8: private, static, and non-abstract (default) methods in interfaces; + * Type Annotations (JEP 104) (Runtime(Inv/V)isibleTypeAnnotations + * attribute); MethodParameters attribute + * 9: JSR 376 - modules (JSR 376, JEP 261) (Module, ModuleMainClass, + * ModulePackages attributes, CONSTANT_Module, CONSTANT_Package + * constant pool entries, ACC_MODULE modifier) + * 10: minor tweak to requires_flags in Module attribute + * 11: Nest mates (JEP 181) (NestHost, NestMembers attributes); + * CONSTANT_Dynamic (JEP 309) constant pool entry + * 12: Preview Features (JEP 12) (minor version must be 0 or 65535) + * 13: no changes + * 14: no changes; (JEP 359 Records in Preview) + * 15: no changes; (JEP 384 Records in 2nd Preview, JEP 360 Sealed Classes + * in Preview) + * 16: Records (JEP 395) (Record attribute); (JEP 397 Sealed Classes in 2nd + * Preview) + * 17: Sealed Classes (JEP 409) (PermittedSubclasses attribute); ACC_STRICT + * modifier obsolete (JEP 306) + * 18: no changes + * 19: no changes + * 20: no changes + * 21: no changes + * 22: no changes + * 23: no changes + * 24: no changes + */ /** * The original version. From 761774a120f4aa326da3c55a000dacc5549762e9 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Fri, 10 Jan 2025 23:49:03 +0000 Subject: [PATCH 020/263] 8346143: add ClearAllFramePops function to speedup debugger single stepping in some cases Reviewed-by: cjplummer, amenkov --- src/hotspot/share/prims/jvmti.xml | 33 +++- src/hotspot/share/prims/jvmtiEnv.cpp | 29 ++- src/hotspot/share/prims/jvmtiEnvBase.cpp | 25 ++- src/hotspot/share/prims/jvmtiEnvBase.hpp | 17 +- .../share/prims/jvmtiEnvThreadState.cpp | 31 ++- .../share/prims/jvmtiEnvThreadState.hpp | 4 +- .../share/prims/jvmtiEventController.cpp | 18 +- .../share/prims/jvmtiEventController.hpp | 3 +- src/hotspot/share/prims/jvmtiExport.cpp | 7 +- .../ClearAllFramePops/ClearAllFramePops.java | 79 ++++++++ .../libClearAllFramePops.cpp | 176 ++++++++++++++++++ 11 files changed, 386 insertions(+), 36 deletions(-) create mode 100644 test/hotspot/jtreg/serviceability/jvmti/events/FramePop/ClearAllFramePops/ClearAllFramePops.java create mode 100644 test/hotspot/jtreg/serviceability/jvmti/events/FramePop/ClearAllFramePops/libClearAllFramePops.cpp diff --git a/src/hotspot/share/prims/jvmti.xml b/src/hotspot/share/prims/jvmti.xml index b63dfdfedb1aa..4bff3230c9ee3 100644 --- a/src/hotspot/share/prims/jvmti.xml +++ b/src/hotspot/share/prims/jvmti.xml @@ -1,7 +1,7 @@ m3 cycle - resolveAndBind(finder, "m1"); + assertThrows(ResolutionException.class, () -> resolveAndBind(finder, "m1")); } @@ -1554,8 +1573,8 @@ public void testCycleInProvider() { * - Configuration cf1: m1, m2 requires transitive m1 * - Configuration cf2: m1 requires m2 */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testReadModuleWithSameNameAsSelf() { + @Test + void testReadModuleWithSameNameAsSelf() { ModuleDescriptor descriptor1_v1 = newBuilder("m1") .build(); @@ -1573,7 +1592,7 @@ public void testReadModuleWithSameNameAsSelf() { // resolve should throw ResolutionException ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1_v2); - resolve(cf1, finder2, "m1"); + assertThrows(ResolutionException.class, () -> resolve(cf1, finder2, "m1")); } @@ -1585,8 +1604,8 @@ public void testReadModuleWithSameNameAsSelf() { * - Configuration cf2: m1, m3 requires transitive m1 * - Configuration cf3(cf1,cf2): m4 requires m2, m3 */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testReadTwoModuleWithSameName() { + @Test + void testReadTwoModuleWithSameName() { ModuleDescriptor descriptor1 = newBuilder("m1") .build(); @@ -1613,16 +1632,19 @@ public void testReadTwoModuleWithSameName() { // should throw ResolutionException as m4 will read modules named "m1". ModuleFinder finder3 = ModuleUtils.finderOf(descriptor4); - Configuration.resolve(finder3, List.of(cf1, cf2), ModuleFinder.of(), Set.of("m4")); + assertThrows(ResolutionException.class, + () -> Configuration.resolve(finder3, + List.of(cf1, cf2), + ModuleFinder.of(), + Set.of("m4"))); } /** * Test two modules exporting package p to a module that reads both. */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testPackageSuppliedByTwoOthers() { - + @Test + void testPackageSuppliedByTwoOthers() { ModuleDescriptor descriptor1 = newBuilder("m1") .requires("m2") .requires("m3") @@ -1640,7 +1662,7 @@ public void testPackageSuppliedByTwoOthers() { = ModuleUtils.finderOf(descriptor1, descriptor2, descriptor3); // m2 and m3 export package p to module m1 - resolve(finder, "m1"); + assertThrows(ResolutionException.class, () -> resolve(finder, "m1")); } @@ -1648,9 +1670,8 @@ public void testPackageSuppliedByTwoOthers() { * Test the scenario where a module contains a package p and reads * a module that exports package p. */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testPackageSuppliedBySelfAndOther() { - + @Test + void testPackageSuppliedBySelfAndOther() { ModuleDescriptor descriptor1 = newBuilder("m1") .requires("m2") .packages(Set.of("p")) @@ -1663,7 +1684,7 @@ public void testPackageSuppliedBySelfAndOther() { ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); // m1 contains package p, module m2 exports package p to m1 - resolve(finder, "m1"); + assertThrows(ResolutionException.class, () -> resolve(finder, "m1")); } @@ -1671,7 +1692,8 @@ public void testPackageSuppliedBySelfAndOther() { * Test the scenario where a module contains a package p and reads * a module that also contains a package p. */ - public void testContainsPackageInSelfAndOther() { + @Test + void testContainsPackageInSelfAndOther() { ModuleDescriptor descriptor1 = newBuilder("m1") .requires("m2") .packages(Set.of("p")) @@ -1702,8 +1724,8 @@ public void testContainsPackageInSelfAndOther() { * Test the scenario where a module that exports a package that is also * exported by a module that it reads in a parent layer. */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testExportSamePackageAsBootLayer() { + @Test + void testExportSamePackageAsBootLayer() { ModuleDescriptor descriptor = newBuilder("m1") .requires("java.base") .exports("java.lang") @@ -1714,14 +1736,15 @@ public void testExportSamePackageAsBootLayer() { Configuration bootConfiguration = ModuleLayer.boot().configuration(); // m1 contains package java.lang, java.base exports package java.lang to m1 - resolve(bootConfiguration, finder, "m1"); + assertThrows(ResolutionException.class, () -> resolve(bootConfiguration, finder, "m1")); } /** * Test "uses p.S" where p is contained in the same module. */ - public void testContainsService1() { + @Test + void testContainsService1() { ModuleDescriptor descriptor1 = newBuilder("m1") .packages(Set.of("p")) .uses("p.S") @@ -1739,8 +1762,8 @@ public void testContainsService1() { /** * Test "uses p.S" where p is contained in a different module. */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testContainsService2() { + @Test + void testContainsService2() { ModuleDescriptor descriptor1 = newBuilder("m1") .packages(Set.of("p")) .build(); @@ -1753,14 +1776,15 @@ public void testContainsService2() { ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); // m2 does not read a module that exports p - resolve(finder, "m2"); + assertThrows(ResolutionException.class, () -> resolve(finder, "m2")); } /** * Test "provides p.S" where p is contained in the same module. */ - public void testContainsService3() { + @Test + void testContainsService3() { ModuleDescriptor descriptor1 = newBuilder("m1") .packages(Set.of("p", "q")) .provides("p.S", List.of("q.S1")) @@ -1778,8 +1802,8 @@ public void testContainsService3() { /** * Test "provides p.S" where p is contained in a different module. */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testContainsService4() { + @Test + void testContainsService4() { ModuleDescriptor descriptor1 = newBuilder("m1") .packages(Set.of("p")) .build(); @@ -1792,46 +1816,182 @@ public void testContainsService4() { ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); // m2 does not read a module that exports p - resolve(finder, "m2"); + assertThrows(ResolutionException.class, () -> resolve(finder, "m2")); } + /** + * Test uses optional service. + * + * module m1 { requires static m2; uses p.S; } + */ + @Test + void testUsesOptionalService1() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .requires(Set.of(Requires.Modifier.STATIC), "m2") + .uses("p.S") + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 1); + assertTrue(cf.findModule("m1").isPresent()); + } /** - * Test "uses p.S" where p is not exported to the module. + * Test uses optional service. + * + * module m1 { requires m2; uses p.S; } + * module m2 { requires static transitive m3; } + */ + @Test + void testUsesOptionalService2() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .requires("m2") + .uses("p.S") + .build(); + ModuleDescriptor descriptor2 = newBuilder("m2") + .requires(Set.of(Requires.Modifier.STATIC, Requires.Modifier.TRANSITIVE), "m3") + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 2); + assertTrue(cf.findModule("m1").isPresent()); + assertTrue(cf.findModule("m2").isPresent()); + } + + /** + * Test uses optional service. + * + * module m1 { requires m2; uses p.S; } + * module m2 { requires transitive m3; } + * module m3 { requires static transitive m4; } */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testServiceTypePackageNotExported1() { + @Test + void testUsesOptionalService3() { ModuleDescriptor descriptor1 = newBuilder("m1") + .requires("m2") .uses("p.S") .build(); + ModuleDescriptor descriptor2 = newBuilder("m2") + .requires(Set.of(Requires.Modifier.TRANSITIVE), "m3") + .build(); + ModuleDescriptor descriptor3 = newBuilder("m3") + .requires(Set.of(Requires.Modifier.STATIC, Requires.Modifier.TRANSITIVE), "m4") + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2, descriptor3); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 3); + assertTrue(cf.findModule("m1").isPresent()); + assertTrue(cf.findModule("m2").isPresent()); + assertTrue(cf.findModule("m3").isPresent()); + } + /** + * Test provides optional service. + * + * module m1 { requires static m2; provides p.S with q.P; } + */ + @Test + void testProvidesOptionalService1() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .requires(Set.of(Requires.Modifier.STATIC), "m2") + .provides("p.S", List.of("q.P")) + .build(); ModuleFinder finder = ModuleUtils.finderOf(descriptor1); - - // m1 does not read a module that exports p - resolve(finder, "m1"); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 1); + assertTrue(cf.findModule("m1").isPresent()); } + /** + * Test provides optional service. + * + * module m1 { requires m2; provides p.S with q.P; } + * module m2 { requires static transitive m3; } + */ + @Test + void testProvidesOptionalService2() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .requires("m2") + .provides("p.S", List.of("q.P")) + .build(); + ModuleDescriptor descriptor2 = newBuilder("m2") + .requires(Set.of(Requires.Modifier.STATIC, Requires.Modifier.TRANSITIVE), "m3") + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 2); + assertTrue(cf.findModule("m1").isPresent()); + assertTrue(cf.findModule("m2").isPresent()); + } /** - * Test "provides p.S" where p is not exported to the module. + * Test provides optional service. + * + * module m1 { requires m2; provides p.S with q.P; } + * module m2 { requires transitive m3; } + * module m3 { requires static transitive m4; } */ - @Test(expectedExceptions = { ResolutionException.class }) - public void testServiceTypePackageNotExported2() { + @Test + void testProvidesOptionalService3() { ModuleDescriptor descriptor1 = newBuilder("m1") - .provides("p.S", List.of("q.T")) + .requires("m2") + .provides("p.S", List.of("q.P")) + .build(); + ModuleDescriptor descriptor2 = newBuilder("m2") + .requires(Set.of(Requires.Modifier.TRANSITIVE), "m3") .build(); + ModuleDescriptor descriptor3 = newBuilder("m3") + .requires(Set.of(Requires.Modifier.STATIC, Requires.Modifier.TRANSITIVE), "m4") + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2, descriptor3); + Configuration cf = resolve(finder, "m1"); + assertTrue(cf.modules().size() == 3); + assertTrue(cf.findModule("m1").isPresent()); + assertTrue(cf.findModule("m2").isPresent()); + assertTrue(cf.findModule("m3").isPresent()); + } + /** + * Test "uses p.S" where p is not exported to the module. + */ + @Test + void testServiceTypePackageNotExported1() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .uses("p.S") + .build(); ModuleFinder finder = ModuleUtils.finderOf(descriptor1); - // m1 does not read a module that exports p - resolve(finder, "m1"); + // m1 does not read a module that exports p to m1 + assertThrows(ResolutionException.class, () -> resolve(finder, "m1")); + } + + /** + * Test "uses p.S" where p is not exported to the module. + * + * module m1 { requires m2; uses p.S; } + * module m2 { contains p; } + */ + @Test + void testServiceTypePackageNotExported2() { + ModuleDescriptor descriptor1 = newBuilder("m1") + .requires("m2") + .uses("p.S") + .build(); + ModuleDescriptor descriptor2 = newBuilder("m2") + .packages(Set.of("p")) + .build(); + ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2); + + // m1 does not read a module that exports p to m1 + assertThrows(ResolutionException.class, () -> resolve(finder, "m1")); } /** * Test the empty configuration. */ - public void testEmptyConfiguration() { + @Test + void testEmptyConfiguration() { Configuration cf = Configuration.empty(); assertTrue(cf.parents().isEmpty()); @@ -1840,47 +2000,22 @@ public void testEmptyConfiguration() { assertFalse(cf.findModule("java.base").isPresent()); } - - // platform specific modules - - @DataProvider(name = "platformmatch") - public Object[][] createPlatformMatches() { - return new Object[][]{ - - { "", "" }, - { "linux-arm", "" }, - { "linux-arm", "linux-arm" }, - - }; - - }; - - @DataProvider(name = "platformmismatch") - public Object[][] createBad() { - return new Object[][] { - - { "linux-x64", "linux-arm" }, - { "linux-x64", "windows-x64" }, - - }; - } - /** * Test creating a configuration containing platform specific modules. */ - @Test(dataProvider = "platformmatch") - public void testPlatformMatch(String s1, String s2) throws IOException { - + @ParameterizedTest + @CsvSource({",", "linux-aarch64,", "linux-aarch64,linux-aarch64"}) + void testPlatformMatch(String targetPlatform1, String targetPlatform2) throws IOException { ModuleDescriptor base = ModuleDescriptor.newModule("java.base").build(); Path system = writeModule(base, null); ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1") .requires("m2") .build(); - Path dir1 = writeModule(descriptor1, s1); + Path dir1 = writeModule(descriptor1, targetPlatform1); ModuleDescriptor descriptor2 = ModuleDescriptor.newModule("m2").build(); - Path dir2 = writeModule(descriptor2, s2); + Path dir2 = writeModule(descriptor2, targetPlatform2); ModuleFinder finder = ModuleFinder.of(system, dir1, dir2); @@ -1893,43 +2028,45 @@ public void testPlatformMatch(String s1, String s2) throws IOException { } /** - * Test attempting to create a configuration with modules for different - * platforms. + * Test attempting to create a configuration with modules for different platforms. */ - @Test(dataProvider = "platformmismatch", - expectedExceptions = FindException.class ) - public void testPlatformMisMatch(String s1, String s2) throws IOException { - testPlatformMatch(s1, s2); + @ParameterizedTest + @CsvSource({"linux-x64,linux-aarch64", "linux-x64,windows-x64"}) + void testPlatformMisMatch(String targetPlatform1, String targetPlatform2) throws IOException { + assertThrows(FindException.class, + () -> testPlatformMatch(targetPlatform1, targetPlatform2)); } // no parents - @Test(expectedExceptions = { IllegalArgumentException.class }) - public void testResolveRequiresWithNoParents() { + @Test + void testResolveRequiresWithNoParents() { ModuleFinder empty = ModuleFinder.of(); - Configuration.resolve(empty, List.of(), empty, Set.of()); + assertThrows(IllegalArgumentException.class, + () -> Configuration.resolve(empty, List.of(), empty, Set.of())); } - @Test(expectedExceptions = { IllegalArgumentException.class }) - public void testResolveRequiresAndUsesWithNoParents() { + @Test + void testResolveRequiresAndUsesWithNoParents() { ModuleFinder empty = ModuleFinder.of(); - Configuration.resolveAndBind(empty, List.of(), empty, Set.of()); + assertThrows(IllegalArgumentException.class, + () -> Configuration.resolveAndBind(empty, List.of(), empty, Set.of())); } // parents with modules for specific platforms - @Test(dataProvider = "platformmatch") - public void testResolveRequiresWithCompatibleParents(String s1, String s2) - throws IOException - { - ModuleDescriptor base = ModuleDescriptor.newModule("java.base").build(); + @ParameterizedTest + @CsvSource({",", "linux-aarch64,", "linux-aarch64,linux-aarch64"}) + void testResolveRequiresWithCompatibleParents(String targetPlatform1, + String targetPlatform2) throws IOException { + ModuleDescriptor base = ModuleDescriptor.newModule("java.base").build(); Path system = writeModule(base, null); ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1").build(); - Path dir1 = writeModule(descriptor1, s1); + Path dir1 = writeModule(descriptor1, targetPlatform1); ModuleDescriptor descriptor2 = ModuleDescriptor.newModule("m2").build(); - Path dir2 = writeModule(descriptor2, s2); + Path dir2 = writeModule(descriptor2, targetPlatform2); ModuleFinder finder1 = ModuleFinder.of(system, dir1); Configuration cf1 = resolve(finder1, "m1"); @@ -1945,163 +2082,160 @@ public void testResolveRequiresWithCompatibleParents(String s1, String s2) } - @Test(dataProvider = "platformmismatch", - expectedExceptions = IllegalArgumentException.class ) - public void testResolveRequiresWithConflictingParents(String s1, String s2) - throws IOException - { - testResolveRequiresWithCompatibleParents(s1, s2); + @ParameterizedTest + @CsvSource({"linux-x64,linux-aarch64", "linux-x64,windows-x64"}) + void testResolveRequiresWithConflictingParents(String targetPlatform1, + String targetPlatform2) throws IOException { + assertThrows(IllegalArgumentException.class, + () -> testResolveRequiresWithCompatibleParents(targetPlatform1, targetPlatform2)); } // null handling - // finder1, finder2, roots - - - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull1() { - resolve((ModuleFinder)null, ModuleFinder.of()); + @Test + void testResolveRequiresWithNull1() { + assertThrows(NullPointerException.class, + () -> resolve((ModuleFinder) null, ModuleFinder.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull2() { - resolve(ModuleFinder.of(), (ModuleFinder)null); + @Test + void testResolveRequiresWithNull2() { + assertThrows(NullPointerException.class, + () -> resolve(ModuleFinder.of(), (ModuleFinder) null)); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull3() { + @Test + void testResolveRequiresWithNull3() { Configuration empty = Configuration.empty(); - Configuration.resolve(null, List.of(empty), ModuleFinder.of(), Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolve(null, List.of(empty), ModuleFinder.of(), Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull4() { + @Test + void testResolveRequiresWithNull4() { ModuleFinder empty = ModuleFinder.of(); - Configuration.resolve(empty, null, empty, Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolve(empty, null, empty, Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull5() { + @Test + void testResolveRequiresWithNull5() { Configuration cf = ModuleLayer.boot().configuration(); - Configuration.resolve(ModuleFinder.of(), List.of(cf), null, Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolve(ModuleFinder.of(), List.of(cf), null, Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresWithNull6() { + @Test + void testResolveRequiresWithNull6() { ModuleFinder empty = ModuleFinder.of(); Configuration cf = ModuleLayer.boot().configuration(); - Configuration.resolve(empty, List.of(cf), empty, null); + assertThrows(NullPointerException.class, + () -> Configuration.resolve(empty, List.of(cf), empty, null)); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull1() { - resolveAndBind((ModuleFinder) null, ModuleFinder.of()); + @Test + void testResolveRequiresAndUsesWithNull1() { + assertThrows(NullPointerException.class, + () -> resolveAndBind((ModuleFinder) null, ModuleFinder.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull2() { - resolveAndBind(ModuleFinder.of(), (ModuleFinder) null); + @Test + void testResolveRequiresAndUsesWithNull2() { + assertThrows(NullPointerException.class, + () -> resolveAndBind(ModuleFinder.of(), (ModuleFinder) null)); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull3() { + @Test + void testResolveRequiresAndUsesWithNull3() { Configuration empty = Configuration.empty(); - Configuration.resolveAndBind(null, List.of(empty), ModuleFinder.of(), Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolveAndBind(null, List.of(empty), ModuleFinder.of(), Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull4() { + @Test + void testResolveRequiresAndUsesWithNull4() { ModuleFinder empty = ModuleFinder.of(); - Configuration.resolveAndBind(empty, null, empty, Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolveAndBind(empty, null, empty, Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull5() { + @Test + void testResolveRequiresAndUsesWithNull5() { Configuration cf = ModuleLayer.boot().configuration(); - Configuration.resolveAndBind(ModuleFinder.of(), List.of(cf), null, Set.of()); + assertThrows(NullPointerException.class, + () -> Configuration.resolveAndBind(ModuleFinder.of(), List.of(cf), null, Set.of())); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testResolveRequiresAndUsesWithNull6() { + @Test + void testResolveRequiresAndUsesWithNull6() { ModuleFinder empty = ModuleFinder.of(); Configuration cf = ModuleLayer.boot().configuration(); - Configuration.resolveAndBind(empty, List.of(cf), empty, null); + assertThrows(NullPointerException.class, + () -> Configuration.resolveAndBind(empty, List.of(cf), empty, null)); } - @Test(expectedExceptions = { NullPointerException.class }) - public void testFindModuleWithNull() { - Configuration.empty().findModule(null); + @Test + void testFindModuleWithNull() { + assertThrows(NullPointerException.class, () -> Configuration.empty().findModule(null)); } // unmodifiable collections - @DataProvider(name = "configurations") - public Object[][] configurations() { - // empty, boot, and custom configurations - return new Object[][] { - { Configuration.empty(), null }, - { ModuleLayer.boot().configuration(), null }, - { resolve(ModuleFinder.of()), null }, - }; - } - - @Test(dataProvider = "configurations", - expectedExceptions = { UnsupportedOperationException.class }) - public void testUnmodifiableParents1(Configuration cf, Object ignore) { - cf.parents().add(Configuration.empty()); - } - - @Test(dataProvider = "configurations", - expectedExceptions = { UnsupportedOperationException.class }) - public void testUnmodifiableParents2(Configuration cf, Object ignore) { - cf.parents().remove(Configuration.empty()); + static Stream configurations() { + return Stream.of( + Configuration.empty(), + ModuleLayer.boot().configuration(), + resolve(ModuleFinder.of()) + ); } - @Test(dataProvider = "configurations", - expectedExceptions = { UnsupportedOperationException.class }) - public void testUnmodifiableModules1(Configuration cf, Object ignore) { - ResolvedModule module = ModuleLayer.boot() - .configuration() - .findModule("java.base") - .orElseThrow(); - cf.modules().add(module); + @ParameterizedTest + @MethodSource("configurations") + void testUnmodifiableParents(Configuration cf) { + assertThrows(UnsupportedOperationException.class, + () -> cf.parents().add(Configuration.empty())); + assertThrows(UnsupportedOperationException.class, + () -> cf.parents().remove(Configuration.empty())); } - @Test(dataProvider = "configurations", - expectedExceptions = { UnsupportedOperationException.class }) - public void testUnmodifiableModules2(Configuration cf, Object ignore) { + @ParameterizedTest + @MethodSource("configurations") + void testUnmodifiableModules(Configuration cf) { ResolvedModule module = ModuleLayer.boot() .configuration() .findModule("java.base") .orElseThrow(); - cf.modules().remove(module); + assertThrows(UnsupportedOperationException.class, + () -> cf.modules().add(module)); + assertThrows(UnsupportedOperationException.class, + () -> cf.modules().remove(module)); } /** * Invokes parent.resolve(...) */ - private Configuration resolve(Configuration parent, - ModuleFinder before, - ModuleFinder after, - String... roots) { + private static Configuration resolve(Configuration parent, + ModuleFinder before, + ModuleFinder after, + String... roots) { return parent.resolve(before, after, Set.of(roots)); } - private Configuration resolve(Configuration parent, - ModuleFinder before, - String... roots) { + private static Configuration resolve(Configuration parent, + ModuleFinder before, + String... roots) { return resolve(parent, before, ModuleFinder.of(), roots); } - private Configuration resolve(ModuleFinder before, - ModuleFinder after, - String... roots) { + private static Configuration resolve(ModuleFinder before, + ModuleFinder after, + String... roots) { return resolve(Configuration.empty(), before, after, roots); } - private Configuration resolve(ModuleFinder before, - String... roots) { + private static Configuration resolve(ModuleFinder before, + String... roots) { return resolve(Configuration.empty(), before, roots); } @@ -2109,27 +2243,27 @@ private Configuration resolve(ModuleFinder before, /** * Invokes parent.resolveAndBind(...) */ - private Configuration resolveAndBind(Configuration parent, - ModuleFinder before, - ModuleFinder after, - String... roots) { + private static Configuration resolveAndBind(Configuration parent, + ModuleFinder before, + ModuleFinder after, + String... roots) { return parent.resolveAndBind(before, after, Set.of(roots)); } - private Configuration resolveAndBind(Configuration parent, - ModuleFinder before, - String... roots) { + private static Configuration resolveAndBind(Configuration parent, + ModuleFinder before, + String... roots) { return resolveAndBind(parent, before, ModuleFinder.of(), roots); } - private Configuration resolveAndBind(ModuleFinder before, - ModuleFinder after, - String... roots) { + private static Configuration resolveAndBind(ModuleFinder before, + ModuleFinder after, + String... roots) { return resolveAndBind(Configuration.empty(), before, after, roots); } - private Configuration resolveAndBind(ModuleFinder before, - String... roots) { + private static Configuration resolveAndBind(ModuleFinder before, + String... roots) { return resolveAndBind(Configuration.empty(), before, roots); } @@ -2138,7 +2272,7 @@ private Configuration resolveAndBind(ModuleFinder before, * Writes a module-info.class. If {@code targetPlatform} is not null then * it includes the ModuleTarget class file attribute with the target platform. */ - static Path writeModule(ModuleDescriptor descriptor, String targetPlatform) + private static Path writeModule(ModuleDescriptor descriptor, String targetPlatform) throws IOException { ModuleTarget target; From 5431668cb92a8ef2ccfe1059db1cde0e5d98adce Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Sat, 25 Jan 2025 18:02:18 +0000 Subject: [PATCH 234/263] 8348212: Need to add warn() step to JavacTaskImpl after JDK-8344148 Reviewed-by: mcimadamore --- .../sun/tools/javac/api/JavacTaskImpl.java | 4 +- .../javac/api/TestJavacTaskWithWarning.java | 88 +++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 test/langtools/tools/javac/api/TestJavacTaskWithWarning.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index 80b1e9d7ea964..980ce060c3395 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -401,12 +401,12 @@ public Iterable analyze(Iterable classes) final ListBuffer results = new ListBuffer<>(); try { if (classes == null) { - handleFlowResults(compiler.flow(compiler.attribute(compiler.todo)), results); + handleFlowResults(compiler.warn(compiler.flow(compiler.attribute(compiler.todo))), results); } else { Filter f = new Filter() { @Override public void process(Env env) { - handleFlowResults(compiler.flow(compiler.attribute(env)), results); + handleFlowResults(compiler.warn(compiler.flow(compiler.attribute(env))), results); } }; f.run(compiler.todo, classes); diff --git a/test/langtools/tools/javac/api/TestJavacTaskWithWarning.java b/test/langtools/tools/javac/api/TestJavacTaskWithWarning.java new file mode 100644 index 0000000000000..70d8332720eca --- /dev/null +++ b/test/langtools/tools/javac/api/TestJavacTaskWithWarning.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 8348212 + * @summary Ensure the warn() phase executes when the compiler is invoked via the API + * @modules jdk.compiler/com.sun.tools.javac.api + */ + +import com.sun.tools.javac.api.JavacTaskImpl; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class TestJavacTaskWithWarning { + + static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + static final StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); + + public static void warningTest() throws Exception { + + // Create a source file that will generate a warning + String srcdir = System.getProperty("test.src"); + File file = new File(srcdir, "GeneratesWarning.java"); + try (PrintStream out = new PrintStream(new FileOutputStream(file))) { + out.print( + """ + public class GeneratesWarning { + public GeneratesWarning() { + hashCode(); // generates a "this-escape" warning + } + } + """); + } + + // Compile it using API + Iterable files = fm.getJavaFileObjectsFromFiles(List.of(file)); + StringWriter buf = new StringWriter(); + List options = List.of( + "-Xlint:this-escape", + "-XDrawDiagnostics" + ); + JavacTaskImpl task = (JavacTaskImpl)compiler.getTask(new PrintWriter(buf), fm, null, options, null, files); + task.analyze(); + + // Verify warning was generated + if (!buf.toString().contains("compiler.warn.possible.this.escape")) + throw new AssertionError("warning not found in:\n" + buf); + } + + public static void main(String[] args) throws Exception { + try { + warningTest(); + } finally { + fm.close(); + } + } +} From 99002e4f9d421d08d912187a1f01809d85820427 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Sat, 25 Jan 2025 18:59:20 +0000 Subject: [PATCH 235/263] 8318098: Update jfr tests to replace keyword jfr with vm.flagless Reviewed-by: mgronlun --- test/jdk/TEST.ROOT | 2 +- .../jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java | 3 ++- .../jdk/jfr/api/consumer/TestChunkInputStreamBulkRead.java | 3 ++- test/jdk/jdk/jfr/api/consumer/TestFieldAccess.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestGetStackTrace.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestHiddenMethod.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestMethodGetModifiers.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestReadTwice.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordedClass.java | 2 +- test/jdk/jdk/jfr/api/consumer/TestRecordedClassLoader.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordedEvent.java | 4 ++-- .../jdk/jfr/api/consumer/TestRecordedEventGetThread.java | 4 ++-- .../jfr/api/consumer/TestRecordedEventGetThreadOther.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordedFrameType.java | 2 +- .../jdk/jfr/api/consumer/TestRecordedFullStackTrace.java | 4 ++-- .../jfr/api/consumer/TestRecordedInstantEventTimestamp.java | 4 ++-- .../jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordedObject.java | 4 ++-- .../jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestRecordingFile.java | 4 ++-- .../jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java | 4 ++-- .../jdk/jfr/api/consumer/TestRecordingFileSanitization.java | 2 +- test/jdk/jdk/jfr/api/consumer/TestRecordingFileWrite.java | 2 +- test/jdk/jdk/jfr/api/consumer/TestRecordingInternals.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestSingleRecordedEvent.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/TestToString.java | 4 ++-- .../jdk/jfr/api/consumer/TestValueDescriptorRecorded.java | 4 ++-- .../jdk/jfr/api/consumer/filestream/TestMultipleChunk.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/log/TestContent.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestDiskOnOff.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestDynamicStart.java | 2 +- .../jdk/jfr/api/consumer/log/TestMemoryDiskTransition.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestMemoryOnly.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestSystemEvents.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestTruncation.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestUserEvents.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestVerbosity.java | 2 +- test/jdk/jdk/jfr/api/consumer/log/TestWithStreaming.java | 2 +- .../api/consumer/recordingstream/TestAwaitTermination.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestBasics.java | 4 ++-- .../jdk/jdk/jfr/api/consumer/recordingstream/TestClose.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestConstructor.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestDisable.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/recordingstream/TestDump.java | 2 +- .../jdk/jfr/api/consumer/recordingstream/TestEnable.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestMaxAge.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestOnClose.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestOnErrorAsync.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestOnErrorSync.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestOnEvent.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestOnFlush.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestOnMetadata.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestRecordingName.java | 2 +- .../jdk/jfr/api/consumer/recordingstream/TestRecursive.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestRemove.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestSetEndTime.java | 4 ++-- .../jdk/jfr/api/consumer/recordingstream/TestSetMaxAge.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestSetMaxSize.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestSetSettings.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestSetStartTime.java | 4 ++-- .../jdk/jdk/jfr/api/consumer/recordingstream/TestStart.java | 4 ++-- .../jfr/api/consumer/recordingstream/TestStartAsync.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java | 4 ++-- .../api/consumer/recordingstream/TestStoppedRecording.java | 4 ++-- .../consumer/streaming/TestBaseRepositoryAfterStart.java | 2 +- .../consumer/streaming/TestBaseRepositoryBeforeStart.java | 2 +- .../consumer/streaming/TestBaseRepositoryLastModified.java | 2 +- .../streaming/TestBaseRepositoryMultipleProcesses.java | 2 +- test/jdk/jdk/jfr/api/consumer/streaming/TestChunkGap.java | 4 ++-- .../api/consumer/streaming/TestCrossProcessStreaming.java | 4 ++-- .../jdk/jdk/jfr/api/consumer/streaming/TestEmptyChunks.java | 4 ++-- .../jdk/jfr/api/consumer/streaming/TestEnableEvents.java | 4 ++-- .../jfr/api/consumer/streaming/TestEventRegistration.java | 4 ++-- .../jdk/jfr/api/consumer/streaming/TestFilledChunks.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestFiltering.java | 4 ++-- .../jfr/api/consumer/streaming/TestInProcessMigration.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java | 4 ++-- .../jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java | 4 ++-- .../api/consumer/streaming/TestOutOfProcessMigration.java | 4 ++-- .../jdk/jfr/api/consumer/streaming/TestRecordingBefore.java | 4 ++-- .../jdk/jfr/api/consumer/streaming/TestRemovedChunks.java | 4 ++-- .../jfr/api/consumer/streaming/TestRepositoryProperty.java | 4 ++-- .../jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java | 4 ++-- .../jfr/api/consumer/streaming/TestStartSingleChunk.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestUnstarted.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestAbstractEvent.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestBeginEnd.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestClinitRegistration.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestClonedEvent.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestEnableDisable.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestEventDuration.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestEventFactory.java | 4 ++-- .../jdk/jfr/api/event/TestEventFactoryRegisterTwice.java | 4 ++-- .../jdk/jdk/jfr/api/event/TestEventFactoryRegistration.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestExtends.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestGetDuration.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestIsEnabled.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestIsEnabledMultiple.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestOwnCommit.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestShouldCommit.java | 4 ++-- test/jdk/jdk/jfr/api/event/TestStaticEnable.java | 4 ++-- .../jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java | 4 ++-- test/jdk/jdk/jfr/api/event/dynamic/TestEventFactory.java | 4 ++-- .../jdk/jfr/api/flightrecorder/TestAddListenerTwice.java | 4 ++-- .../jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java | 4 ++-- .../TestFlightRecorderListenerRecorderInitialized.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestGetEventTypes.java | 4 ++-- .../jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestGetRecordings.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestGetSettings.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestIsAvailable.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestIsInitialized.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestListener.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestListenerNull.java | 4 ++-- .../jfr/api/flightrecorder/TestPeriodicEventsSameHook.java | 4 ++-- .../flightrecorder/TestRecorderInitializationCallback.java | 4 ++-- .../jfr/api/flightrecorder/TestRegisterUnregisterEvent.java | 4 ++-- .../jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java | 4 ++-- test/jdk/jdk/jfr/api/flightrecorder/TestSnapshot.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestCategory.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestContentType.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestDescription.java | 4 ++-- .../jfr/api/metadata/annotations/TestDynamicAnnotation.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestEnabled.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestExperimental.java | 4 ++-- .../jfr/api/metadata/annotations/TestFieldAnnotations.java | 4 ++-- .../api/metadata/annotations/TestFormatMissingValue.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestHasValue.java | 4 ++-- .../api/metadata/annotations/TestInheritedAnnotations.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestLabel.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestMetadata.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestName.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/annotations/TestPeriod.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestRegistered.java | 4 ++-- .../metadata/annotations/TestRegisteredFalseAndRunning.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestRelational.java | 4 ++-- .../api/metadata/annotations/TestSimpleMetadataEvent.java | 4 ++-- .../jdk/jfr/api/metadata/annotations/TestStackFilter.java | 2 +- .../jdk/jfr/api/metadata/annotations/TestStackTrace.java | 4 ++-- .../jdk/jdk/jfr/api/metadata/annotations/TestThreshold.java | 4 ++-- .../jfr/api/metadata/annotations/TestTypesIdentical.java | 4 ++-- .../jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java | 4 ++-- .../api/metadata/eventtype/TestGetAnnotationElements.java | 4 ++-- .../jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java | 4 ++-- .../jdk/jdk/jfr/api/metadata/eventtype/TestGetCategory.java | 4 ++-- .../jfr/api/metadata/eventtype/TestGetDefaultValues.java | 4 ++-- .../jdk/jfr/api/metadata/eventtype/TestGetDescription.java | 4 ++-- .../jdk/jfr/api/metadata/eventtype/TestGetEventType.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java | 4 ++-- test/jdk/jdk/jfr/api/metadata/eventtype/TestGetFields.java | 4 ++-- .../jdk/jdk/jfr/api/metadata/eventtype/TestGetSettings.java | 4 ++-- .../jfr/api/metadata/eventtype/TestUnloadingEventClass.java | 4 ++-- .../api/metadata/settingdescriptor/TestDefaultValue.java | 4 ++-- .../api/metadata/settingdescriptor/TestGetAnnotation.java | 4 ++-- .../settingdescriptor/TestGetAnnotationElement.java | 4 ++-- .../api/metadata/settingdescriptor/TestGetContentType.java | 4 ++-- .../api/metadata/settingdescriptor/TestGetDescription.java | 4 ++-- .../jfr/api/metadata/settingdescriptor/TestGetLabel.java | 4 ++-- .../jdk/jfr/api/metadata/settingdescriptor/TestGetName.java | 4 ++-- .../jfr/api/metadata/settingdescriptor/TestGetTypeId.java | 4 ++-- .../jfr/api/metadata/settingdescriptor/TestGetTypeName.java | 4 ++-- .../jdk/jfr/api/metadata/valuedescriptor/TestClasses.java | 4 ++-- .../jfr/api/metadata/valuedescriptor/TestConstructor.java | 4 ++-- .../api/metadata/valuedescriptor/TestGetAnnotations.java | 4 ++-- .../jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java | 4 ++-- .../jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java | 4 ++-- .../jfr/api/metadata/valuedescriptor/TestSimpleTypes.java | 4 ++-- .../valuedescriptor/TestValueDescriptorContentType.java | 4 ++-- test/jdk/jdk/jfr/api/recorder/TestRecorderInitialized.java | 4 ++-- test/jdk/jdk/jfr/api/recorder/TestRecorderListener.java | 4 ++-- .../jdk/jfr/api/recorder/TestRecorderListenerWithDump.java | 2 +- test/jdk/jdk/jfr/api/recorder/TestStartStopRecording.java | 4 ++-- .../jfr/api/recording/destination/TestDestFileExist.java | 4 ++-- .../jfr/api/recording/destination/TestDestFileReadOnly.java | 4 ++-- .../jdk/jfr/api/recording/destination/TestDestInvalid.java | 4 ++-- .../jdk/jfr/api/recording/destination/TestDestLongPath.java | 4 ++-- .../jdk/jfr/api/recording/destination/TestDestMultiple.java | 4 ++-- .../jdk/jfr/api/recording/destination/TestDestReadOnly.java | 4 ++-- .../jdk/jfr/api/recording/destination/TestDestState.java | 4 ++-- .../jfr/api/recording/destination/TestDestToDiskFalse.java | 4 ++-- .../jfr/api/recording/destination/TestDestToDiskTrue.java | 4 ++-- .../jfr/api/recording/destination/TestDestWithDuration.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDump.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDumpDevNull.java | 2 +- test/jdk/jdk/jfr/api/recording/dump/TestDumpInvalid.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDumpLongPath.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDumpMultiple.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDumpReadOnly.java | 4 ++-- test/jdk/jdk/jfr/api/recording/dump/TestDumpState.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestChunkPeriod.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestEnableClass.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestEnableName.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestEventTime.java | 4 ++-- .../jfr/api/recording/event/TestLoadEventAfterStart.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestPeriod.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestReEnableClass.java | 4 ++-- .../jdk/jfr/api/recording/event/TestReEnableMultiple.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestReEnableName.java | 4 ++-- .../jfr/api/recording/event/TestRecordingEnableDisable.java | 4 ++-- test/jdk/jdk/jfr/api/recording/event/TestShortPeriod.java | 2 +- test/jdk/jdk/jfr/api/recording/event/TestThreshold.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestGetId.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestGetSize.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestGetSizeToMem.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestRecordingBase.java | 4 ++-- test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java | 4 ++-- test/jdk/jdk/jfr/api/recording/options/TestDuration.java | 4 ++-- test/jdk/jdk/jfr/api/recording/options/TestName.java | 4 ++-- .../recording/settings/TestConfigurationGetContents.java | 4 ++-- .../api/recording/settings/TestCreateConfigFromPath.java | 4 ++-- .../api/recording/settings/TestCreateConfigFromReader.java | 4 ++-- .../jfr/api/recording/settings/TestGetConfigurations.java | 4 ++-- .../api/recording/settings/TestSettingsAvailability.java | 4 ++-- test/jdk/jdk/jfr/api/recording/state/TestOptionState.java | 4 ++-- test/jdk/jdk/jfr/api/recording/state/TestState.java | 4 ++-- test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java | 4 ++-- .../api/recording/state/TestStateIdenticalListeners.java | 4 ++-- test/jdk/jdk/jfr/api/recording/state/TestStateInvalid.java | 4 ++-- test/jdk/jdk/jfr/api/recording/state/TestStateMultiple.java | 4 ++-- .../jdk/jfr/api/recording/state/TestStateScheduleStart.java | 4 ++-- test/jdk/jdk/jfr/api/recording/time/TestTime.java | 4 ++-- test/jdk/jdk/jfr/api/recording/time/TestTimeDuration.java | 4 ++-- test/jdk/jdk/jfr/api/recording/time/TestTimeMultiple.java | 4 ++-- .../jdk/jfr/api/recording/time/TestTimeScheduleStart.java | 4 ++-- test/jdk/jdk/jfr/api/settings/TestFilterEvents.java | 4 ++-- test/jdk/jdk/jfr/api/settings/TestSettingControl.java | 2 +- .../allocation/TestObjectAllocationInNewTLABEvent.java | 4 ++-- .../allocation/TestObjectAllocationOutsideTLABEvent.java | 4 ++-- .../event/allocation/TestObjectAllocationSampleEvent.java | 2 +- .../TestObjectAllocationSampleEventThrottling.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCodeCacheStats.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCompilerConfig.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java | 4 ++-- .../jfr/event/compiler/TestCompilerQueueUtilization.java | 2 +- test/jdk/jdk/jfr/event/compiler/TestCompilerStats.java | 4 ++-- test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java | 4 ++-- test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java | 4 ++-- .../jdk/jfr/event/gc/collection/TestG1ParallelPhases.java | 4 ++-- .../gc/collection/TestGCCauseWithG1ConcurrentMark.java | 4 ++-- .../gc/collection/TestGCCauseWithG1FullCollection.java | 4 ++-- .../jfr/event/gc/collection/TestGCCauseWithParallelOld.java | 4 ++-- .../jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java | 4 ++-- .../gc/collection/TestGCEventMixedWithG1ConcurrentMark.java | 4 ++-- .../gc/collection/TestGCEventMixedWithG1FullCollection.java | 4 ++-- .../gc/collection/TestGCEventMixedWithParallelOld.java | 4 ++-- .../jfr/event/gc/collection/TestGCEventMixedWithSerial.java | 4 ++-- .../event/gc/collection/TestGCGarbageCollectionEvent.java | 4 ++-- .../jdk/jdk/jfr/event/gc/collection/TestGCWithFasttime.java | 4 ++-- .../gc/collection/TestGarbageCollectionEventWithZMajor.java | 4 ++-- .../gc/collection/TestGarbageCollectionEventWithZMinor.java | 6 +++--- test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java | 4 ++-- .../TestYoungGarbageCollectionEventWithDefNew.java | 4 ++-- .../TestYoungGarbageCollectionEventWithG1New.java | 4 ++-- ...TestYoungGarbageCollectionEventWithParallelScavenge.java | 4 ++-- .../event/gc/collection/TestZOldGarbageCollectionEvent.java | 4 ++-- .../gc/collection/TestZYoungGarbageCollectionEvent.java | 4 ++-- .../event/gc/configuration/TestGCConfigurationEvent.java | 4 ++-- .../TestGCConfigurationEventWithDefaultPauseTarget.java | 4 ++-- .../TestGCHeapConfigurationEventWith32BitOops.java | 4 ++-- .../TestGCHeapConfigurationEventWithHeapBasedOops.java | 4 ++-- .../TestGCHeapConfigurationEventWithZeroBasedOops.java | 4 ++-- .../gc/configuration/TestGCSurvivorConfigurationEvent.java | 4 ++-- .../gc/configuration/TestGCTLABConfigurationEvent.java | 4 ++-- ...CYoungGenerationConfigurationEventWithMinAndMaxSize.java | 4 ++-- ...TestGCYoungGenerationConfigurationEventWithNewRatio.java | 4 ++-- .../jfr/event/gc/detailed/TestEvacuationFailedEvent.java | 4 ++-- .../jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java | 4 ++-- test/jdk/jdk/jfr/event/gc/detailed/TestG1AIHOPEvent.java | 4 ++-- .../event/gc/detailed/TestG1ConcurrentModeFailureEvent.java | 4 ++-- .../jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java | 4 ++-- .../event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java | 4 ++-- test/jdk/jdk/jfr/event/gc/detailed/TestG1IHOPEvent.java | 4 ++-- .../gc/detailed/TestG1InvalidHeapRegionTypeChangeEvent.java | 2 +- test/jdk/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java | 4 ++-- test/jdk/jdk/jfr/event/gc/detailed/TestGCCPUTimeEvent.java | 6 +++--- .../event/gc/detailed/TestGCHeapMemoryPoolUsageEvent.java | 2 +- .../jfr/event/gc/detailed/TestGCHeapMemoryUsageEvent.java | 2 +- test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java | 2 +- .../jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java | 6 +++--- .../jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java | 4 ++-- .../gc/detailed/TestPromotionEventWithParallelScavenge.java | 4 ++-- .../gc/detailed/TestPromotionFailedEventWithDefNew.java | 4 ++-- .../TestPromotionFailedEventWithParallelScavenge.java | 4 ++-- .../detailed/TestShenandoahEvacuationInformationEvent.java | 2 +- .../detailed/TestShenandoahHeapRegionInformationEvent.java | 2 +- .../detailed/TestShenandoahHeapRegionStateChangeEvent.java | 2 +- .../event/gc/detailed/TestTenuringDistributionEvent.java | 4 ++-- .../jfr/event/gc/detailed/TestZAllocationStallEvent.java | 4 ++-- .../jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java | 4 ++-- .../jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java | 4 ++-- .../jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java | 4 ++-- test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java | 4 ++-- test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java | 4 ++-- .../event/gc/heapsummary/TestHeapSummaryCommittedSize.java | 4 ++-- .../gc/heapsummary/TestHeapSummaryEventDefNewSerial.java | 6 +++--- .../jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java | 4 ++-- .../event/gc/heapsummary/TestHeapSummaryEventPSParOld.java | 4 ++-- .../TestObjectCountAfterGCEventWithG1ConcurrentMark.java | 4 ++-- .../TestObjectCountAfterGCEventWithG1FullCollection.java | 4 ++-- .../TestObjectCountAfterGCEventWithParallelOld.java | 4 ++-- .../objectcount/TestObjectCountAfterGCEventWithSerial.java | 4 ++-- .../jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java | 4 ++-- .../jfr/event/gc/refstat/TestRefStatEventWithDefNew.java | 4 ++-- .../gc/refstat/TestRefStatEventWithG1ConcurrentMark.java | 4 ++-- .../gc/refstat/TestRefStatEventWithG1FullCollection.java | 4 ++-- .../jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java | 4 ++-- .../event/gc/refstat/TestRefStatEventWithParallelOld.java | 4 ++-- .../gc/refstat/TestRefStatEventWithParallelScavenge.java | 4 ++-- .../stacktrace/TestDefNewAllocationPendingStackTrace.java | 4 ++-- .../TestG1HumongousAllocationPendingStackTrace.java | 4 ++-- .../gc/stacktrace/TestG1OldAllocationPendingStackTrace.java | 4 ++-- .../stacktrace/TestG1YoungAllocationPendingStackTrace.java | 4 ++-- .../TestMarkSweepCompactAllocationPendingStackTrace.java | 4 ++-- .../TestMetaspaceG1GCAllocationPendingStackTrace.java | 4 ++-- .../TestMetaspaceParallelGCAllocationPendingStackTrace.java | 4 ++-- .../TestMetaspaceSerialGCAllocationPendingStackTrace.java | 4 ++-- .../TestParallelMarkSweepAllocationPendingStackTrace.java | 4 ++-- .../TestParallelScavengeAllocationPendingStackTrace.java | 4 ++-- .../jdk/jfr/event/io/TestAsynchronousFileChannelEvents.java | 2 +- test/jdk/jdk/jfr/event/io/TestDeserializationEvent.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestDisabledEvents.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestFileReadOnly.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestFileStreamEvents.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestInstrumentation.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestRandomAccessFileEvents.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestRandomAccessFileThread.java | 4 ++-- .../jfr/event/io/TestSerializationMisdeclarationEvent.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java | 2 +- test/jdk/jdk/jfr/event/io/TestSocketChannelEvents.java | 4 ++-- test/jdk/jdk/jfr/event/io/TestSocketEvents.java | 4 ++-- .../jdk/jfr/event/metadata/TestDefaultConfigurations.java | 4 ++-- test/jdk/jdk/jfr/event/metadata/TestEventMetadata.java | 4 ++-- .../jdk/jfr/event/metadata/TestLookForUntestedEvents.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestAllocationTime.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestArrayInformation.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestCircularReference.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestFieldInformation.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestG1.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestHeapDeep.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestHeapShallow.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestLargeRootSet.java | 4 ++-- .../jdk/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestMetadataRetention.java | 6 +++--- test/jdk/jdk/jfr/event/oldobject/TestObjectAge.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestObjectDescription.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java | 2 +- test/jdk/jdk/jfr/event/oldobject/TestParallel.java | 4 ++-- .../jdk/jfr/event/oldobject/TestReferenceChainLimit.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestSanityDefault.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestSerial.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestShenandoah.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java | 4 ++-- test/jdk/jdk/jfr/event/oldobject/TestZ.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestCPUInformation.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestCPULoad.java | 2 +- test/jdk/jdk/jfr/event/os/TestCPUTimeStampCounter.java | 4 ++-- .../jdk/jfr/event/os/TestInitialEnvironmentVariable.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestOSInfo.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestPhysicalMemoryEvent.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestProcessStart.java | 2 +- test/jdk/jdk/jfr/event/os/TestSwapSpaceEvent.java | 6 +++--- test/jdk/jdk/jfr/event/os/TestSystemProcess.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestThreadContextSwitches.java | 4 ++-- test/jdk/jdk/jfr/event/os/TestVirtualizationInfo.java | 4 ++-- test/jdk/jdk/jfr/event/profiling/TestFullStackTrace.java | 4 ++-- test/jdk/jdk/jfr/event/profiling/TestNative.java | 4 ++-- .../jdk/jdk/jfr/event/profiling/TestSamplingLongPeriod.java | 4 ++-- .../jdk/jdk/jfr/event/runtime/TestActiveRecordingEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestClassDefineEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestClassLoadEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java | 4 ++-- .../jfr/event/runtime/TestClassLoadingStatisticsEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestClassRedefinition.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestClassUnloadEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java | 2 +- .../jfr/event/runtime/TestDirectBufferStatisticsEvent.java | 2 +- test/jdk/jdk/jfr/event/runtime/TestDumpReason.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestExceptionEvents.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestExceptionSubclass.java | 4 ++-- .../jdk/jfr/event/runtime/TestFinalizerStatisticsEvent.java | 2 +- test/jdk/jdk/jfr/event/runtime/TestFlush.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestJavaBlockedEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java | 4 ++-- .../jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java | 4 ++-- .../jfr/event/runtime/TestJavaThreadStatisticsEvent.java | 4 ++-- .../event/runtime/TestJavaThreadStatisticsEventBean.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java | 4 ++-- .../jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestNativeLibraryLoadEvent.java | 2 +- .../jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java | 4 ++-- .../jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestRedefineClasses.java | 4 ++-- .../jdk/jdk/jfr/event/runtime/TestResidentSetSizeEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestRetransformClasses.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestSizeTFlags.java | 4 ++-- .../jfr/event/runtime/TestSyncOnValueBasedClassEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java | 4 ++-- .../jdk/jdk/jfr/event/runtime/TestTableStatisticsEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestThreadAllocationEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadDumpEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadEndEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestThreadStartEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestVMOperation.java | 4 ++-- .../jdk/jfr/event/runtime/TestVirtualThreadEndEvent.java | 4 ++-- .../jdk/jfr/event/runtime/TestVirtualThreadStartEvent.java | 4 ++-- test/jdk/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java | 4 ++-- .../event/security/TestInitialSecurityPropertyEvent.java | 2 +- .../security/TestSecurityPropertyModificationEvent.java | 4 ++-- .../event/security/TestSecurityProviderServiceEvent.java | 2 +- test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java | 4 ++-- .../jdk/jfr/event/security/TestX509CertificateEvent.java | 4 ++-- .../jdk/jdk/jfr/event/security/TestX509ValidationEvent.java | 4 ++-- test/jdk/jdk/jfr/javaagent/TestEventInstrumentation.java | 4 ++-- test/jdk/jdk/jfr/javaagent/TestLoadedAgent.java | 4 ++-- test/jdk/jdk/jfr/javaagent/TestPremainAgent.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestFilenameExpansion.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdChangeLogLevel.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdConfigureReadOnly.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdDump.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdDumpLimited.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdLegacy.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdPreserveRepository.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdSaveToFile.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartGeneratedFilename.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStartWithSettings.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdStopWithoutFilename.java | 2 +- test/jdk/jdk/jfr/jcmd/TestJcmdView.java | 4 ++-- test/jdk/jdk/jfr/jcmd/TestJcmdViewMissingData.java | 2 +- test/jdk/jdk/jfr/jmx/TestClone.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestCloneRepeat.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestConfigurationInfo.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestCopyTo.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestCopyToInvalidPath.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestCopyToReadOnlyDir.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestCopyToRunning.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestEventTypes.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestFlightRecorderMXBeanLeak.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestGetRecordings.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestGetRecordingsMultiple.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestMultipleRecordings.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestNotificationListener.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestPredefinedConfiguration.java | 4 ++-- .../jdk/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingOptions.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingSettings.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingSettingsInvalid.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingSettingsMultiple.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingState.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestRecordingStateInvalid.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestSetConfiguration.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestSetConfigurationInvalid.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestSnapshot.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestStartRecording.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestStream.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestStreamClosed.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestStreamMultiple.java | 4 ++-- test/jdk/jdk/jfr/jmx/TestWrongId.java | 4 ++-- test/jdk/jdk/jfr/jmx/info/TestConfigurationInfo.java | 4 ++-- test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java | 4 ++-- test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java | 4 ++-- test/jdk/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java | 4 ++-- test/jdk/jdk/jfr/jmx/streaming/TestClose.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestDumpOrder.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestMetadataEvent.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestNew.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java | 4 ++-- test/jdk/jdk/jfr/jmx/streaming/TestRotate.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestStart.java | 2 +- test/jdk/jdk/jfr/jmx/streaming/TestStop.java | 2 +- test/jdk/jdk/jfr/jvm/TestBeginAndEnd.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestChunkIntegrity.java | 2 +- test/jdk/jdk/jfr/jvm/TestClassId.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java | 6 +++--- test/jdk/jdk/jfr/jvm/TestCounterTime.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestCreateNative.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestEventDuration.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestEventWriterLog.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestFatEvent.java | 2 +- test/jdk/jdk/jfr/jvm/TestFormatDuration.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestGetEventWriter.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestGetEventWriterPackage.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestGetEventWriterReflection.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestHiddenWait.java | 2 +- test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestJavaEvent.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestLargeJavaEvent512k.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestLargeJavaEvent64k.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestLogImplementation.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestLogOutput.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestLongStringsInPool.java | 2 +- test/jdk/jdk/jfr/jvm/TestModularImage.java | 2 +- test/jdk/jdk/jfr/jvm/TestPid.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestPrimitiveClasses.java | 2 +- test/jdk/jdk/jfr/jvm/TestThreadExclusion.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestUnloadEventClassCount.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestUnsupportedVM.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestVerifyInstrumentation.java | 2 +- test/jdk/jdk/jfr/jvm/TestVirtualThreadExclusion.java | 4 ++-- test/jdk/jdk/jfr/jvm/TestWaste.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestEventSettings.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestFlushInterval.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java | 4 ++-- .../jdk/jfr/startupargs/TestMultipleStartupRecordings.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java | 2 +- test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java | 2 +- test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestRetransform.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartDelay.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartDuration.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartHelp.java | 2 +- test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartName.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartRecording.java | 4 ++-- test/jdk/jdk/jfr/startupargs/TestStartupMessage.java | 4 ++-- .../jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java | 2 +- test/jdk/jdk/jfr/threading/TestDeepVirtualStackTrace.java | 4 ++-- test/jdk/jdk/jfr/threading/TestManyVirtualThreads.java | 4 ++-- test/jdk/jdk/jfr/threading/TestNestedVirtualThreads.java | 4 ++-- .../jfr/threading/TestStringPoolVirtualThreadPinning.java | 2 +- test/jdk/jdk/jfr/tool/TestAssemble.java | 2 +- test/jdk/jdk/jfr/tool/TestConfigure.java | 2 +- test/jdk/jdk/jfr/tool/TestDisassemble.java | 4 ++-- test/jdk/jdk/jfr/tool/TestHelp.java | 4 ++-- test/jdk/jdk/jfr/tool/TestMetadata.java | 4 ++-- test/jdk/jdk/jfr/tool/TestPrint.java | 4 ++-- test/jdk/jdk/jfr/tool/TestPrintDefault.java | 4 ++-- test/jdk/jdk/jfr/tool/TestPrintJSON.java | 4 ++-- test/jdk/jdk/jfr/tool/TestPrintXML.java | 4 ++-- test/jdk/jdk/jfr/tool/TestScrub.java | 2 +- test/jdk/jdk/jfr/tool/TestSummary.java | 4 ++-- test/jdk/jdk/jfr/tool/TestView.java | 2 +- 582 files changed, 1090 insertions(+), 1088 deletions(-) diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index 1b08167ff34f5..db48d501707b7 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -47,7 +47,7 @@ # tests which require two displays connected. keys=headful sound printer multimon \ - i18n intermittent randomness jfr cgroups + i18n intermittent randomness cgroups # Tests that must run in othervm mode othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/swing javax/print \ diff --git a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java index 07f796d47d329..e4eaccc0057c3 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java +++ b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,7 +24,7 @@ /** * @test TestChunkInputStreamAvailable - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestChunkInputStreamAvailable diff --git a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamBulkRead.java b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamBulkRead.java index 15bf1b7707c6d..5733f2f0cf654 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamBulkRead.java +++ b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamBulkRead.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Palantir Technologies, Inc. and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,7 +24,7 @@ /** * @test TestChunkInputStreamBulkRead - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestChunkInputStreamBulkRead diff --git a/test/jdk/jdk/jfr/api/consumer/TestFieldAccess.java b/test/jdk/jdk/jfr/api/consumer/TestFieldAccess.java index 3a35ca6d7512b..bb2e145467ce7 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestFieldAccess.java +++ b/test/jdk/jdk/jfr/api/consumer/TestFieldAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestFieldAccess diff --git a/test/jdk/jdk/jfr/api/consumer/TestGetStackTrace.java b/test/jdk/jdk/jfr/api/consumer/TestGetStackTrace.java index fa26270ccebb2..9dcdfaf84e0dd 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestGetStackTrace.java +++ b/test/jdk/jdk/jfr/api/consumer/TestGetStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test * @summary Verifies that a recorded JFR event has the correct stack trace info - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestGetStackTrace diff --git a/test/jdk/jdk/jfr/api/consumer/TestHiddenMethod.java b/test/jdk/jdk/jfr/api/consumer/TestHiddenMethod.java index ad68e016a1a10..969016ebf35ea 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestHiddenMethod.java +++ b/test/jdk/jdk/jfr/api/consumer/TestHiddenMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/consumer/TestMethodGetModifiers.java b/test/jdk/jdk/jfr/api/consumer/TestMethodGetModifiers.java index 9b5505c55deb9..d98fbdfcfd542 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestMethodGetModifiers.java +++ b/test/jdk/jdk/jfr/api/consumer/TestMethodGetModifiers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Verifies that a recorded method has the correct modifier - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xint jdk.jfr.api.consumer.TestMethodGetModifiers diff --git a/test/jdk/jdk/jfr/api/consumer/TestReadTwice.java b/test/jdk/jdk/jfr/api/consumer/TestReadTwice.java index 97ef76ece85b5..8990ffaa03d2b 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestReadTwice.java +++ b/test/jdk/jdk/jfr/api/consumer/TestReadTwice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Reads the recorded file two times and verifies that both reads are the same - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestReadTwice diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedClass.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedClass.java index 19c637049197c..003e8c91edd00 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedClass.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedClass.java @@ -35,7 +35,7 @@ /** * @test * @summary Verifies methods of RecordedClass - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedClass diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedClassLoader.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedClassLoader.java index a7b03149ce92e..f58c4051d3c27 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedClassLoader.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Verifies the methods of the RecordedClassLoader - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedClassLoader diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedEvent.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedEvent.java index 9223d2ef5ad0f..1bfeb8accec1e 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedEvent.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Verifies the methods of the RecordedEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedEvent diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThread.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThread.java index d3d581bc374ba..f05846b7284d4 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThread.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Tests that the RecordedEvent.getThread() returns th expected info - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedEventGetThread diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java index daaec8c05576b..2e5e767b0e10e 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Tests that the RecordedEvent.getThread() returns th expected info - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedEventGetThreadOther diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java index 611ed0e688f47..2e6abd960a826 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Simple test for RecordedFrame APIs - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedFrame diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedFrameType.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedFrameType.java index a44bdd371f073..c988f37bd0b4d 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedFrameType.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedFrameType.java @@ -39,7 +39,7 @@ /** * @test * @summary Test jdk.jfr.consumer.RecordedFrame::getType() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.compiler1.enabled * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java index 18fcb30038205..7506932981137 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedFullStackTrace diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java index 8c37fe8743b2f..c4f2966d40a5b 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Tests that an instant event gets recorded with its start time equal to its end time - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedInstantEventTimestamp diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java index 884697c26a531..a80203543960c 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary Verifies that the method descriptor is correct - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedMethodDescriptor diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedObject.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedObject.java index 17878ff7e6ce6..772a0ca641954 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedObject.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Verifies the methods of the RecordedObject - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedObject diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java b/test/jdk/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java index dae9b8fc11a8d..e5b40a34d1ef3 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Tests getParent method in RecordedThreadGroup - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordedThreadGroupParent diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordingFile.java b/test/jdk/jdk/jfr/api/consumer/TestRecordingFile.java index a81262f9405c8..5aeee69cadc2e 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordingFile.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordingFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Verifies that all methods in RecordingFIle are working - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr*=info jdk.jfr.api.consumer.TestRecordingFile diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java index 1c98f293c243d..c92b2362ce4b3 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Verifies that RecordingFile.readEvent() throws EOF when past the last record - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordingFileReadEventEof diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileSanitization.java b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileSanitization.java index 75e01f82cd403..dfa39b4ad8595 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileSanitization.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileSanitization.java @@ -35,7 +35,7 @@ /** * @test * @summary Verifies that all traces of sensitive data is removed - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordingFileSanitization diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileWrite.java b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileWrite.java index f4cf5a20805fd..5fc0dab0d30aa 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordingFileWrite.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordingFileWrite.java @@ -39,7 +39,7 @@ /** * @test * @summary Tests RecordingFile::write(Path, Predicate) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordingFileWrite diff --git a/test/jdk/jdk/jfr/api/consumer/TestRecordingInternals.java b/test/jdk/jdk/jfr/api/consumer/TestRecordingInternals.java index 75513f5b7b44f..efa36c799878b 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestRecordingInternals.java +++ b/test/jdk/jdk/jfr/api/consumer/TestRecordingInternals.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Tests that chunks are read in order and constant pools from multiple chunks can be read - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestRecordingInternals diff --git a/test/jdk/jdk/jfr/api/consumer/TestSingleRecordedEvent.java b/test/jdk/jdk/jfr/api/consumer/TestSingleRecordedEvent.java index f8bd63b915a68..1580647b43c72 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestSingleRecordedEvent.java +++ b/test/jdk/jdk/jfr/api/consumer/TestSingleRecordedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Verifies that a single JFR event is recorded as expected - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestSingleRecordedEvent diff --git a/test/jdk/jdk/jfr/api/consumer/TestToString.java b/test/jdk/jdk/jfr/api/consumer/TestToString.java index 3c36317662471..7f75a55e0f1ba 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestToString.java +++ b/test/jdk/jdk/jfr/api/consumer/TestToString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Sanity checks that RecordedEvent#toString returns something valid - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestToString diff --git a/test/jdk/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java b/test/jdk/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java index 4fc90c10cf1e5..aa6ac255ba0c0 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java +++ b/test/jdk/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Verifies that the recorded value descriptors are correct - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.TestValueDescriptorRecorded diff --git a/test/jdk/jdk/jfr/api/consumer/filestream/TestMultipleChunk.java b/test/jdk/jdk/jfr/api/consumer/filestream/TestMultipleChunk.java index d0fed7477ebc1..5efe203161405 100644 --- a/test/jdk/jdk/jfr/api/consumer/filestream/TestMultipleChunk.java +++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestMultipleChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Verifies that it is possible to stream contents from a multichunked file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.filestream.TestMultipleChunk diff --git a/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java b/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java index 58f23350dd07e..a2c127afdce13 100644 --- a/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java +++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Test EventStream::setOrdered(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.filestream.TestOrdered diff --git a/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java b/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java index ff26fd7269d67..7d34f00c891bc 100644 --- a/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java +++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Test EventStream::setReuse(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.filestream.TestReuse diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestContent.java b/test/jdk/jdk/jfr/api/consumer/log/TestContent.java index c6ef6f960f54e..75a2b98ac96f6 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestContent.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestContent.java @@ -32,7 +32,7 @@ * @test * @summary Tests that the event payload is printed when using * -Xlog:jfr+event=trace - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestDiskOnOff.java b/test/jdk/jdk/jfr/api/consumer/log/TestDiskOnOff.java index 0f8f0cf3ba7b0..220820e3c9955 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestDiskOnOff.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestDiskOnOff.java @@ -27,7 +27,7 @@ /** * @test * @summary Tests that event logging can't be turned on and off - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestDynamicStart.java b/test/jdk/jdk/jfr/api/consumer/log/TestDynamicStart.java index b24e96c53bb56..e598d4302a1c7 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestDynamicStart.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestDynamicStart.java @@ -35,7 +35,7 @@ * @test * @summary Tests that log responds to log level changes after JVM has * started - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestMemoryDiskTransition.java b/test/jdk/jdk/jfr/api/consumer/log/TestMemoryDiskTransition.java index 133318e837df2..6ffb22a38ebe8 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestMemoryDiskTransition.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestMemoryDiskTransition.java @@ -27,7 +27,7 @@ /** * @test * @summary Tests that transition between disk=true/false works - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestMemoryOnly.java b/test/jdk/jdk/jfr/api/consumer/log/TestMemoryOnly.java index d9faa0805ffae..618dbaffad893 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestMemoryOnly.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestMemoryOnly.java @@ -27,7 +27,7 @@ /** * @test * @summary Tests that a stream is not started if disk=false - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestSystemEvents.java b/test/jdk/jdk/jfr/api/consumer/log/TestSystemEvents.java index 01b57ed32757b..8d90684e5235a 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestSystemEvents.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestSystemEvents.java @@ -30,7 +30,7 @@ /** * @test * @summary Tests that only system events are emitted - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestTruncation.java b/test/jdk/jdk/jfr/api/consumer/log/TestTruncation.java index 84075053793c2..d2f6bf5b051cc 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestTruncation.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestTruncation.java @@ -31,7 +31,7 @@ /** * @test * @summary Tests that large output is truncated - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestUserEvents.java b/test/jdk/jdk/jfr/api/consumer/log/TestUserEvents.java index a6d2074645bad..62feb2b9dbd44 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestUserEvents.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestUserEvents.java @@ -30,7 +30,7 @@ /** * @test * @summary Tests that only user events are emitted - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestVerbosity.java b/test/jdk/jdk/jfr/api/consumer/log/TestVerbosity.java index 0533a0177f343..841f990a8d396 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestVerbosity.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestVerbosity.java @@ -32,7 +32,7 @@ /** * @test * @summary Tests output from various tag sets and levels - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/log/TestWithStreaming.java b/test/jdk/jdk/jfr/api/consumer/log/TestWithStreaming.java index fc5cd7b4fe042..78b4e959182c4 100644 --- a/test/jdk/jdk/jfr/api/consumer/log/TestWithStreaming.java +++ b/test/jdk/jdk/jfr/api/consumer/log/TestWithStreaming.java @@ -35,7 +35,7 @@ /** * @test * @summary Checks that it is possible to stream together with log stream - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.log.LogAnalyzer diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestAwaitTermination.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestAwaitTermination.java index 6d99f9dbb69f5..4477dc4f90190 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestAwaitTermination.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestAwaitTermination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test RecordingStream::awaitTermination(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestAwaitTermination diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestBasics.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestBasics.java index 1dbfeefa968c8..3adbbd1af43a6 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestBasics.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestBasics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Basic/sanity test for JFR event streaming - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestBasics diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestClose.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestClose.java index 8b3fbe88b90d0..c7e6c6e592284 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestClose.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Tests RecordingStream::close() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -Xlog:jfr+streaming+system=trace jdk.jfr.api.consumer.recordingstream.TestClose diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestConstructor.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestConstructor.java index 5cfc21d698c22..0597300d83f7f 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestConstructor.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Tests RecordingStream::RecordingStream() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestConstructor diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDisable.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDisable.java index e0eccf9198ecc..73345f346e30f 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDisable.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDisable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Tests RecordingStream::disable(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestDisable diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDump.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDump.java index 86c131aa246b9..cf4dad5477e24 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDump.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestDump.java @@ -41,7 +41,7 @@ /** * @test * @summary Tests RecordingStream::dump(Path) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestDump diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestEnable.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestEnable.java index 27ca64b790701..cde7d74ae0846 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestEnable.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestEnable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Tests RecordingStream::enable(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestEnable diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestMaxAge.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestMaxAge.java index 8803272e919de..64dbfa4173b28 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestMaxAge.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestMaxAge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Tests RecordingStream::setMaxAge(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestMaxAge diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnClose.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnClose.java index 9840511823269..3da0c62b8c8ad 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnClose.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Tests RecordingStream::onClose(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnClose diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorAsync.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorAsync.java index 7939a634d4d54..4e7effae9a2a7 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorAsync.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorAsync.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @summary Tests RecordingStream::onError(...) when using * RecordingStream:startAsync - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnErrorAsync diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorSync.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorSync.java index 2936070c3bf2f..4bf0ed0f6f696 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorSync.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnErrorSync.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Tests RecordingStream::onError(...) when using RecordingStream:start - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnErrorSync diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java index 390df2a2f562c..fa65553939901 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Tests RecordingStream::onEvent(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -Xlog:jfr+system+streaming=debug jdk.jfr.api.consumer.recordingstream.TestOnEvent diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnFlush.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnFlush.java index d895110274983..5f623f7ae5c81 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnFlush.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnFlush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Tests RecordingStream::onFlush(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnFlush diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java index 79ca66344549d..e8085736613e7 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +46,7 @@ /** * @test * @summary Tests RecordingStream::onMetadata(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnMetadata diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java index 813150e0d19db..18f2337547836 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java @@ -31,7 +31,7 @@ * @test * @bug 8257424 * @summary Tests recording name for RecordingStrream -* @key jfr +* @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestRecordingName diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecursive.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecursive.java index fb62d62b6c965..49cc9fc644f34 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecursive.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecursive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Tests that events are not emitted in handlers - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @build jdk.jfr.api.consumer.recordingstream.EventProducer diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRemove.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRemove.java index fc4ca6e272ee2..d8d0aeacfa085 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRemove.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRemove.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Tests RecordingStrream::remove(...) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestRemove diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java index 478e7a7f77edb..1e7a630e08459 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary Tests EventStream::setEndTime - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.api.consumer.recordingstream.TestSetEndTime diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxAge.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxAge.java index b8c2674e5c19c..80e05a6995c89 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxAge.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxAge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Tests RecordingStrream::setMaxAge - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestSetMaxAge diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxSize.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxSize.java index 8b350084e485c..764082b2f9ed7 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxSize.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetMaxSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test * @summary Tests RecordingStrream::setMaxSize -* @key jfr +* @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestSetMaxSize diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetSettings.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetSettings.java index 9f55c26540bca..e9cc19734e3b0 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetSettings.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Tests RecordingStream::setSettings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr+system+parser jdk.jfr.api.consumer.recordingstream.TestSetSettings diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetStartTime.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetStartTime.java index 06b28aaa79c36..95807cb2deba8 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetStartTime.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetStartTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Tests EventStream::setStartTime - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestSetStartTime diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStart.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStart.java index 719411b2fa0ae..f14d2cdceec64 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStart.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Tests RecordingStream::start() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @build jdk.jfr.api.consumer.recordingstream.EventProducer diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStartAsync.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStartAsync.java index 362fd1301150d..087b55801cdd8 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStartAsync.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStartAsync.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Tests RecordingStream::startAsync() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestStartAsync diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java index 36bbaa3c557db..5f23943e6cb00 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Tests RecordingStream::stop() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @build jdk.jfr.api.consumer.recordingstream.EventProducer diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStoppedRecording.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStoppedRecording.java index c0593f4d97bbf..a8bcb7f33687e 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStoppedRecording.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestStoppedRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * @test * @summary Tests that a RecordingStream is closed if the underlying Recording * is stopped. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestStoppedRecording diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryAfterStart.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryAfterStart.java index 6c4e5b8061559..2e0aceb3825dc 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryAfterStart.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryAfterStart.java @@ -32,7 +32,7 @@ * @test * @summary Test that it is possible to start a stream against a directory, * specified on command, line before the application starts - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.streaming.Application diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryBeforeStart.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryBeforeStart.java index 10f87402778d7..180a00988436d 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryBeforeStart.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryBeforeStart.java @@ -32,7 +32,7 @@ * @test * @summary Test that it is possible to start a stream against a directory, * specified on command line, after the application starts - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.streaming.Application diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryLastModified.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryLastModified.java index 2ca1c474acc83..6a9e8376ed2ba 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryLastModified.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryLastModified.java @@ -31,7 +31,7 @@ /** * @test * @summary Test that a stream starts against the latest created repository - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.streaming.Application diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryMultipleProcesses.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryMultipleProcesses.java index 6bda427b38734..95f6c5d4e5955 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryMultipleProcesses.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestBaseRepositoryMultipleProcesses.java @@ -33,7 +33,7 @@ * @summary Test that it is possible to start a stream against a directory, * specified on command line, where multiple processes starts * simultaneously - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.jfr.api.consumer.streaming.Application diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestChunkGap.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestChunkGap.java index 052914f08db21..bf5507815d6d1 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestChunkGap.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestChunkGap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ * @test * @summary Tests that a stream can gracefully handle chunk being removed in the * middle - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestChunkGap diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java index 313b5f026e1e2..b4bc1fec8f834 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ * @test * @summary Test scenario where JFR event producer is in a different process * with respect to the JFR event stream consumer. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.attach diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestEmptyChunks.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestEmptyChunks.java index 15de9597d637a..76940a99775c8 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestEmptyChunks.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestEmptyChunks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test that it is possible to iterate over chunk without normal events - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestEmptyChunks diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestEnableEvents.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestEnableEvents.java index 6e68872c464eb..99df63105a248 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestEnableEvents.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestEnableEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ * @test * @summary Verifies that it is possible to stream contents from specified event * settings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestEventRegistration.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestEventRegistration.java index 1934f4802afe9..d61fb197f75a7 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestEventRegistration.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestEventRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Test that it is possible to register new metadata in a chunk - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestEventRegistration diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestFilledChunks.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestFilledChunks.java index 18bfa57a4b18c..423e3969af8e3 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestFilledChunks.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestFilledChunks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test that it is possible to iterate over chunk with normal events - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestFilledChunks diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestFiltering.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestFiltering.java index a591faf34440a..d493a4475be79 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestFiltering.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestFiltering.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Verifies that it is possible to filter a stream for an event - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestFiltering diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java index 955226ec3fb24..5b9aeb50fa281 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @summary Verifies that is possible to stream from an in-process repository * that is being moved. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.consumer.streaming.TestInProcessMigration diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java index e1a95380477ea..3586421d41eab 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test that a stream ends/closes when an application crashes. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr jdk.attach java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java index 27dfb0224c1ac..9485919c8e354 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test that a stream ends/closes when an application exists. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr jdk.attach java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java index 4515ae9832a01..43c0559d47322 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary Verifies that EventStream::openRepository() read from the latest flush - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestLatestEvent diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestOutOfProcessMigration.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestOutOfProcessMigration.java index a21d5a3fda44a..0067467cf1bb0 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestOutOfProcessMigration.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestOutOfProcessMigration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @summary Verifies that a out-of-process stream is closed when the repository * is changed. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr jdk.attach java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestRecordingBefore.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestRecordingBefore.java index e79b6de6738e3..c5eca13cef46f 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestRecordingBefore.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestRecordingBefore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ * @test * @summary Verifies that it is possible to start a stream when there are * already chunk in the repository - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestRecordingBefore diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java index 05a8d8c5e51a0..f279f3acdfd2a 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Tests that a stream can gracefully handle chunk being removed - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr*=info jdk.jfr.api.consumer.streaming.TestRemovedChunks diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestRepositoryProperty.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestRepositoryProperty.java index e1fa206477f5a..e5151e8a496b3 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestRepositoryProperty.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestRepositoryProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ * @test * @summary Verifies that it is possible to access JFR repository from a system * property - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.attach diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java index baae06b8ec713..fbc27b051b0b8 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @summary Verifies that it is possible to stream contents of ongoing * recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr+system+streaming=trace diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestStartSingleChunk.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestStartSingleChunk.java index b97c8a7645318..92eeb5282c46a 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestStartSingleChunk.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestStartSingleChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ * @test * @summary Verifies that it is possible to stream contents of ongoing * recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr+system+streaming=trace diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestUnstarted.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestUnstarted.java index 998a8681519e5..1e947c092edc5 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestUnstarted.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestUnstarted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @test * @summary Verifies that it is possible to open a stream when a repository doesn't * exists - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.consumer.streaming.TestUnstarted diff --git a/test/jdk/jdk/jfr/api/event/TestAbstractEvent.java b/test/jdk/jdk/jfr/api/event/TestAbstractEvent.java index 1d6ac835be9a4..d1b320b94bffb 100644 --- a/test/jdk/jdk/jfr/api/event/TestAbstractEvent.java +++ b/test/jdk/jdk/jfr/api/event/TestAbstractEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Tests that abstract events are not part of metadata - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestAbstractEvent diff --git a/test/jdk/jdk/jfr/api/event/TestBeginEnd.java b/test/jdk/jdk/jfr/api/event/TestBeginEnd.java index 698b4f94ca286..4dfafa321ef93 100644 --- a/test/jdk/jdk/jfr/api/event/TestBeginEnd.java +++ b/test/jdk/jdk/jfr/api/event/TestBeginEnd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Test for RecordedEvent.getDuration() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestBeginEnd diff --git a/test/jdk/jdk/jfr/api/event/TestClinitRegistration.java b/test/jdk/jdk/jfr/api/event/TestClinitRegistration.java index 99a851eba7f5e..099fb8e721606 100644 --- a/test/jdk/jdk/jfr/api/event/TestClinitRegistration.java +++ b/test/jdk/jdk/jfr/api/event/TestClinitRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test enable/disable event and verify recording has expected events. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestClinitRegistration diff --git a/test/jdk/jdk/jfr/api/event/TestClonedEvent.java b/test/jdk/jdk/jfr/api/event/TestClonedEvent.java index adad7269bbd1f..336dee9609932 100644 --- a/test/jdk/jdk/jfr/api/event/TestClonedEvent.java +++ b/test/jdk/jdk/jfr/api/event/TestClonedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Tests that a cloned event can be successfully committed. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestClonedEvent diff --git a/test/jdk/jdk/jfr/api/event/TestEnableDisable.java b/test/jdk/jdk/jfr/api/event/TestEnableDisable.java index a953feafabe06..6b7576d74b95c 100644 --- a/test/jdk/jdk/jfr/api/event/TestEnableDisable.java +++ b/test/jdk/jdk/jfr/api/event/TestEnableDisable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test enable/disable event and verify recording has expected events. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestEnableDisable diff --git a/test/jdk/jdk/jfr/api/event/TestEventDuration.java b/test/jdk/jdk/jfr/api/event/TestEventDuration.java index f043ee26c53f8..d8b30f4af8e40 100644 --- a/test/jdk/jdk/jfr/api/event/TestEventDuration.java +++ b/test/jdk/jdk/jfr/api/event/TestEventDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Tests that a duration is recorded. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestEventDuration diff --git a/test/jdk/jdk/jfr/api/event/TestEventFactory.java b/test/jdk/jdk/jfr/api/event/TestEventFactory.java index 43c89f490b437..4aaf2e749babf 100644 --- a/test/jdk/jdk/jfr/api/event/TestEventFactory.java +++ b/test/jdk/jdk/jfr/api/event/TestEventFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary EventFactory simple test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestEventFactory diff --git a/test/jdk/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java b/test/jdk/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java index ed32b3586c2f8..479de103353f7 100644 --- a/test/jdk/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java +++ b/test/jdk/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Verifies that EventFactory can register the same event twice - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestEventFactoryRegisterTwice diff --git a/test/jdk/jdk/jfr/api/event/TestEventFactoryRegistration.java b/test/jdk/jdk/jfr/api/event/TestEventFactoryRegistration.java index 313c8060972e3..15640f56b68db 100644 --- a/test/jdk/jdk/jfr/api/event/TestEventFactoryRegistration.java +++ b/test/jdk/jdk/jfr/api/event/TestEventFactoryRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary EventFactory register/unregister API test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestEventFactoryRegistration diff --git a/test/jdk/jdk/jfr/api/event/TestExtends.java b/test/jdk/jdk/jfr/api/event/TestExtends.java index eae47911ba091..0121f2ce0911a 100644 --- a/test/jdk/jdk/jfr/api/event/TestExtends.java +++ b/test/jdk/jdk/jfr/api/event/TestExtends.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test with event class inheritance - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestExtends diff --git a/test/jdk/jdk/jfr/api/event/TestGetDuration.java b/test/jdk/jdk/jfr/api/event/TestGetDuration.java index b25969198edad..c4f6377f2194a 100644 --- a/test/jdk/jdk/jfr/api/event/TestGetDuration.java +++ b/test/jdk/jdk/jfr/api/event/TestGetDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test for RecordedEvent.getDuration() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestGetDuration diff --git a/test/jdk/jdk/jfr/api/event/TestIsEnabled.java b/test/jdk/jdk/jfr/api/event/TestIsEnabled.java index a94bea9ba62af..8474646608c5e 100644 --- a/test/jdk/jdk/jfr/api/event/TestIsEnabled.java +++ b/test/jdk/jdk/jfr/api/event/TestIsEnabled.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test Event.isEnabled() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestIsEnabled diff --git a/test/jdk/jdk/jfr/api/event/TestIsEnabledMultiple.java b/test/jdk/jdk/jfr/api/event/TestIsEnabledMultiple.java index 66256c69e4b6f..69db35cbf4973 100644 --- a/test/jdk/jdk/jfr/api/event/TestIsEnabledMultiple.java +++ b/test/jdk/jdk/jfr/api/event/TestIsEnabledMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test Event.isEnabled() with multiple recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestIsEnabledMultiple diff --git a/test/jdk/jdk/jfr/api/event/TestOwnCommit.java b/test/jdk/jdk/jfr/api/event/TestOwnCommit.java index 6ca058cfcc4b8..0186d86d82dca 100644 --- a/test/jdk/jdk/jfr/api/event/TestOwnCommit.java +++ b/test/jdk/jdk/jfr/api/event/TestOwnCommit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Use custom event that reuse method names begin, end and commit. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestOwnCommit diff --git a/test/jdk/jdk/jfr/api/event/TestShouldCommit.java b/test/jdk/jdk/jfr/api/event/TestShouldCommit.java index f28884b77a2d3..f26bb6c67fcf3 100644 --- a/test/jdk/jdk/jfr/api/event/TestShouldCommit.java +++ b/test/jdk/jdk/jfr/api/event/TestShouldCommit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Test jdk.jfr.Event::shouldCommit() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestShouldCommit diff --git a/test/jdk/jdk/jfr/api/event/TestStaticEnable.java b/test/jdk/jdk/jfr/api/event/TestStaticEnable.java index b1bc9bdab97f1..e7d116917b1b8 100644 --- a/test/jdk/jdk/jfr/api/event/TestStaticEnable.java +++ b/test/jdk/jdk/jfr/api/event/TestStaticEnable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Enable an event from a static function in the event. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.TestStaticEnable diff --git a/test/jdk/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java b/test/jdk/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java index 18fb3cc586533..c98be5bdbe3a2 100644 --- a/test/jdk/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java +++ b/test/jdk/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.dynamic.TestDynamicAnnotations diff --git a/test/jdk/jdk/jfr/api/event/dynamic/TestEventFactory.java b/test/jdk/jdk/jfr/api/event/dynamic/TestEventFactory.java index f61c81bb9ebdf..4385c459e3660 100644 --- a/test/jdk/jdk/jfr/api/event/dynamic/TestEventFactory.java +++ b/test/jdk/jdk/jfr/api/event/dynamic/TestEventFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.event.dynamic.TestEventFactory diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java b/test/jdk/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java index 8b273e9b905cd..3a6d566fb1d1a 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.flightrecorder.TestAddListenerTwice diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java b/test/jdk/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java index 78950a723da75..d838f31b8d9d9 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestAddPeriodicEvent diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java b/test/jdk/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java index 9f9315ea1c407..72e2e3cc92935 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestFlightRecorderListenerRecorderInitialized diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestGetEventTypes.java b/test/jdk/jdk/jfr/api/flightrecorder/TestGetEventTypes.java index 8a3abdb3046c2..248a4f385cfcf 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestGetEventTypes.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestGetEventTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm/timeout=600 jdk.jfr.api.flightrecorder.TestGetEventTypes diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java b/test/jdk/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java index bdbf0c53fa26e..52597f81b0d8c 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestGetPlatformRecorder diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestGetRecordings.java b/test/jdk/jdk/jfr/api/flightrecorder/TestGetRecordings.java index d4318134c580e..e0c8f9f0432fd 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestGetRecordings.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestGetRecordings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestGetRecordings diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestGetSettings.java b/test/jdk/jdk/jfr/api/flightrecorder/TestGetSettings.java index 68472f04bc418..85aaa177cf4bf 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestGetSettings.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestGetSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestGetSettings diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestIsAvailable.java b/test/jdk/jdk/jfr/api/flightrecorder/TestIsAvailable.java index 6e2cf4cf94202..9665319e64300 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestIsAvailable.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestIsAvailable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -XX:+FlightRecorder jdk.jfr.api.flightrecorder.TestIsAvailable true diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestIsInitialized.java b/test/jdk/jdk/jfr/api/flightrecorder/TestIsInitialized.java index 8d8dda1eaac3a..ebb6be410458b 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestIsInitialized.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestIsInitialized.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestIsInitialized diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestListener.java b/test/jdk/jdk/jfr/api/flightrecorder/TestListener.java index f039a60a2457c..90ceadfaf826c 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestListener.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.flightrecorder.TestListener diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestListenerNull.java b/test/jdk/jdk/jfr/api/flightrecorder/TestListenerNull.java index dab7f551af4d4..cab7346fa60ef 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestListenerNull.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestListenerNull.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestListenerNull diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java b/test/jdk/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java index f6e7f6a234037..5556020dc0f0d 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test * @summary Check that an IllegalArgumentException is thrown if event is added twice - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestPeriodicEventsSameHook diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java b/test/jdk/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java index ccb2245551bcc..a97b7b865bfd7 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Test Flight Recorder initialization callback is only called once - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestRecorderInitializationCallback diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java b/test/jdk/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java index 2a0088ec52a37..1481750c74c20 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestRegisterUnregisterEvent diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java b/test/jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java index 0b54f218c43c3..e186db41bc2de 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestSettingsControl diff --git a/test/jdk/jdk/jfr/api/flightrecorder/TestSnapshot.java b/test/jdk/jdk/jfr/api/flightrecorder/TestSnapshot.java index fbb41b7f15798..6070c68236dbd 100644 --- a/test/jdk/jdk/jfr/api/flightrecorder/TestSnapshot.java +++ b/test/jdk/jdk/jfr/api/flightrecorder/TestSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.flightrecorder.TestSnapshot diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestCategory.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestCategory.java index 4bb0083a0f35d..dbd33d013ae02 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestCategory.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestCategory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestCategory diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestContentType.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestContentType.java index 0c72ae8057159..1c38c21c3ae7e 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestContentType.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestContentType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestContentType diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestDescription.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestDescription.java index 57d86e85fdec1..6232346b871f6 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestDescription.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestDescription diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java index 5b2cae9278191..726ac9070d6ed 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestDynamicAnnotation diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestEnabled.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestEnabled.java index b5e60cedb8a23..3aafd264ff5da 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestEnabled.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestEnabled.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestEnabled diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestExperimental.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestExperimental.java index 3420debafa02d..5f044d34e24ab 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestExperimental.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestExperimental.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestExperimental diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java index 088639b674874..879ba0727f2a8 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestFieldAnnotations diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java index b7b61d09abac2..90ecb9fa7d8c1 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Check that event values are properly formatted and sanity check * that extreme values don't throws exceptions * @requires vm.hasJFR diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestHasValue.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestHasValue.java index c5194f1381c59..a2367cc3fe258 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestHasValue.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestHasValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestHasValue diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java index 16c7f20a9b57c..7434f51ca02cd 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestInheritedAnnotations diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestLabel.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestLabel.java index ca1b74e10f2e1..0f8f853107286 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestLabel.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestLabel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestLabel diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestMetadata.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestMetadata.java index 1287aa5e20d49..8939272b0f7b4 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestMetadata.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestMetadata diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestName.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestName.java index 411f5da67e140..269ddbecc20ee 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestName.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestName diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestPeriod.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestPeriod.java index 893b1ab4720d9..bf679b05bbf24 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestPeriod.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestLabel diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegistered.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegistered.java index 1c1177ac040cc..f9e89c2c12d05 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegistered.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegistered.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestRegistered diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java index 95bfbf527e1d8..2f2246ac3364d 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test Tests that commit doesn't throw exception when an event has not been registered. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestRelational.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestRelational.java index 7b2d6e896896e..d52364091752b 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestRelational.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestRelational.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestRelational diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java index 720da6da9ba00..cbb9cc54af664 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestSimpleMetadataEvent diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java index 2acd369b6cd8f..b7c3a67ae681c 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java @@ -47,7 +47,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.events * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestStackTrace.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackTrace.java index 8223d313a08c2..11e651d40cd04 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestStackTrace.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestStackTrace diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestThreshold.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestThreshold.java index 2ff1c3410a017..8cbb276c14598 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestThreshold.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestThreshold diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java index 9faae6ba564cd..7983828152538 100644 --- a/test/jdk/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.annotations.TestTypesIdentical diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java index 2af6870af5b53..b4a8e87735f74 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotation diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java index 34b84779d3e6c..0ce8767f8c1d7 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +63,7 @@ /** * @test * @summary Test for AnnotationElement.getAnnotationElements() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotationElements diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java index 895f9f4050fec..b86ef6dafaca3 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotations diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetCategory.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetCategory.java index ec92be1eb4e50..d4b70ff18b0bd 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetCategory.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetCategory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Test setName(). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetCategory diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java index be7264966c3e9..a5664af148407 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test getDefaultValues() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetDefaultValues diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDescription.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDescription.java index 19eb83fcf6ec0..91732ed9a9b02 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDescription.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test descriptive annotations for EventType - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetDescription diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetEventType.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetEventType.java index 4dbd2e7cc6f0c..9e7571577a9ef 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetEventType.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetEventType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test getEventType() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetEventType diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java index 28a39d649f7d9..aec07fdd136a8 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test getField() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetField diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetFields.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetFields.java index 237239b603532..1c8d98132f561 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetFields.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test getFields() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetFields diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetSettings.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetSettings.java index f47d451edfb9b..ab5cccf8bd8bc 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetSettings.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test getSettings() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetSettings diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java index d86a9d10452a5..07daab8fa4559 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test that verifies event metadata is removed when an event class is unloaded. * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java index 8ded0a5830d34..c88b21013484b 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test SettingDescriptor.getName() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestDefaultValue diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java index 70d58074fcb21..8c45e82c3cb42 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test SettingDescriptor.getAnnotation(); - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetAnnotation diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java index 74ffad14b727f..91a490e24c94c 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test SettingDescriptor.getAnnotationElements() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetAnnotationElement diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java index 2af0bb3af11b8..ba8e25dd44939 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test SettingDescriptor.getContentType() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetDescription diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java index 2e23b17962ad4..1b91361771425 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test SettingDescriptor.getDescription() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetDescription diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java index 961261bae196f..19b9f72c1d5c0 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test SettingDescriptor.getLabel() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetLabel diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java index 38b1fcb8085a2..f9ddc217bb73a 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test * @summary Test SettingDescriptor.getName() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetName diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java index b1d123855bf1d..16d35f8d5c73f 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test SettingDescriptor.getTypeId() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetTypeId diff --git a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java index 20d1ea957ecc3..98c7a3c0d0b5b 100644 --- a/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java +++ b/test/jdk/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test SettingDescriptor.getTypeName(); - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetTypeName diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java index 477beeab3b5d9..851ed0da7afaf 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test ValueDescriptor.getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestClasses diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java index 056f216d677f5..c8d33bc000430 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test ValueDescriptor.getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestConstructor diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java index bc2a227a8f5ee..eefbb876c8b18 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test ValueDescriptor.getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetAnnotations diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java index 0576615ba225a..a965e046643e3 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test * @summary Test ValueDescriptor.getAnnotations() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetFields diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java index 983d7e29d5ca2..d3a002ea0161d 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test ValueDescriptor.isArray(). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestIsArray diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java index cf506197a1836..c75737426a39c 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Test all basic types in ValueDescriptor. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestSimpleTypes diff --git a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java index 73acc71db68f9..cc5f8e8256447 100644 --- a/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java +++ b/test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test ValueDescriptor.getContentType() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestValueDescriptorContentType diff --git a/test/jdk/jdk/jfr/api/recorder/TestRecorderInitialized.java b/test/jdk/jdk/jfr/api/recorder/TestRecorderInitialized.java index c4f48b9ce7987..bc791e6cb3305 100644 --- a/test/jdk/jdk/jfr/api/recorder/TestRecorderInitialized.java +++ b/test/jdk/jdk/jfr/api/recorder/TestRecorderInitialized.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test TestRecorderListener - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/api/recorder/TestRecorderListener.java b/test/jdk/jdk/jfr/api/recorder/TestRecorderListener.java index c6a1e853771ac..87790b57392bc 100644 --- a/test/jdk/jdk/jfr/api/recorder/TestRecorderListener.java +++ b/test/jdk/jdk/jfr/api/recorder/TestRecorderListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test TestRecorderListener * - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @run main/othervm jdk.jfr.api.recorder.TestRecorderListener */ diff --git a/test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java b/test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java index 0053c71019551..74d1f632ac541 100644 --- a/test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java +++ b/test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java @@ -9,7 +9,7 @@ /** * @test TestRecorderListenerWithDump * - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @run main/othervm jdk.jfr.api.recorder.TestRecorderListenerWithDump */ diff --git a/test/jdk/jdk/jfr/api/recorder/TestStartStopRecording.java b/test/jdk/jdk/jfr/api/recorder/TestStartStopRecording.java index 4f78f6888e29c..1b923ab8ad282 100644 --- a/test/jdk/jdk/jfr/api/recorder/TestStartStopRecording.java +++ b/test/jdk/jdk/jfr/api/recorder/TestStartStopRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test TestStartStopRecording * - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recorder.TestStartStopRecording diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestFileExist.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestFileExist.java index 42f5e277cedf3..22df06e164aad 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestFileExist.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestFileExist.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Set destination to an existing file. File should be overwritten. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestFileExist diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java index d7fc0bdd0aac8..94289f9397803 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Set destination to a read-only file. Expects exception. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestFileReadOnly diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestInvalid.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestInvalid.java index 93e2709c222f8..e3c099707f4c2 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestInvalid.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Test setDestination to invalid paths - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestInvalid diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestLongPath.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestLongPath.java index 9ab67cfc02e86..045362bea1443 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestLongPath.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestLongPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Set destination to a long path - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestLongPath diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestMultiple.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestMultiple.java index bf7d3f3b0fbf5..4e3eef91c8563 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestMultiple.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test setDestination with concurrent recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr=trace jdk.jfr.api.recording.destination.TestDestMultiple diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestReadOnly.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestReadOnly.java index 8c4a132cb7102..b6b2ddd8ce305 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestReadOnly.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestReadOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary Test setDestination to read-only dir - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestReadOnly diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestState.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestState.java index 99ded47f5ea9e..233d898be10b2 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestState.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Call setDestination() when recording in different states - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestState diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java index 4930916a1d95b..1f264af21f80d 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Basic test for setDestination with disk=false - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestToDiskFalse diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java index 3684c6e65e8bb..b685c2c17bd2b 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Basic test for setDestination with disk=true - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestToDiskTrue diff --git a/test/jdk/jdk/jfr/api/recording/destination/TestDestWithDuration.java b/test/jdk/jdk/jfr/api/recording/destination/TestDestWithDuration.java index ba305a18c2a56..eb9226fa2d8eb 100644 --- a/test/jdk/jdk/jfr/api/recording/destination/TestDestWithDuration.java +++ b/test/jdk/jdk/jfr/api/recording/destination/TestDestWithDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Test that recording is auto closed after duration - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.destination.TestDestWithDuration diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDump.java b/test/jdk/jdk/jfr/api/recording/dump/TestDump.java index 36706ecde3a31..1818cacca2062 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDump.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test copyTo and parse file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDump diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpDevNull.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpDevNull.java index d74dd7fede294..b83f96868686a 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpDevNull.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpDevNull.java @@ -29,7 +29,7 @@ /** * @test * @summary Tests that it's possible to dump to /dev/null without a livelock - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & (os.family != "windows") * @library /test/lib * @run main/othervm -Xlog:jfr jdk.jfr.api.recording.dump.TestDumpDevNull diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpInvalid.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpInvalid.java index 7b69f552afe7d..41250336d8998 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpInvalid.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test copyTo and parse file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDumpInvalid diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpLongPath.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpLongPath.java index a1d2f714f4eee..d3b08cc8e048d 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpLongPath.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpLongPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test copyTo and parse file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDumpLongPath diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpMultiple.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpMultiple.java index 3eab84cb44af3..2b14700e179b1 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpMultiple.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test copyTo and parse file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDumpMultiple diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpReadOnly.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpReadOnly.java index 8ffbfa75952f8..9e05d8a2037ed 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpReadOnly.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpReadOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test copyTo and parse file - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDumpReadOnly diff --git a/test/jdk/jdk/jfr/api/recording/dump/TestDumpState.java b/test/jdk/jdk/jfr/api/recording/dump/TestDumpState.java index 7b464ff85b18b..b315117f726da 100644 --- a/test/jdk/jdk/jfr/api/recording/dump/TestDumpState.java +++ b/test/jdk/jdk/jfr/api/recording/dump/TestDumpState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test * @summary call copyTo() with recording in all states. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.dump.TestDumpState diff --git a/test/jdk/jdk/jfr/api/recording/event/TestChunkPeriod.java b/test/jdk/jdk/jfr/api/recording/event/TestChunkPeriod.java index 71ffa1f3a9f3b..9ce6af5861577 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestChunkPeriod.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestChunkPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test periodic setting that involves chunks. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestChunkPeriod diff --git a/test/jdk/jdk/jfr/api/recording/event/TestEnableClass.java b/test/jdk/jdk/jfr/api/recording/event/TestEnableClass.java index ea14efd1ce93f..cce06973d1c05 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestEnableClass.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestEnableClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test * @summary Simple enable Event class. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestEnableClass diff --git a/test/jdk/jdk/jfr/api/recording/event/TestEnableName.java b/test/jdk/jdk/jfr/api/recording/event/TestEnableName.java index c513fa64466ac..a1647918abb6e 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestEnableName.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestEnableName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Simple enable Event class. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestEnableName diff --git a/test/jdk/jdk/jfr/api/recording/event/TestEventTime.java b/test/jdk/jdk/jfr/api/recording/event/TestEventTime.java index 7ee9748520a79..54c735fff6963 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestEventTime.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestEventTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Test getStartTime() and getEndTime(). Verify startTime <= endTime - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestEventTime diff --git a/test/jdk/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java b/test/jdk/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java index 4bd96871b454e..0586389d86a15 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Load event class after recording started. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.lib.jfr.SimpleEvent diff --git a/test/jdk/jdk/jfr/api/recording/event/TestPeriod.java b/test/jdk/jdk/jfr/api/recording/event/TestPeriod.java index a3a76953fff08..e667fe010ef56 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestPeriod.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test periodic events. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestPeriod diff --git a/test/jdk/jdk/jfr/api/recording/event/TestReEnableClass.java b/test/jdk/jdk/jfr/api/recording/event/TestReEnableClass.java index 57d274abaa774..82631f5dcfefd 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestReEnableClass.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestReEnableClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Enable, disable, enable event during recording. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestReEnableClass diff --git a/test/jdk/jdk/jfr/api/recording/event/TestReEnableMultiple.java b/test/jdk/jdk/jfr/api/recording/event/TestReEnableMultiple.java index 4bbd0714c08f8..392450ee92ef0 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestReEnableMultiple.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestReEnableMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Enable, disable, enable event during recording. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestReEnableMultiple diff --git a/test/jdk/jdk/jfr/api/recording/event/TestReEnableName.java b/test/jdk/jdk/jfr/api/recording/event/TestReEnableName.java index 45f254956d6ab..3b6092f384cb0 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestReEnableName.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestReEnableName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Enable/disable event by name during recording. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestReEnableName diff --git a/test/jdk/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java b/test/jdk/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java index dd9d5089ae4d9..e0751c98aa9e1 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Enable, disable, enable event during recording. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestRecordingEnableDisable diff --git a/test/jdk/jdk/jfr/api/recording/event/TestShortPeriod.java b/test/jdk/jdk/jfr/api/recording/event/TestShortPeriod.java index e53fd90a75cac..a7c6d995bfb39 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestShortPeriod.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestShortPeriod.java @@ -33,7 +33,7 @@ /** * @test Tests that periodic events are not disabled when using a very short * period - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.recording.event.TestShortPeriod diff --git a/test/jdk/jdk/jfr/api/recording/event/TestThreshold.java b/test/jdk/jdk/jfr/api/recording/event/TestThreshold.java index a0b42f66b892b..fdde42cdf5ad2 100644 --- a/test/jdk/jdk/jfr/api/recording/event/TestThreshold.java +++ b/test/jdk/jdk/jfr/api/recording/event/TestThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test event threshold. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.event.TestThreshold diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestGetId.java b/test/jdk/jdk/jfr/api/recording/misc/TestGetId.java index de4d17a741c45..979a59c7ca011 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestGetId.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestGetId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Verify that each recording get unique a id - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestGetId diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestGetSize.java b/test/jdk/jdk/jfr/api/recording/misc/TestGetSize.java index dc2176f59019d..ba540e6ae40c2 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestGetSize.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestGetSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test recording file size with Recording.getSize() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestGetSize diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestGetSizeToMem.java b/test/jdk/jdk/jfr/api/recording/misc/TestGetSizeToMem.java index 2b7ad3d4e6b2d..4529c9059c55f 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestGetSizeToMem.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestGetSizeToMem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Test recording file size with Recording.getSize() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestGetSizeToMem diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java b/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java index 3b353d0968be8..3db2549019974 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary A simple test for Recording.getStream() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestGetStream diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingBase.java b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingBase.java index a17a7eb9959a0..4122a203db1f5 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingBase.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary Basic tests for Recording - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestRecordingBase diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java index 8d539ed68c4e1..1234655f31ac7 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary A simple test for Recording.copy() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.misc.TestRecordingCopy diff --git a/test/jdk/jdk/jfr/api/recording/options/TestDuration.java b/test/jdk/jdk/jfr/api/recording/options/TestDuration.java index 8f231ab77a038..d0bb1938f6b61 100644 --- a/test/jdk/jdk/jfr/api/recording/options/TestDuration.java +++ b/test/jdk/jdk/jfr/api/recording/options/TestDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test setDuration(). Verify recording is stopped automatically. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.options.TestDuration diff --git a/test/jdk/jdk/jfr/api/recording/options/TestName.java b/test/jdk/jdk/jfr/api/recording/options/TestName.java index c0042b4458ab1..a1b1747c70029 100644 --- a/test/jdk/jdk/jfr/api/recording/options/TestName.java +++ b/test/jdk/jdk/jfr/api/recording/options/TestName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test setName(). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.options.TestName diff --git a/test/jdk/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java b/test/jdk/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java index 9365c7cf13ee7..ceea62bed2a71 100644 --- a/test/jdk/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java +++ b/test/jdk/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Verifies Configuration.getContents() for every configuration - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.settings.TestConfigurationGetContents diff --git a/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java b/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java index b64d0055dcb24..bd46c75c18be8 100644 --- a/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java +++ b/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test setName(). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.settings.TestCreateConfigFromPath diff --git a/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromReader.java b/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromReader.java index e96fab76899fc..219a100385291 100644 --- a/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromReader.java +++ b/test/jdk/jdk/jfr/api/recording/settings/TestCreateConfigFromReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test setName(). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.settings.TestCreateConfigFromReader diff --git a/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java b/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java index 465a07ab021bd..73b9557591a29 100644 --- a/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java +++ b/test/jdk/jdk/jfr/api/recording/settings/TestGetConfigurations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ * @test * @summary Verifies that there is the default config and that it has * the expected parameters - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.settings.TestGetConfigurations diff --git a/test/jdk/jdk/jfr/api/recording/settings/TestSettingsAvailability.java b/test/jdk/jdk/jfr/api/recording/settings/TestSettingsAvailability.java index e5d90e4b80bca..dc22644b4d034 100644 --- a/test/jdk/jdk/jfr/api/recording/settings/TestSettingsAvailability.java +++ b/test/jdk/jdk/jfr/api/recording/settings/TestSettingsAvailability.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Verifies that event types has the correct type of settings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.settings.TestSettingsAvailability diff --git a/test/jdk/jdk/jfr/api/recording/state/TestOptionState.java b/test/jdk/jdk/jfr/api/recording/state/TestOptionState.java index 4e9dd4f2f7217..4b43f0fd5cbc2 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestOptionState.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestOptionState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test options in different states * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/recording/state/TestState.java b/test/jdk/jdk/jfr/api/recording/state/TestState.java index 5c548977ad79e..724b885d280d8 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestState.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test Recording state - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestState diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java b/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java index 5e8ef60b36720..ac54d69e4abe8 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test Recording state - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestStateDuration diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java b/test/jdk/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java index 216ac64c79c34..295f5b3c0c91b 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test Recording state with concurrent recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestStateIdenticalListeners diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateInvalid.java b/test/jdk/jdk/jfr/api/recording/state/TestStateInvalid.java index ba190c68d8538..5108fb0329104 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateInvalid.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test start/stop/close recording from different recording states. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestStateInvalid diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateMultiple.java b/test/jdk/jdk/jfr/api/recording/state/TestStateMultiple.java index 21ccd7360742c..9745cab7351ec 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateMultiple.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Test Recording state with concurrent recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestStateMultiple diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java b/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java index 3708ded56f167..ba95407dad223 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Test Recording state - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.api.recording.state.TestStateScheduleStart diff --git a/test/jdk/jdk/jfr/api/recording/time/TestTime.java b/test/jdk/jdk/jfr/api/recording/time/TestTime.java index 66e729f7568fa..3ece99b9e466d 100644 --- a/test/jdk/jdk/jfr/api/recording/time/TestTime.java +++ b/test/jdk/jdk/jfr/api/recording/time/TestTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test Recording.get*Time() * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/recording/time/TestTimeDuration.java b/test/jdk/jdk/jfr/api/recording/time/TestTimeDuration.java index 7f71c0c900471..12b5368db8842 100644 --- a/test/jdk/jdk/jfr/api/recording/time/TestTimeDuration.java +++ b/test/jdk/jdk/jfr/api/recording/time/TestTimeDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test Recording.setDuration() and Recording.get*Time() * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/recording/time/TestTimeMultiple.java b/test/jdk/jdk/jfr/api/recording/time/TestTimeMultiple.java index 057d9150b6a74..aab608267b571 100644 --- a/test/jdk/jdk/jfr/api/recording/time/TestTimeMultiple.java +++ b/test/jdk/jdk/jfr/api/recording/time/TestTimeMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test recording times with concurrent recordings * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/recording/time/TestTimeScheduleStart.java b/test/jdk/jdk/jfr/api/recording/time/TestTimeScheduleStart.java index 3698a683c50be..83d8399e41eda 100644 --- a/test/jdk/jdk/jfr/api/recording/time/TestTimeScheduleStart.java +++ b/test/jdk/jdk/jfr/api/recording/time/TestTimeScheduleStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test Recording.scheduleStart() and Recording.get*Time() * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java b/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java index 67619fb10b4e9..ed20c44c688b8 100644 --- a/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java +++ b/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary The test uses SettingControl - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.settings.TestFilterEvents diff --git a/test/jdk/jdk/jfr/api/settings/TestSettingControl.java b/test/jdk/jdk/jfr/api/settings/TestSettingControl.java index 5543953482d63..ef38626eedb75 100644 --- a/test/jdk/jdk/jfr/api/settings/TestSettingControl.java +++ b/test/jdk/jdk/jfr/api/settings/TestSettingControl.java @@ -44,7 +44,7 @@ /** * @test * @summary Tests that methods on all SettingControls have expected behavior. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.api.settings.TestSettingControl diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java index 1fe3425372280..9112cfbc247e5 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test that event is triggered when an object is allocated in a new TLAB. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java index d2f2a3a1bc4da..a7695b7684947 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Test that when an object is allocated outside a TLAB an event will be triggered. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java index 2f7d3cc150303..6f22476bcbf37 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java @@ -33,7 +33,7 @@ /** * @test * @summary Tests ObjectAllocationSampleEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -XX:+UseTLAB -XX:TLABSize=2k -XX:-ResizeTLAB jdk.jfr.event.allocation.TestObjectAllocationSampleEvent diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java index a38aae51c01ae..47f5b31f8816d 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary Test that when an object is allocated outside a TLAB an event will be triggered. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java b/test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java index cfc2115d68b6a..defc9cba1be0b 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test TestCodeCacheConfig - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/compiler/TestCodeCacheStats.java b/test/jdk/jdk/jfr/event/compiler/TestCodeCacheStats.java index 2930b79883e01..2256e6a21fa8b 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCodeCacheStats.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCodeCacheStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.compiler.TestCodeCacheStats diff --git a/test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java b/test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java index 62fb137b1cf03..dd227489a0c6e 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ */ /** * @test TestCodeSweeper - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java index e13bcaa80b5cc..d39e006f5caa6 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.compMode == "Xmixed" * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerConfig.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerConfig.java index 0e4834ccfa118..cc5455f98d9de 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerConfig.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.compiler.TestCompilerConfig diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java index 2d0ce579dd810..9694c054f6a0c 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ /* * @test CompilerInliningTest * @bug 8073607 - * @key jfr + * @requires vm.flagless * @summary Verifies that corresponding JFR events are emitted in case of inlining. * @requires vm.hasJFR * @requires vm.compMode == "Xmixed" diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java index 02e235a23cadd..33884d448bff3 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.compMode!="Xint" & vm.flavor == "server" & (vm.opt.TieredStopAtLevel == 4 | vm.opt.TieredStopAtLevel == null) * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerQueueUtilization.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerQueueUtilization.java index 081cb5296d596..d4e4e12eaa3c7 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerQueueUtilization.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerQueueUtilization.java @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.compMode!="Xint" * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerStats.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerStats.java index 389a7da25b4c5..053aedf94c8bf 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerStats.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.compiler.TestCompilerStats diff --git a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java index bd6d57b31762d..eb19965a64413 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java +++ b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public static void dummyMethod(boolean b) { /** * @test - * @key jfr + * @requires vm.flagless * @summary sanity test for Deoptimization event, depends on Compilation event * @requires vm.hasJFR * @requires vm.compMode == "Xmixed" diff --git a/test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java b/test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java index 20577d8257dee..14b0489505811 100644 --- a/test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java +++ b/test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules java.management diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java index 86da3907e9d87..568104a7b50a2 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk /test/hotspot/jtreg diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java index e0ea218a07f0b..3cd8f6612bf44 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "G1" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java index 308a544adeb17..40c5129eb2303 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "G1" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java index 16217c0cbe1b7..785d761f4eeb9 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Parallel" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java index 344c61043a2e1..f8f95070c1ca9 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Serial" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java index 2282783ae1498..fcd33cbb1b50d 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires (vm.gc == "G1" | vm.gc == null) diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java index 5c3da24fa1b9b..a698497cf956d 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires (vm.gc == "G1" | vm.gc == null) diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java index 9f95ca364f84f..c06b046f47325 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Parallel" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java index 6499f18c16425..6fc675a93e78e 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Serial" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java index e228f7fd067ed..ff23291fa41fd 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:gc*=debug -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.collection.TestGCGarbageCollectionEvent diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCWithFasttime.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCWithFasttime.java index edce5e76190c5..d6b271e4669c8 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCWithFasttime.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCWithFasttime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java index 5305cfd8d67b9..e2dd258818ba7 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestGarbageCollectionEventWithZMajor */ diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java index 65c177d3a6812..8e0d48682fccd 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,9 +39,9 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java b/test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java index c5614ad1cbe0c..c22670e4528fe 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.collection.TestSystemGC true diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java index 95c1a9c40ee9f..c6798c770a65e 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java index 931721011aa4a..5f026fc50e8e2 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java index b731f1936bb92..f9adb6a45a6f5 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java b/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java index 38e5ca49e608b..77abb19922bfe 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZOldGarbageCollectionEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java b/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java index 40c0a2adec32c..10c1407b96aaa 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZYoungGarbageCollectionEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java index e459b0f2e7bae..7b7cc8a43766a 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "Parallel" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java index c3a2803033810..6e411cf910553 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.configuration.TestGCConfigurationEventWithDefaultPauseTarget diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java index 0a61a288cc218..9ef90afb06336 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /* * @test TestGCHeapConfigurationEventWith32BitOops - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @requires os.family == "linux" | os.family == "windows" diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java index a6fdcbde6b18e..5346c7a71038c 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /* * @test TestGCHeapConfigurationEventWith32BitOops - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @requires os.family == "linux" | os.family == "windows" diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java index d63ca856bc34a..62d858eef984f 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /* * @test TestGCHeapConfigurationEventWithZeroBasedOops - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @requires os.family == "linux" | os.family == "windows" diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java index fde69412a7af6..2a282660b03f4 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java index b69e4fb8490c7..cabf6ac1fab8c 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java index d347378b6063d..b58bb2ae7bf20 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run driver jdk.jfr.event.gc.configuration.TestGCYoungGenerationConfigurationEventWithMinAndMaxSize diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java index 0c78f1e9541fb..c360ae3fa86d8 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:NewRatio=4 jdk.jfr.event.gc.configuration.TestGCYoungGenerationConfigurationEventWithNewRatio diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java index 584900620d4ec..41cfbf97b95e0 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @bug 8263461 * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java index 420f083758db0..0ec33a9d5eecd 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1AIHOPEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1AIHOPEvent.java index deed6b6462646..6570bbdd6afa4 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1AIHOPEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1AIHOPEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1ConcurrentModeFailureEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1ConcurrentModeFailureEvent.java index dade7aea8b68e..d178a429560a1 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1ConcurrentModeFailureEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1ConcurrentModeFailureEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "G1" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java index e32cfda41a9b4..56798b09db30d 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java index b716295b507d7..399d82aa0f0c3 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8149650 * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:G1HeapRegionSize=1m -XX:+UseG1GC jdk.jfr.event.gc.detailed.TestG1HeapRegionTypeChangeEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1IHOPEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1IHOPEvent.java index 4a5bce6a69f49..20ec6fa76f479 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1IHOPEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1IHOPEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1InvalidHeapRegionTypeChangeEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1InvalidHeapRegionTypeChangeEvent.java index 023020f2a296b..7939a769ccb8c 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1InvalidHeapRegionTypeChangeEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1InvalidHeapRegionTypeChangeEvent.java @@ -39,7 +39,7 @@ * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @requires vm.debug - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @summary Make sure that there are no Old->Old and Free->Free events sent. * @run main/othervm -XX:+G1GCAllocationFailureALot -XX:NewSize=2m -XX:MaxNewSize=2m -XX:MaxTenuringThreshold=1 diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java index 967a3bc03d5b5..49b4a72147230 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCCPUTimeEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCCPUTimeEvent.java index 9e7d7ca54137e..cd9f0046cbbef 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCCPUTimeEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCCPUTimeEvent.java @@ -32,7 +32,7 @@ /** * @test id=Serial - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.Serial * @library /test/lib /test/jdk @@ -43,7 +43,7 @@ /** * @test id=Parallel - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.Parallel * @library /test/lib /test/jdk @@ -54,7 +54,7 @@ /** * @test id=G1 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.G1 * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryPoolUsageEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryPoolUsageEvent.java index 6d5308408d622..1286c53d938ad 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryPoolUsageEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryPoolUsageEvent.java @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:-ExplicitGCInvokesConcurrent jdk.jfr.event.gc.detailed.TestGCHeapMemoryPoolUsageEvent diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryUsageEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryUsageEvent.java index 7f1d96a3993b0..d54ca7a723d04 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryUsageEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCHeapMemoryUsageEvent.java @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:-ExplicitGCInvokesConcurrent jdk.jfr.event.gc.detailed.TestGCHeapMemoryUsageEvent diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java index 596af47de39bc..1ad0fbd86b8d6 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java @@ -24,7 +24,7 @@ /** * @test TestGCLockerEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.Serial | vm.gc.Parallel * @requires vm.gc != null diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java index 66e3e026536af..fde4cd9c2d605 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test id=Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @requires vm.hasJFR & vm.gc.Z * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestGCPhaseConcurrent Z @@ -40,7 +40,7 @@ /** * @test TestGCPhaseConcurrent - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @requires vm.hasJFR & vm.gc.Shenandoah * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx32M jdk.jfr.event.gc.detailed.TestGCPhaseConcurrent Shenandoah diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java index ac646e7c14a05..3e76369940232 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 8212766 - * @key jfr + * @requires vm.flagless * @summary Test that events are created when an object is aged or promoted during a GC and the copying of the object requires a new PLAB or direct heap allocation * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java index 30b18a9df4a2a..13de75ff583d0 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test that events are created when an object is aged or promoted during a GC and the copying of the object requires a new PLAB or direct heap allocation * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java index 53382ea8ba269..b239f6f78ba77 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Serial" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java index 98abeabdacb4b..4880640b77265 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "Parallel" | vm.gc == null diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java index 33310ab721a5a..4f2334284cc9d 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java @@ -39,7 +39,7 @@ * @test * @bug 8221507 * @requires vm.hasJFR & vm.gc.Shenandoah - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx64m -XX:+UnlockExperimentalVMOptions -XX:ShenandoahRegionSize=1m -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational jdk.jfr.event.gc.detailed.TestShenandoahEvacuationInformationEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionInformationEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionInformationEvent.java index 2f220571b7d2d..88538928145e4 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionInformationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionInformationEvent.java @@ -38,7 +38,7 @@ * @test * @bug 8221507 * @requires vm.hasJFR & vm.gc.Shenandoah - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx32m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGarbageThreshold=1 jdk.jfr.event.gc.detailed.TestShenandoahHeapRegionInformationEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionStateChangeEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionStateChangeEvent.java index 3162497f52c64..dfd0c0f86bcb6 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionStateChangeEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestShenandoahHeapRegionStateChangeEvent.java @@ -38,7 +38,7 @@ * @test * @bug 8221507 * @requires vm.hasJFR & vm.gc.Shenandoah - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -Xmx32m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGarbageThreshold=1 jdk.jfr.event.gc.detailed.TestShenandoahHeapRegionStateChangeEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java index 9002373caef9e..843219d61d2b7 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * @bug 8009538 * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:+UseG1GC -XX:+NeverTenure jdk.jfr.event.gc.detailed.TestTenuringDistributionEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java index b17c678ec5533..b2f20450d0d86 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xmx32M -Xlog:gc*:gc.log::filecount=0 jdk.jfr.event.gc.detailed.TestZAllocationStallEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java index c17e19193db63..83caddbbaafbc 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZPageAllocationEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java index baae61d5cd81f..e64d6f83ab822 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java index 0e93aed8b8eb8..29e1de24224c3 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java index 1aa2ba6af0b6d..f77ada9bf1bf4 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test id=Z * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xms32M -Xmx128M -Xlog:gc,gc+heap -XX:+ZUncommit -XX:ZUncommitDelay=1 jdk.jfr.event.gc.detailed.TestZUncommitEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java index fabbdce9c94ea..93ed6253de28b 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test id=Z * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZUnmapEvent */ diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java index 2606757721f8a..33578d854b6c0 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java index b46d52e46f18d..f70d7a85f168f 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk @@ -36,7 +36,7 @@ /** * @test * @bug 8264008 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.bits == 64 * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java index fc30a8dec7345..edecfaf14065e 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java index 475c0ff84fe7e..306b23f88b786 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java index 3fe9e0f360d90..eb69289aa5e2d 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != false diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java index 54b8ebc33e4bc..6e91cf4c64452 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java index 8d88c8d6d8e66..2a17e540be86f 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java index 6401a0002e2c5..888eb08902720 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java index 2f7c7513b258e..a9034ba0eaad2 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java index 5e3ce6928c9a1..bc26ad792d0a7 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java index 7a635d4812e12..33547a1ca6766 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != false diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java index b06d68c5cc313..2bf13facffcbf 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java index 16e87232a51a2..139e95980a50d 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java index a2810a8c8b225..5faae179fe0f2 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java index 21ae0a319a8ea..ce9dd0b936cdd 100644 --- a/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java +++ b/test/jdk/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java index 4f83b37765d89..8741d433570ed 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Serial" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java index 0cc00bb1e4b76..a61a87fd53958 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "G1" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java index e74528c20e181..1346c36c04f36 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "G1" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java index 0454d8fe77f00..8c951919feb2f 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "G1" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java index 07a1c63fda1f4..8b3261e3a00ae 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Serial" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java index 5a0cc9288b604..06c0d23788b42 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ package jdk.jfr.event.gc.stacktrace; /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "G1" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java index 8e71c8d55a83c..13bfc7c9ea6bb 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Parallel" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java index 4d9a53e9afd32..36bf59741ee26 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Serial" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java index 733b493548121..93e6b5b17e791 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Parallel" diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java index 341a3e53aa8c6..7771965dc97b9 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @requires vm.gc == "null" | vm.gc == "Parallel" diff --git a/test/jdk/jdk/jfr/event/io/TestAsynchronousFileChannelEvents.java b/test/jdk/jdk/jfr/event/io/TestAsynchronousFileChannelEvents.java index f1ddba369eb41..e0752c6d319dd 100644 --- a/test/jdk/jdk/jfr/event/io/TestAsynchronousFileChannelEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestAsynchronousFileChannelEvents.java @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestAsynchronousFileChannelEvents diff --git a/test/jdk/jdk/jfr/event/io/TestDeserializationEvent.java b/test/jdk/jdk/jfr/event/io/TestDeserializationEvent.java index 28b26165e2f70..04e5126ca0055 100644 --- a/test/jdk/jdk/jfr/event/io/TestDeserializationEvent.java +++ b/test/jdk/jdk/jfr/event/io/TestDeserializationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @bug 8261160 * @summary Add a deserialization JFR event - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run testng/othervm jdk.jfr.event.io.TestDeserializationEvent diff --git a/test/jdk/jdk/jfr/event/io/TestDisabledEvents.java b/test/jdk/jdk/jfr/event/io/TestDisabledEvents.java index 0b523b80523b8..5a6835c4ce2fb 100644 --- a/test/jdk/jdk/jfr/event/io/TestDisabledEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestDisabledEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary Test with FlightRecorder enabled but with the events disabled. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestDisabledEvents diff --git a/test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java b/test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java index 11ae0a12e4fb5..490e16d3e52b4 100644 --- a/test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestFileChannelEvents diff --git a/test/jdk/jdk/jfr/event/io/TestFileReadOnly.java b/test/jdk/jdk/jfr/event/io/TestFileReadOnly.java index 6986c43e3fe1b..f28c20d888173 100644 --- a/test/jdk/jdk/jfr/event/io/TestFileReadOnly.java +++ b/test/jdk/jdk/jfr/event/io/TestFileReadOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestFileReadOnly diff --git a/test/jdk/jdk/jfr/event/io/TestFileStreamEvents.java b/test/jdk/jdk/jfr/event/io/TestFileStreamEvents.java index d557a8dfd7de2..a710335e63d95 100644 --- a/test/jdk/jdk/jfr/event/io/TestFileStreamEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestFileStreamEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test TestFileStreamEvents - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestFileStreamEvents diff --git a/test/jdk/jdk/jfr/event/io/TestInstrumentation.java b/test/jdk/jdk/jfr/event/io/TestInstrumentation.java index beef8437a3442..37a196237e810 100644 --- a/test/jdk/jdk/jfr/event/io/TestInstrumentation.java +++ b/test/jdk/jdk/jfr/event/io/TestInstrumentation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ /* * @test * @summary Test that will instrument the same classes that JFR will also instrument. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/io/TestRandomAccessFileEvents.java b/test/jdk/jdk/jfr/event/io/TestRandomAccessFileEvents.java index 47fbc62d08d20..4da995533f8b3 100644 --- a/test/jdk/jdk/jfr/event/io/TestRandomAccessFileEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestRandomAccessFileEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestRandomAccessFileEvents diff --git a/test/jdk/jdk/jfr/event/io/TestRandomAccessFileThread.java b/test/jdk/jdk/jfr/event/io/TestRandomAccessFileThread.java index a815a1231ce41..54b989cbf3c8b 100644 --- a/test/jdk/jdk/jfr/event/io/TestRandomAccessFileThread.java +++ b/test/jdk/jdk/jfr/event/io/TestRandomAccessFileThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary Verify the event time stamp and thread name - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.io.TestRandomAccessFileThread diff --git a/test/jdk/jdk/jfr/event/io/TestSerializationMisdeclarationEvent.java b/test/jdk/jdk/jfr/event/io/TestSerializationMisdeclarationEvent.java index 7c7b8366a0468..b746d50689e2e 100644 --- a/test/jdk/jdk/jfr/event/io/TestSerializationMisdeclarationEvent.java +++ b/test/jdk/jdk/jfr/event/io/TestSerializationMisdeclarationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ * @bug 8275338 8324220 * @summary Check generation of JFR events for misdeclared fields and methods * relevant to serialization - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run junit/othervm jdk.jfr.event.io.TestSerializationMisdeclarationEvent diff --git a/test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java b/test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java index 9ac57b839fb2c..77a083ad8fe9d 100644 --- a/test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java @@ -48,7 +48,7 @@ * @test * @bug 8310978 * @summary test socket read/write events on socket adaptors - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestSocketAdapterEvents diff --git a/test/jdk/jdk/jfr/event/io/TestSocketChannelEvents.java b/test/jdk/jdk/jfr/event/io/TestSocketChannelEvents.java index fc045e55caa6e..1a40edde0fd94 100644 --- a/test/jdk/jdk/jfr/event/io/TestSocketChannelEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestSocketChannelEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary test socket read/write events on SocketChannel - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestSocketChannelEvents diff --git a/test/jdk/jdk/jfr/event/io/TestSocketEvents.java b/test/jdk/jdk/jfr/event/io/TestSocketEvents.java index d73c5010cf7d0..144b9592b2206 100644 --- a/test/jdk/jdk/jfr/event/io/TestSocketEvents.java +++ b/test/jdk/jdk/jfr/event/io/TestSocketEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ /** * @test * @summary test socket read/write events on Socket - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.event.io.TestSocketEvents diff --git a/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java b/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java index 3b8b0d975eb6f..3a14937e21d37 100644 --- a/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java +++ b/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/metadata/TestEventMetadata.java b/test/jdk/jdk/jfr/event/metadata/TestEventMetadata.java index afdb84952f429..e3255909fccb7 100644 --- a/test/jdk/jdk/jfr/event/metadata/TestEventMetadata.java +++ b/test/jdk/jdk/jfr/event/metadata/TestEventMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.metadata.TestEventMetadata diff --git a/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java b/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java index 981579ba341e6..5b8aacfb1d228 100644 --- a/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java +++ b/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test Check for JFR events not covered by tests - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main jdk.jfr.event.metadata.TestLookForUntestedEvents diff --git a/test/jdk/jdk/jfr/event/oldobject/TestAllocationTime.java b/test/jdk/jdk/jfr/event/oldobject/TestAllocationTime.java index ce3e3057699a3..0ce109368a56f 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestAllocationTime.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestAllocationTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestArrayInformation.java b/test/jdk/jdk/jfr/event/oldobject/TestArrayInformation.java index 028024fdd284f..393a734aa26a1 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestArrayInformation.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestArrayInformation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestCircularReference.java b/test/jdk/jdk/jfr/event/oldobject/TestCircularReference.java index b3dbfef090c45..a601cefad40d5 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestCircularReference.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestCircularReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java index 6f7337d37777d..b9aab92b9242e 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.flagless * @comment Marked as flagless until JDK-8322597 is fixed diff --git a/test/jdk/jdk/jfr/event/oldobject/TestFieldInformation.java b/test/jdk/jdk/jfr/event/oldobject/TestFieldInformation.java index fb0f5eebd7fb7..0d3e1dcc2e564 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestFieldInformation.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestFieldInformation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestG1.java b/test/jdk/jdk/jfr/event/oldobject/TestG1.java index 79df63953c557..4c3d65a3ecea4 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestG1.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestG1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.G1 * @summary Test leak profiler with G1 GC diff --git a/test/jdk/jdk/jfr/event/oldobject/TestHeapDeep.java b/test/jdk/jdk/jfr/event/oldobject/TestHeapDeep.java index b7cbb233f311e..7461a9f1503c2 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestHeapDeep.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestHeapDeep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestHeapShallow.java b/test/jdk/jdk/jfr/event/oldobject/TestHeapShallow.java index 8d8b7f3c97aa3..bca93871cd901 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestHeapShallow.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestHeapShallow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestLargeRootSet.java b/test/jdk/jdk/jfr/event/oldobject/TestLargeRootSet.java index 4fe432e649327..c2a4cc5264ce5 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestLargeRootSet.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestLargeRootSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java b/test/jdk/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java index d51c52ab7e36c..36fdef6c86b93 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java index 92610283525a6..fd895fae91b92 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestMetadataRetention.java b/test/jdk/jdk/jfr/event/oldobject/TestMetadataRetention.java index b84160a0ac5a4..1747939390b2e 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestMetadataRetention.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestMetadataRetention.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ * @test * @summary The test verifies that an old object sample maintains references to "stale" metadata * @requires vm.hasJFR - * @key jfr + * @requires vm.flagless * @modules jdk.jfr/jdk.jfr.internal.test * @library /test/lib /test/jdk * @build jdk.jfr.event.oldobject.TestMetadataObject @@ -86,7 +86,7 @@ public static void main(String[] args) throws Throwable { // System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent // is NOT set. If this flag is set G1 will never unload classes on System.gc(). - // As far as the "jfr" key guarantees no VM flags are set from the + // As far as the vm.flagless guarantees no VM flags are set from the // outside it should be enough with System.gc(). System.gc(); diff --git a/test/jdk/jdk/jfr/event/oldobject/TestObjectAge.java b/test/jdk/jdk/jfr/event/oldobject/TestObjectAge.java index cd3ff53576250..6346326d620f0 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestObjectAge.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestObjectAge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestObjectDescription.java b/test/jdk/jdk/jfr/event/oldobject/TestObjectDescription.java index 447d2bb9cecf4..60f85e6ba7293 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestObjectDescription.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestObjectDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc != "Shenandoah" * @requires vm.flagless diff --git a/test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java b/test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java index 7b8a1003edd34..c10da3b498c3f 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java @@ -38,7 +38,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestParallel.java b/test/jdk/jdk/jfr/event/oldobject/TestParallel.java index 547619c128356..e41b86e51d635 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestParallel.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestParallel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.Parallel * @summary Test leak profiler with Parallel GC diff --git a/test/jdk/jdk/jfr/event/oldobject/TestReferenceChainLimit.java b/test/jdk/jdk/jfr/event/oldobject/TestReferenceChainLimit.java index 640819e9bc69a..be8cb03fb39c5 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestReferenceChainLimit.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestReferenceChainLimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestSanityDefault.java b/test/jdk/jdk/jfr/event/oldobject/TestSanityDefault.java index 30186db8def5b..b03f5e94f7bb2 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestSanityDefault.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestSanityDefault.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.flagless * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/oldobject/TestSerial.java b/test/jdk/jdk/jfr/event/oldobject/TestSerial.java index 8ed4d51c19d8c..4e6ee3c39d33e 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestSerial.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.gc.Serial * @summary Test leak profiler with Serial GC diff --git a/test/jdk/jdk/jfr/event/oldobject/TestShenandoah.java b/test/jdk/jdk/jfr/event/oldobject/TestShenandoah.java index 6d3483910301b..14b3dec5eb374 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestShenandoah.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestShenandoah.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.gc.Shenandoah * @summary Test leak profiler with Shenandoah * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java index c82636e9146e9..3ccc6952cdc12 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/oldobject/TestZ.java b/test/jdk/jdk/jfr/event/oldobject/TestZ.java index 8aff89ce7de64..9ae406c93697c 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestZ.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestZ.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @requires vm.hasJFR & vm.gc.Z - * @key jfr + * @requires vm.flagless * @summary Test leak profiler with ZGC * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/event/os/TestCPUInformation.java b/test/jdk/jdk/jfr/event/os/TestCPUInformation.java index c5166580010df..5a9e631141c1a 100644 --- a/test/jdk/jdk/jfr/event/os/TestCPUInformation.java +++ b/test/jdk/jdk/jfr/event/os/TestCPUInformation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestCPUInformation diff --git a/test/jdk/jdk/jfr/event/os/TestCPULoad.java b/test/jdk/jdk/jfr/event/os/TestCPULoad.java index 1edb163969955..09ceb0a79b786 100644 --- a/test/jdk/jdk/jfr/event/os/TestCPULoad.java +++ b/test/jdk/jdk/jfr/event/os/TestCPULoad.java @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestCPULoad diff --git a/test/jdk/jdk/jfr/event/os/TestCPUTimeStampCounter.java b/test/jdk/jdk/jfr/event/os/TestCPUTimeStampCounter.java index fd37ef195a54f..464de5557bedb 100644 --- a/test/jdk/jdk/jfr/event/os/TestCPUTimeStampCounter.java +++ b/test/jdk/jdk/jfr/event/os/TestCPUTimeStampCounter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestCPUTimeStampCounter diff --git a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java index d8fd9a6e67344..e869a3da3c7db 100644 --- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java +++ b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main jdk.jfr.event.os.TestInitialEnvironmentVariable diff --git a/test/jdk/jdk/jfr/event/os/TestOSInfo.java b/test/jdk/jdk/jfr/event/os/TestOSInfo.java index ce7565e3f5182..5dfce35683bef 100644 --- a/test/jdk/jdk/jfr/event/os/TestOSInfo.java +++ b/test/jdk/jdk/jfr/event/os/TestOSInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestOSInfo diff --git a/test/jdk/jdk/jfr/event/os/TestPhysicalMemoryEvent.java b/test/jdk/jdk/jfr/event/os/TestPhysicalMemoryEvent.java index 13e0522727842..79810a58b3a81 100644 --- a/test/jdk/jdk/jfr/event/os/TestPhysicalMemoryEvent.java +++ b/test/jdk/jdk/jfr/event/os/TestPhysicalMemoryEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestPhysicalMemoryEvent diff --git a/test/jdk/jdk/jfr/event/os/TestProcessStart.java b/test/jdk/jdk/jfr/event/os/TestProcessStart.java index bcf216857bb9b..2d1d80f59418d 100644 --- a/test/jdk/jdk/jfr/event/os/TestProcessStart.java +++ b/test/jdk/jdk/jfr/event/os/TestProcessStart.java @@ -36,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestProcessStart diff --git a/test/jdk/jdk/jfr/event/os/TestSwapSpaceEvent.java b/test/jdk/jdk/jfr/event/os/TestSwapSpaceEvent.java index 5ea2ed139eafa..cf92db85ace79 100644 --- a/test/jdk/jdk/jfr/event/os/TestSwapSpaceEvent.java +++ b/test/jdk/jdk/jfr/event/os/TestSwapSpaceEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (os.family != "linux") * @library /test/lib @@ -41,7 +41,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (os.family == "linux") * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/os/TestSystemProcess.java b/test/jdk/jdk/jfr/event/os/TestSystemProcess.java index 0af7a7ff37949..a76060bac9d8d 100644 --- a/test/jdk/jdk/jfr/event/os/TestSystemProcess.java +++ b/test/jdk/jdk/jfr/event/os/TestSystemProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestSystemProcess diff --git a/test/jdk/jdk/jfr/event/os/TestThreadContextSwitches.java b/test/jdk/jdk/jfr/event/os/TestThreadContextSwitches.java index 00b846b87e2bb..7b3dfc79ce956 100644 --- a/test/jdk/jdk/jfr/event/os/TestThreadContextSwitches.java +++ b/test/jdk/jdk/jfr/event/os/TestThreadContextSwitches.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestThreadContextSwitches diff --git a/test/jdk/jdk/jfr/event/os/TestVirtualizationInfo.java b/test/jdk/jdk/jfr/event/os/TestVirtualizationInfo.java index 0c3c86d5829ec..2c30e102c73f8 100644 --- a/test/jdk/jdk/jfr/event/os/TestVirtualizationInfo.java +++ b/test/jdk/jdk/jfr/event/os/TestVirtualizationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.os.TestVirtualizationInfo diff --git a/test/jdk/jdk/jfr/event/profiling/TestFullStackTrace.java b/test/jdk/jdk/jfr/event/profiling/TestFullStackTrace.java index b7abbc0a587f1..424b519c1e042 100644 --- a/test/jdk/jdk/jfr/event/profiling/TestFullStackTrace.java +++ b/test/jdk/jdk/jfr/event/profiling/TestFullStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.profiling.TestFullStackTrace diff --git a/test/jdk/jdk/jfr/event/profiling/TestNative.java b/test/jdk/jdk/jfr/event/profiling/TestNative.java index 21949bcc31306..e7e076051f45f 100644 --- a/test/jdk/jdk/jfr/event/profiling/TestNative.java +++ b/test/jdk/jdk/jfr/event/profiling/TestNative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /* * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/event/profiling/TestSamplingLongPeriod.java b/test/jdk/jdk/jfr/event/profiling/TestSamplingLongPeriod.java index c2cd4cb7bd16a..2402a948ef988 100644 --- a/test/jdk/jdk/jfr/event/profiling/TestSamplingLongPeriod.java +++ b/test/jdk/jdk/jfr/event/profiling/TestSamplingLongPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /* * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/event/runtime/TestActiveRecordingEvent.java b/test/jdk/jdk/jfr/event/runtime/TestActiveRecordingEvent.java index e786e8c933d0d..778acf48306e0 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestActiveRecordingEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestActiveRecordingEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary Tests that the recording properties are properly reflected in the ActiveRecording event - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestActiveRecordingEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java b/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java index 2b55a012d44d8..92298eaece0ff 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ /** * @test * @summary Tests that active setting are available in the ActiveSettingevent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestActiveSettingEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java b/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java index 240868d567077..ca7b6dfc0f112 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests Agent Loaded event by starting native and Java agents * @requires vm.hasJFR & vm.jvmti * diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassDefineEvent.java b/test/jdk/jdk/jfr/event/runtime/TestClassDefineEvent.java index 3681e73b52707..b0522741a1e49 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassDefineEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassDefineEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassLoadEvent.java b/test/jdk/jdk/jfr/event/runtime/TestClassLoadEvent.java index ec72253bc0662..102ff92db719a 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassLoadEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassLoadEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java index 62b9ef1eccdb5..f73876e677c3a 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java index 8bbbdcbc447a7..6184a6f627e01 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassRedefinition.java b/test/jdk/jdk/jfr/event/runtime/TestClassRedefinition.java index 23c2f2cbc3a5b..5367d76dbf564 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassRedefinition.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassRedefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Tests ClassRedefinition event by redefining classes in a Java agent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.instrument diff --git a/test/jdk/jdk/jfr/event/runtime/TestClassUnloadEvent.java b/test/jdk/jdk/jfr/event/runtime/TestClassUnloadEvent.java index 6507b7e53bfe3..f25b9a69650eb 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestClassUnloadEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestClassUnloadEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @summary The test verifies that a class unload event is created when class is unloaded - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java b/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java index 183d82bc5e201..e2ecea43a8802 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.internal.test * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/runtime/TestDirectBufferStatisticsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestDirectBufferStatisticsEvent.java index 777f2d5fca2be..b007083dde91f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDirectBufferStatisticsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDirectBufferStatisticsEvent.java @@ -36,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java index 83af0de239d3d..f801829d8eb3f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules java.base/jdk.internal.misc jdk.jfr diff --git a/test/jdk/jdk/jfr/event/runtime/TestExceptionEvents.java b/test/jdk/jdk/jfr/event/runtime/TestExceptionEvents.java index 46488f0221a97..8c447ac44bf35 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestExceptionEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestExceptionEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestExceptionEvents diff --git a/test/jdk/jdk/jfr/event/runtime/TestExceptionSubclass.java b/test/jdk/jdk/jfr/event/runtime/TestExceptionSubclass.java index f6917faa8e2f9..0c55b27364eb9 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestExceptionSubclass.java +++ b/test/jdk/jdk/jfr/event/runtime/TestExceptionSubclass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +27,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @bug 8013122 * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/runtime/TestFinalizerStatisticsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestFinalizerStatisticsEvent.java index 8256a62b5712b..ead77f467acb3 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestFinalizerStatisticsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestFinalizerStatisticsEvent.java @@ -36,7 +36,7 @@ * @test * @bug 8266936 8276422 * @summary The test verifies that classes overriding finalize() are represented as events. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -Xlog:class+unload,finalizer -Xmx16m jdk.jfr.event.runtime.TestFinalizerStatisticsEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestFlush.java b/test/jdk/jdk/jfr/event/runtime/TestFlush.java index ad8706a649379..5c450eab05f85 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestFlush.java +++ b/test/jdk/jdk/jfr/event/runtime/TestFlush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary Verifies at the metalevel that stream contents are written to ongoing recordings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xlog:jfr+system+streaming=trace jdk.jfr.event.runtime.TestFlush diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaBlockedEvent.java b/test/jdk/jdk/jfr/event/runtime/TestJavaBlockedEvent.java index 23fb1cd84332c..c29cebc3d1ddf 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaBlockedEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaBlockedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java index 596b50f5b0cd2..5b7fb3e19cad2 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test TestJavaMonitorInflateEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorInflateEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java index a9cbd04019264..d16503f1fdc75 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorWaitEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java index 0e200f68f9ee6..379b9a97a298f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorWaitTimeOut diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java index 4a6c991ec3cc9..92d86b1163cd1 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java b/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java index 1702d5cd2352b..dae73cb76b55d 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java +++ b/test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java b/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java index dc877e1cafc47..4998cb29d3dc2 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test * @summary Tests the JFR events related to modules - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires !vm.graal.enabled * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java b/test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java index 571809ddab40c..132cc7e73b80d 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test * @bug 8216559 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestNativeLibrariesEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestNativeLibraryLoadEvent.java b/test/jdk/jdk/jfr/event/runtime/TestNativeLibraryLoadEvent.java index 240045c1d6089..e0931d7453f1a 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNativeLibraryLoadEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNativeLibraryLoadEvent.java @@ -39,7 +39,7 @@ /** * @test * @bug 8313251 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestNativeLibraryLoadEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java b/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java index b1a564cb4a0cf..9373f7455913b 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.opt.NativeMemoryTracking == null * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java b/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java index a1b5485a5bd7c..ac33c39a1a2d7 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/event/runtime/TestRedefineClasses.java b/test/jdk/jdk/jfr/event/runtime/TestRedefineClasses.java index 40fc583872f44..c4c73ec3d5787 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestRedefineClasses.java +++ b/test/jdk/jdk/jfr/event/runtime/TestRedefineClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ * @test * @summary Tests RedefinitionClasses event by redefining a class in a Java * agent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.instrument diff --git a/test/jdk/jdk/jfr/event/runtime/TestResidentSetSizeEvent.java b/test/jdk/jdk/jfr/event/runtime/TestResidentSetSizeEvent.java index facf222279c78..8b9bd99bf5ebe 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestResidentSetSizeEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestResidentSetSizeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/runtime/TestRetransformClasses.java b/test/jdk/jdk/jfr/event/runtime/TestRetransformClasses.java index a02f97366c3be..582422d8c8031 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestRetransformClasses.java +++ b/test/jdk/jdk/jfr/event/runtime/TestRetransformClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ * @test * @summary Tests the RetransformClasses event by redefining a class in a Java * agent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.instrument diff --git a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java index 8ea0181b0dd40..0dccbc4495a45 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test TestSafepointEvents - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java index d680dde023d7a..61d99fbec4f27 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ /** * @test * @summary Test Shutdown event - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/runtime/TestSizeTFlags.java b/test/jdk/jdk/jfr/event/runtime/TestSizeTFlags.java index 3eaf4cccf6cc3..0c53d7c91a73a 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSizeTFlags.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSizeTFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * @bug 8058552 * @requires vm.hasJFR * @requires vm.gc == "G1" | vm.gc == null - * @key jfr + * @requires vm.flagless * @summary Test checks that flags of type size_t are being sent to the jfr * @library /test/lib * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:+UseTLAB -XX:MinTLABSize=3k -XX:YoungPLABSize=3k -XX:MaxDirectMemorySize=5M jdk.jfr.event.runtime.TestSizeTFlags diff --git a/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java b/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java index f20175da37fd9..7ad50c83399dd 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @bug 8242263 * @requires vm.hasJFR - * @key jfr + * @requires vm.flagless * @library /test/lib * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:DiagnoseSyncOnValueBasedClasses=2 jdk.jfr.event.runtime.TestSyncOnValueBasedClassEvent */ diff --git a/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java b/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java index 9cb506c45cb45..7adc1fabc2393 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestSystemPropertyEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestTableStatisticsEvent.java b/test/jdk/jdk/jfr/event/runtime/TestTableStatisticsEvent.java index 1f5884c4b46e1..9652b5d501ce5 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestTableStatisticsEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestTableStatisticsEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules java.base/jdk.internal.misc diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadAllocationEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadAllocationEvent.java index 192559cd69b3d..69511a4b52159 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadAllocationEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadAllocationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java index a6520614eab85..e6cd9d95d16a3 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadDumpEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadDumpEvent.java index b583d48692668..302874880c29f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadDumpEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadDumpEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestThreadDumpEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadEndEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadEndEvent.java index 160702de36098..0b70cd5bcbc20 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadEndEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadEndEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @compile TestThreadEndEvent.java LatchedThread.java diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java index d65a407430636..3887af38aeba7 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java index c084808ce79ae..e372766b95dab 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @run main/othervm jdk.jfr.event.runtime.TestThreadSleepEvent diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadStartEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadStartEvent.java index 9e8f7b13e31f0..5b0a6ea68a39c 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadStartEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadStartEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @compile TestThreadStartEvent.java LatchedThread.java diff --git a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java index 82a052739791b..2571530a47097 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.gc == "Serial" | vm.gc == null * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/runtime/TestVMOperation.java b/test/jdk/jdk/jfr/event/runtime/TestVMOperation.java index 31fb306c04d79..d9ed619ac3621 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVMOperation.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVMOperation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null - * @key jfr + * @requires vm.flagless * @library /test/lib * @run main/othervm -XX:+UseParallelGC jdk.jfr.event.runtime.TestVMOperation */ diff --git a/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadEndEvent.java b/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadEndEvent.java index 355ef163e6fdd..7de0b321864db 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadEndEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadEndEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @compile TestVirtualThreadEndEvent.java LatchedThread.java diff --git a/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadStartEvent.java b/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadStartEvent.java index 7b4bdb4b28e7f..cc1f38b8a7272 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadStartEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVirtualThreadStartEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @compile TestVirtualThreadStartEvent.java LatchedThread.java diff --git a/test/jdk/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java b/test/jdk/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java index a386adc8ac2ff..a24996f0e5562 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test TestVmFlagChangedEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/security/TestInitialSecurityPropertyEvent.java b/test/jdk/jdk/jfr/event/security/TestInitialSecurityPropertyEvent.java index bebd44782d21b..bed89be84c2ae 100644 --- a/test/jdk/jdk/jfr/event/security/TestInitialSecurityPropertyEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestInitialSecurityPropertyEvent.java @@ -38,7 +38,7 @@ * @test * @bug 8292177 * @summary InitialSecurityProperty JFR event - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules java.base/jdk.internal.access diff --git a/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java b/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java index ff5919b25909a..4ede92aee4166 100644 --- a/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * @test * @bug 8148188 * @summary Enhance the security libraries to record events of interest - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.security.TestSecurityPropertyModificationEvent diff --git a/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java b/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java index df801c5190742..70ed6f3d867d9 100644 --- a/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java @@ -42,7 +42,7 @@ * @test * @bug 8254711 * @summary Add JFR events for security crypto algorithms - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.events diff --git a/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java b/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java index 7c5240a2a72e5..559290f50b47f 100644 --- a/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ * @test * @bug 8148188 * @summary Enhance the security libraries to record events of interest - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.event.security.TestTLSHandshakeEvent diff --git a/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java b/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java index e7e905830a44b..60b1406a0dc5f 100644 --- a/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * @test * @bug 8148188 8292033 * @summary Enhance the security libraries to record events of interest - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules java.base/sun.security.x509 java.base/sun.security.tools.keytool * @library /test/lib diff --git a/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java b/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java index 651a6390f6857..92dc99ef8c713 100644 --- a/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ * @test * @bug 8148188 * @summary Enhance the security libraries to record events of interest - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.events java.base/sun.security.x509 java.base/sun.security.tools.keytool diff --git a/test/jdk/jdk/jfr/javaagent/TestEventInstrumentation.java b/test/jdk/jdk/jfr/javaagent/TestEventInstrumentation.java index d5997f1ad4666..1a5ad27725b8c 100644 --- a/test/jdk/jdk/jfr/javaagent/TestEventInstrumentation.java +++ b/test/jdk/jdk/jfr/javaagent/TestEventInstrumentation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ * @test * @summary Verify that a subclass of the JFR Event class * can be successfully instrumented. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jartool/sun.tools.jar diff --git a/test/jdk/jdk/jfr/javaagent/TestLoadedAgent.java b/test/jdk/jdk/jfr/javaagent/TestLoadedAgent.java index deb38d5e8db86..92b88336b3e0d 100644 --- a/test/jdk/jdk/jfr/javaagent/TestLoadedAgent.java +++ b/test/jdk/jdk/jfr/javaagent/TestLoadedAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @summary Tests emitting events in a dynamically loaded Java agent * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/javaagent/TestPremainAgent.java b/test/jdk/jdk/jfr/javaagent/TestPremainAgent.java index 19a39ff7ef07a..388779fcc7f84 100644 --- a/test/jdk/jdk/jfr/javaagent/TestPremainAgent.java +++ b/test/jdk/jdk/jfr/javaagent/TestPremainAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 - * @key jfr + * @requires vm.flagless * @summary Tests emitting event before main using a Java agent * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/jcmd/TestFilenameExpansion.java b/test/jdk/jdk/jfr/jcmd/TestFilenameExpansion.java index 9b9f67ba0faa0..789d5cbe5bd36 100644 --- a/test/jdk/jdk/jfr/jcmd/TestFilenameExpansion.java +++ b/test/jdk/jdk/jfr/jcmd/TestFilenameExpansion.java @@ -34,7 +34,7 @@ /** * @test * @summary The test verifies JFR.start/dump/stop commands - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestFilenameExpansion diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdChangeLogLevel.java b/test/jdk/jdk/jfr/jcmd/TestJcmdChangeLogLevel.java index dfb755a7f215f..c4ef5ecfa74fa 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdChangeLogLevel.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdChangeLogLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test TestJcmdLogLevelChange - * @key jfr + * @requires vm.flagless * @summary Test changing log level * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java index 29e666a830c01..f64c99bedbcbf 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java @@ -38,7 +38,7 @@ /** * @test * @summary The test verifies JFR.configure command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigureReadOnly.java b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigureReadOnly.java index 6ddf3a752342d..9eefbd183b2e4 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigureReadOnly.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigureReadOnly.java @@ -28,7 +28,7 @@ /** * @test * @summary The test verifies JFR.configure command can only set certain options before JFR is started. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdConfigureReadOnly diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDump.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDump.java index 6f4be44ff6377..2bc7aa857e3d5 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDump.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test * @summary The test verifies JFR.dump command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:FlightRecorderOptions:maxchunksize=1M jdk.jfr.jcmd.TestJcmdDump diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java index 4612e7c7c8c9d..eca991eaab610 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary The test verifies JFR.dump command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpGeneratedFilename diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpLimited.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpLimited.java index ce4b11937c611..8b8ba050245e8 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpLimited.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpLimited.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ /** * @test * @summary The test verifies JFR.dump command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpLimited diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java index 5d469c698c190..499bf9452be68 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.internal.test * @library /test/lib /test/jdk - * @key jfr + * @requires vm.flagless * * @run main/othervm -XX:TLABSize=2k jdk.jfr.jcmd.TestJcmdDumpPathToGCRoots */ diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java index 93265dc677cf5..268d250418da1 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @bug 8220657 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpWithFileName diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdLegacy.java b/test/jdk/jdk/jfr/jcmd/TestJcmdLegacy.java index a6aa2143f41dc..33e5d9542efe6 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdLegacy.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdLegacy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test TestClassId - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java b/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java index bb057cce3867e..a9b9bcc58725f 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java @@ -25,7 +25,7 @@ /** * @test * @summary The test verifies that options can only be specified once with jcmd JFR - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.dcmd diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdPreserveRepository.java b/test/jdk/jdk/jfr/jcmd/TestJcmdPreserveRepository.java index 374c760ae9b47..9f42bef6e7e87 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdPreserveRepository.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdPreserveRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Test verifies that files are left after preserve-repository has been set using jcmd JFR.configure - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdPreserveRepository diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdSaveToFile.java b/test/jdk/jdk/jfr/jcmd/TestJcmdSaveToFile.java index b6542420bd5c0..b7ce317f9288b 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdSaveToFile.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdSaveToFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary The test verifies that recording can be written to a file both with JFR.start and JFR.stop - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdSaveToFile diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java index 49035cff8f45c..e683880195b39 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Verify error when starting with a dir that does not exist. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartDirNotExist diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java index 0d6e8fa076065..046ecd190f813 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Start a recording with a flush interval - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr:open diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartGeneratedFilename.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartGeneratedFilename.java index d3e4dd7b2c2b6..bf365b9c248f1 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartGeneratedFilename.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartGeneratedFilename.java @@ -38,7 +38,7 @@ /** * @test * @summary Verify that a filename is generated - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartGeneratedFilename diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java index 718ee55a839a7..e8e40557eab5e 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Verify error when starting with invalid file. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartInvaldFile diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java index ff87d2b68a112..5e116480aa89f 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ * @summary Start a recording with or without path-to-gc-roots * @requires vm.hasJFR * @library /test/lib /test/jdk - * @key jfr + * @requires vm.flagless * * @run main/othervm jdk.jfr.jcmd.TestJcmdStartPathToGCRoots */ diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java index c1727c9ef974c..d74c29ae7bf03 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Verify error when starting with read-only file. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartReadOnlyFile diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java index 5985b85b167b3..374234fe07b06 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test * @summary Start a recording without name. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartStopDefault diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java index fe8db5f773aa0..41c144c16ee75 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary The test verifies that recording can be started with options delay|duration|maxage|maxsize - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:FlightRecorderOptions:maxchunksize=2097152 jdk.jfr.jcmd.TestJcmdStartWithOptions diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithSettings.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithSettings.java index d0e502c52a361..afe405ef29dfe 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithSettings.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary The test verifies that recording can be started with setting file(s) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStartWithSettings diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java index 63f201c08bd31..dc74674ca9901 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Verify error when stopping with invalid file. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStopInvalidFile diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java index 10401bdf12f36..a91f11a55d682 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Verify error when stopping with read-only file. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStopReadOnlyFile diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStopWithoutFilename.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStopWithoutFilename.java index 3cd7a572427fb..a4a8051937ffb 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdStopWithoutFilename.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStopWithoutFilename.java @@ -28,7 +28,7 @@ /** * @test * @summary The test verifies JFR.stop - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdStopWithoutFilename diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdView.java b/test/jdk/jdk/jfr/jcmd/TestJcmdView.java index 44db54e785038..92e5c950f9bfb 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdView.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary The test verifies JFR.view command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != false diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdViewMissingData.java b/test/jdk/jdk/jfr/jcmd/TestJcmdViewMissingData.java index 9ba7e9119d923..b7a22b1adcca5 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdViewMissingData.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdViewMissingData.java @@ -30,7 +30,7 @@ /** * @test * @summary The test verifies JFR.view command - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jcmd.TestJcmdViewMissingData diff --git a/test/jdk/jdk/jfr/jmx/TestClone.java b/test/jdk/jdk/jfr/jmx/TestClone.java index 9e1c2d4e9a5fb..586a58a607c88 100644 --- a/test/jdk/jdk/jfr/jmx/TestClone.java +++ b/test/jdk/jdk/jfr/jmx/TestClone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestClone diff --git a/test/jdk/jdk/jfr/jmx/TestCloneRepeat.java b/test/jdk/jdk/jfr/jmx/TestCloneRepeat.java index 61458b676c93e..099aec3b4782f 100644 --- a/test/jdk/jdk/jfr/jmx/TestCloneRepeat.java +++ b/test/jdk/jdk/jfr/jmx/TestCloneRepeat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestCloneRepeat diff --git a/test/jdk/jdk/jfr/jmx/TestConfigurationInfo.java b/test/jdk/jdk/jfr/jmx/TestConfigurationInfo.java index 450caaa93edf7..4b6f786ee6108 100644 --- a/test/jdk/jdk/jfr/jmx/TestConfigurationInfo.java +++ b/test/jdk/jdk/jfr/jmx/TestConfigurationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestConfigurationInfo diff --git a/test/jdk/jdk/jfr/jmx/TestCopyTo.java b/test/jdk/jdk/jfr/jmx/TestCopyTo.java index 3da3e266fca08..6ed7f14547e63 100644 --- a/test/jdk/jdk/jfr/jmx/TestCopyTo.java +++ b/test/jdk/jdk/jfr/jmx/TestCopyTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestCopyTo diff --git a/test/jdk/jdk/jfr/jmx/TestCopyToInvalidPath.java b/test/jdk/jdk/jfr/jmx/TestCopyToInvalidPath.java index 032e1c3dc9b2c..d868eb4c3dd8a 100644 --- a/test/jdk/jdk/jfr/jmx/TestCopyToInvalidPath.java +++ b/test/jdk/jdk/jfr/jmx/TestCopyToInvalidPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestCopyToInvalidPath diff --git a/test/jdk/jdk/jfr/jmx/TestCopyToReadOnlyDir.java b/test/jdk/jdk/jfr/jmx/TestCopyToReadOnlyDir.java index faaae63fbb27d..c9364f2b43c1b 100644 --- a/test/jdk/jdk/jfr/jmx/TestCopyToReadOnlyDir.java +++ b/test/jdk/jdk/jfr/jmx/TestCopyToReadOnlyDir.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestCopyToReadOnlyDir diff --git a/test/jdk/jdk/jfr/jmx/TestCopyToRunning.java b/test/jdk/jdk/jfr/jmx/TestCopyToRunning.java index a8afc2110f1f3..82e453057249c 100644 --- a/test/jdk/jdk/jfr/jmx/TestCopyToRunning.java +++ b/test/jdk/jdk/jfr/jmx/TestCopyToRunning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Copy a recording to file while it is running. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/TestEventTypes.java b/test/jdk/jdk/jfr/jmx/TestEventTypes.java index 4f284b399ce66..a7d0219661d95 100644 --- a/test/jdk/jdk/jfr/jmx/TestEventTypes.java +++ b/test/jdk/jdk/jfr/jmx/TestEventTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Verifies that EventTypes from jmx and FlightRecorder are the same. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/TestFlightRecorderMXBeanLeak.java b/test/jdk/jdk/jfr/jmx/TestFlightRecorderMXBeanLeak.java index d2096fde915d1..54f4fa141234f 100644 --- a/test/jdk/jdk/jfr/jmx/TestFlightRecorderMXBeanLeak.java +++ b/test/jdk/jdk/jfr/jmx/TestFlightRecorderMXBeanLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Verifies that attributes in FlightRecorderMXBean can be inspected * without causing a memory leak. * @requires vm.hasJFR diff --git a/test/jdk/jdk/jfr/jmx/TestGetRecordings.java b/test/jdk/jdk/jfr/jmx/TestGetRecordings.java index 339953fcbf451..af930be5f1776 100644 --- a/test/jdk/jdk/jfr/jmx/TestGetRecordings.java +++ b/test/jdk/jdk/jfr/jmx/TestGetRecordings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -Djdk.attach.allowAttachSelf=true -Dcom.sun.management.jmxremote jdk.jfr.jmx.TestGetRecordings diff --git a/test/jdk/jdk/jfr/jmx/TestGetRecordingsMultiple.java b/test/jdk/jdk/jfr/jmx/TestGetRecordingsMultiple.java index cbaaeda98a0a1..8788097228773 100644 --- a/test/jdk/jdk/jfr/jmx/TestGetRecordingsMultiple.java +++ b/test/jdk/jdk/jfr/jmx/TestGetRecordingsMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestGetRecordingsMultiple diff --git a/test/jdk/jdk/jfr/jmx/TestMultipleRecordings.java b/test/jdk/jdk/jfr/jmx/TestMultipleRecordings.java index 4d1619ed30d1f..316a4104db6d7 100644 --- a/test/jdk/jdk/jfr/jmx/TestMultipleRecordings.java +++ b/test/jdk/jdk/jfr/jmx/TestMultipleRecordings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestMultipleRecordings diff --git a/test/jdk/jdk/jfr/jmx/TestNotificationListener.java b/test/jdk/jdk/jfr/jmx/TestNotificationListener.java index 950e5fa6d59c3..a27059a2faee2 100644 --- a/test/jdk/jdk/jfr/jmx/TestNotificationListener.java +++ b/test/jdk/jdk/jfr/jmx/TestNotificationListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestNotificationListener diff --git a/test/jdk/jdk/jfr/jmx/TestPredefinedConfiguration.java b/test/jdk/jdk/jfr/jmx/TestPredefinedConfiguration.java index 6aa6d6bbbbd43..d329ceae73442 100644 --- a/test/jdk/jdk/jfr/jmx/TestPredefinedConfiguration.java +++ b/test/jdk/jdk/jfr/jmx/TestPredefinedConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestPredefinedConfiguration diff --git a/test/jdk/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java b/test/jdk/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java index d68bacbcbd07b..32d5f30540c15 100644 --- a/test/jdk/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java +++ b/test/jdk/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestPredefinedConfigurationInvalid diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingOptions.java b/test/jdk/jdk/jfr/jmx/TestRecordingOptions.java index 6cab6b4a2ebcc..8f048ace3c3b7 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingOptions.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestRecordingOptions diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingSettings.java b/test/jdk/jdk/jfr/jmx/TestRecordingSettings.java index 026485e494249..d7c0387e8cf09 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingSettings.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestRecordingSettings diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingSettingsInvalid.java b/test/jdk/jdk/jfr/jmx/TestRecordingSettingsInvalid.java index 669b30cf36be1..a29bd3a61d1fd 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingSettingsInvalid.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingSettingsInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Verify exception when setting invalid settings. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingSettingsMultiple.java b/test/jdk/jdk/jfr/jmx/TestRecordingSettingsMultiple.java index c1ab3d80f380a..c383e1b2fd51f 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingSettingsMultiple.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingSettingsMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestRecordingSettingsMultiple diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingState.java b/test/jdk/jdk/jfr/jmx/TestRecordingState.java index de9b316ef2c4e..05d57f01b4417 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingState.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestRecordingState diff --git a/test/jdk/jdk/jfr/jmx/TestRecordingStateInvalid.java b/test/jdk/jdk/jfr/jmx/TestRecordingStateInvalid.java index 91e5384eb4b18..dbfc6783c5412 100644 --- a/test/jdk/jdk/jfr/jmx/TestRecordingStateInvalid.java +++ b/test/jdk/jdk/jfr/jmx/TestRecordingStateInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestRecordingStateInvalid diff --git a/test/jdk/jdk/jfr/jmx/TestSetConfiguration.java b/test/jdk/jdk/jfr/jmx/TestSetConfiguration.java index e3a6c9addf02a..168633d15208b 100644 --- a/test/jdk/jdk/jfr/jmx/TestSetConfiguration.java +++ b/test/jdk/jdk/jfr/jmx/TestSetConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestSetConfiguration diff --git a/test/jdk/jdk/jfr/jmx/TestSetConfigurationInvalid.java b/test/jdk/jdk/jfr/jmx/TestSetConfigurationInvalid.java index ec5bcffdc9a6c..82c3681b1bf84 100644 --- a/test/jdk/jdk/jfr/jmx/TestSetConfigurationInvalid.java +++ b/test/jdk/jdk/jfr/jmx/TestSetConfigurationInvalid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Verify Exception when setting invalid config. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/TestSnapshot.java b/test/jdk/jdk/jfr/jmx/TestSnapshot.java index b4eb13216b5cb..09cd515c4ae6f 100644 --- a/test/jdk/jdk/jfr/jmx/TestSnapshot.java +++ b/test/jdk/jdk/jfr/jmx/TestSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestSnapshot diff --git a/test/jdk/jdk/jfr/jmx/TestStartRecording.java b/test/jdk/jdk/jfr/jmx/TestStartRecording.java index 52a43b1f80eac..1ff3eab6d533e 100644 --- a/test/jdk/jdk/jfr/jmx/TestStartRecording.java +++ b/test/jdk/jdk/jfr/jmx/TestStartRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestStartRecording diff --git a/test/jdk/jdk/jfr/jmx/TestStream.java b/test/jdk/jdk/jfr/jmx/TestStream.java index 3763054ae3ba7..53d0ba473b368 100644 --- a/test/jdk/jdk/jfr/jmx/TestStream.java +++ b/test/jdk/jdk/jfr/jmx/TestStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestStream diff --git a/test/jdk/jdk/jfr/jmx/TestStreamClosed.java b/test/jdk/jdk/jfr/jmx/TestStreamClosed.java index 5f6c49544caf9..3533f7c94e75c 100644 --- a/test/jdk/jdk/jfr/jmx/TestStreamClosed.java +++ b/test/jdk/jdk/jfr/jmx/TestStreamClosed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Call readStream() after closeStream() * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/TestStreamMultiple.java b/test/jdk/jdk/jfr/jmx/TestStreamMultiple.java index f973376574abf..85518790b1ffb 100644 --- a/test/jdk/jdk/jfr/jmx/TestStreamMultiple.java +++ b/test/jdk/jdk/jfr/jmx/TestStreamMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.jmx.TestStreamMultiple diff --git a/test/jdk/jdk/jfr/jmx/TestWrongId.java b/test/jdk/jdk/jfr/jmx/TestWrongId.java index 8a88b970248f0..598a7f05a37f7 100644 --- a/test/jdk/jdk/jfr/jmx/TestWrongId.java +++ b/test/jdk/jdk/jfr/jmx/TestWrongId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Call functions with invalid argument id. Verify Exception. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/info/TestConfigurationInfo.java b/test/jdk/jdk/jfr/jmx/info/TestConfigurationInfo.java index c82f064ae4268..5158d2f7ce132 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestConfigurationInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestConfigurationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test for ConfigurationInfo. Compare infos from java API and jmx API. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java b/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java index 001147e8e5ccf..79421d6ef563f 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test for EventTypeInfo * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java b/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java index a653af76dc0c7..7aaff146f2b02 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test for RecordingInfo * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java b/test/jdk/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java index 59d5aaa5fa99b..fbfaa250351f6 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test for SettingDescriptorInfo. Compare infos from java API and jmx API. * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestClose.java b/test/jdk/jdk/jfr/jmx/streaming/TestClose.java index d742422e69cb8..08c302d6d4b1c 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestClose.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestClose.java @@ -34,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that a RemoteRecordingStream can be closed * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java b/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java index 04a9139b12272..e20f92c301415 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Sanity test methods that delegates to an ordinary stream * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestDumpOrder.java b/test/jdk/jdk/jfr/jmx/streaming/TestDumpOrder.java index 0c6d8fe313d68..7535960366cee 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestDumpOrder.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestDumpOrder.java @@ -42,7 +42,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that chunks arrive in the same order they were committed * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java b/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java index 6a07c57ff7879..06e9691cfa216 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java @@ -35,7 +35,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that event settings for a RemoteRecordingStream can be changed * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java b/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java index 7bf389c75ad85..b79fbc2bcf04c 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that max size can be set for a RemoteRecordingStream * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestMetadataEvent.java b/test/jdk/jdk/jfr/jmx/streaming/TestMetadataEvent.java index 935ef292a5590..3e0e8773f0ad6 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestMetadataEvent.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestMetadataEvent.java @@ -36,7 +36,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Sanity tests RemoteRecordingStream::onMetadata * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java b/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java index e91a58da7b81e..942f64a5da4c3 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java @@ -34,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that a RemoteRecordingStream can stream over multiple chunks * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestNew.java b/test/jdk/jdk/jfr/jmx/streaming/TestNew.java index 9cf7a0cd16fc0..d2489730b032b 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestNew.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestNew.java @@ -38,7 +38,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Test constructors of RemoteRecordingStream * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java b/test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java index 51e0c815dc0b7..9390857c09e5a 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ /** * @test * @summary Tests RecordingStream::dump(Path) - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.jmx.streaming.TestRemoteDump diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java index cf78ea399e760..8a7c7428a99bf 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java @@ -38,7 +38,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that streaming can work over chunk rotations * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java b/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java index d0a9acab9cdff..2d1cb50dcfc42 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java @@ -37,7 +37,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests that a RemoteRecordingStream can be configured using * setSettings * @requires vm.hasJFR diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestStart.java b/test/jdk/jdk/jfr/jmx/streaming/TestStart.java index 0755e99cb041b..6d4bfc10f81ae 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestStart.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestStart.java @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Sanity tests RemoteRecordingStream::start() * @requires vm.hasJFR * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestStop.java b/test/jdk/jdk/jfr/jmx/streaming/TestStop.java index 83656cba8a759..572577786a198 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestStop.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestStop.java @@ -40,7 +40,7 @@ /** * @test * @summary Tests RemoteRecordingStream::stop() - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @build jdk.jfr.api.consumer.recordingstream.EventProducer diff --git a/test/jdk/jdk/jfr/jvm/TestBeginAndEnd.java b/test/jdk/jdk/jfr/jvm/TestBeginAndEnd.java index c85b0966b6e8f..e25d216ab5fd5 100644 --- a/test/jdk/jdk/jfr/jvm/TestBeginAndEnd.java +++ b/test/jdk/jdk/jfr/jvm/TestBeginAndEnd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test TestBeginAndEnd - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.internal * @run main/othervm jdk.jfr.jvm.TestBeginAndEnd diff --git a/test/jdk/jdk/jfr/jvm/TestChunkIntegrity.java b/test/jdk/jdk/jfr/jvm/TestChunkIntegrity.java index aba19bd37b707..c66d323d11da2 100644 --- a/test/jdk/jdk/jfr/jvm/TestChunkIntegrity.java +++ b/test/jdk/jdk/jfr/jvm/TestChunkIntegrity.java @@ -56,7 +56,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm/timeout=300 jdk.jfr.jvm.TestChunkIntegrity diff --git a/test/jdk/jdk/jfr/jvm/TestClassId.java b/test/jdk/jdk/jfr/jvm/TestClassId.java index 058183472e846..b82abb64d5022 100644 --- a/test/jdk/jdk/jfr/jvm/TestClassId.java +++ b/test/jdk/jdk/jfr/jvm/TestClassId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test TestClassId - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java b/test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java index 70e34bcd5140d..81f2a34a6b857 100644 --- a/test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java +++ b/test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @bug 8231081 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.internal * @library /test/lib /test/jdk @@ -49,7 +49,7 @@ /** * System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent is NOT set. * If this flag is set G1 will never unload classes on System.gc() and - * As far as the "jfr" key guarantees no VM flags are set from the outside + * As far as the vm.flagless guarantees no VM flags are set from the outside * it should be enough with System.gc(). */ public final class TestClearStaleConstants { diff --git a/test/jdk/jdk/jfr/jvm/TestCounterTime.java b/test/jdk/jdk/jfr/jvm/TestCounterTime.java index f06fdd0eed676..6cd60eae8945a 100644 --- a/test/jdk/jdk/jfr/jvm/TestCounterTime.java +++ b/test/jdk/jdk/jfr/jvm/TestCounterTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test TestCounterTime - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestCreateNative.java b/test/jdk/jdk/jfr/jvm/TestCreateNative.java index 1050856161d66..9ebbe7891b380 100644 --- a/test/jdk/jdk/jfr/jvm/TestCreateNative.java +++ b/test/jdk/jdk/jfr/jvm/TestCreateNative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test * @summary Checks that the JVM can rollback on native initialization failures. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java index 29e21ddd89d7d..a7e620b203c15 100644 --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Verifies that data associated with a running recording can be evacuated to an hs_err_pidXXX.jfr when the VM crashes * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/jvm/TestEventDuration.java b/test/jdk/jdk/jfr/jvm/TestEventDuration.java index 53a7af9e323cf..1b0a44d843a30 100644 --- a/test/jdk/jdk/jfr/jvm/TestEventDuration.java +++ b/test/jdk/jdk/jfr/jvm/TestEventDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test Tests that the event duration is zero after a chunk rotation - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java b/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java index 9e68d0501dfd9..ca56a3feb416e 100644 --- a/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java +++ b/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test TestEventWriterLog * @summary Test that log message of JFR when handle bytecodes - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm TestEventWriterLog diff --git a/test/jdk/jdk/jfr/jvm/TestFatEvent.java b/test/jdk/jdk/jfr/jvm/TestFatEvent.java index 93e8a838de12f..3e10074cce9c7 100644 --- a/test/jdk/jdk/jfr/jvm/TestFatEvent.java +++ b/test/jdk/jdk/jfr/jvm/TestFatEvent.java @@ -36,7 +36,7 @@ /** * @test TestFatEvent - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Dprop1=12345678901234567890123456789012345678901234567890 diff --git a/test/jdk/jdk/jfr/jvm/TestFormatDuration.java b/test/jdk/jdk/jfr/jvm/TestFormatDuration.java index 0fb1bbe07c557..a0d5b729fcfce 100644 --- a/test/jdk/jdk/jfr/jvm/TestFormatDuration.java +++ b/test/jdk/jdk/jfr/jvm/TestFormatDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal.util diff --git a/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java b/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java index b758520ac81b2..2849258868a95 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java +++ b/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test TestGetAllEventClasses - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java index 7920678b7f0e6..a22e59a39fe8c 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java +++ b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java @@ -39,7 +39,7 @@ /** * @test id=default - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.internal.vm.ci/jdk.vm.ci.meta @@ -71,7 +71,7 @@ /** * @test id=jvmci - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.jvmci * @library /test/lib diff --git a/test/jdk/jdk/jfr/jvm/TestGetEventWriterPackage.java b/test/jdk/jdk/jfr/jvm/TestGetEventWriterPackage.java index 065458d4ac778..3d96330f6ac2f 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetEventWriterPackage.java +++ b/test/jdk/jdk/jfr/jvm/TestGetEventWriterPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ import jdk.jfr.Registered; /** * @test Tests that a module can't execute code in jdk.jfr.internal.event unless an event has been registered. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm diff --git a/test/jdk/jdk/jfr/jvm/TestGetEventWriterReflection.java b/test/jdk/jdk/jfr/jvm/TestGetEventWriterReflection.java index 2e0f87020e680..dae4e9a67b5a3 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetEventWriterReflection.java +++ b/test/jdk/jdk/jfr/jvm/TestGetEventWriterReflection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import jdk.jfr.Registered; /** * @test Tests that reflective access works as (normally) expected - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java b/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java index 8a23e55140886..637a5f3920d36 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java +++ b/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test TestGetStackTraceId - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestHiddenWait.java b/test/jdk/jdk/jfr/jvm/TestHiddenWait.java index b064285329c0f..aaefc60527ce2 100644 --- a/test/jdk/jdk/jfr/jvm/TestHiddenWait.java +++ b/test/jdk/jdk/jfr/jvm/TestHiddenWait.java @@ -38,7 +38,7 @@ /** * @test TestHiddenWait - * @key jfr + * @requires vm.flagless * @summary Checks that JFR code don't emit noise in the form of ThreadSleep and JavaMonitorWait events. * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java b/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java index 6d3ea8d015a89..a846eac2350c8 100644 --- a/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java +++ b/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test * @summary Intrinsic for JFR - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * diff --git a/test/jdk/jdk/jfr/jvm/TestJavaEvent.java b/test/jdk/jdk/jfr/jvm/TestJavaEvent.java index 0a2f2ecaf5b61..8a006dd9eafd9 100644 --- a/test/jdk/jdk/jfr/jvm/TestJavaEvent.java +++ b/test/jdk/jdk/jfr/jvm/TestJavaEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +41,7 @@ /** * @test TestGetThreadId - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent512k.java b/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent512k.java index eacffb7a13b29..530004d3ebddc 100644 --- a/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent512k.java +++ b/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent512k.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test TestLargeJavaEvent512k - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent64k.java b/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent64k.java index 0de03efb35c59..b71ed0ec36130 100644 --- a/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent64k.java +++ b/test/jdk/jdk/jfr/jvm/TestLargeJavaEvent64k.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test TestLargeJavaEvent64k - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestLogImplementation.java b/test/jdk/jdk/jfr/jvm/TestLogImplementation.java index d9d42074b7b98..faa7bc18a3c8b 100644 --- a/test/jdk/jdk/jfr/jvm/TestLogImplementation.java +++ b/test/jdk/jdk/jfr/jvm/TestLogImplementation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test TestLogImplementation - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestLogOutput.java b/test/jdk/jdk/jfr/jvm/TestLogOutput.java index 18527abb90b01..5580270027a4d 100644 --- a/test/jdk/jdk/jfr/jvm/TestLogOutput.java +++ b/test/jdk/jdk/jfr/jvm/TestLogOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +31,7 @@ /** * @test TestLogOutput - * @key jfr + * @requires vm.flagless * @summary Sanity test jfr logging output * @requires vm.hasJFR * @library /test/lib diff --git a/test/jdk/jdk/jfr/jvm/TestLongStringsInPool.java b/test/jdk/jdk/jfr/jvm/TestLongStringsInPool.java index 8ce3fd3859fdb..45b66d508cda1 100644 --- a/test/jdk/jdk/jfr/jvm/TestLongStringsInPool.java +++ b/test/jdk/jdk/jfr/jvm/TestLongStringsInPool.java @@ -36,7 +36,7 @@ /** * @test * @summary Verify that duplicate longer strings doesn't take up unneccessary space - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.jvm.TestLongStringsInPool diff --git a/test/jdk/jdk/jfr/jvm/TestModularImage.java b/test/jdk/jdk/jfr/jvm/TestModularImage.java index 9643324afd8f1..fe49b460f188e 100644 --- a/test/jdk/jdk/jfr/jvm/TestModularImage.java +++ b/test/jdk/jdk/jfr/jvm/TestModularImage.java @@ -38,7 +38,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Checks that a JDK image with and without the jdk.jfr module behaves * as expected * @requires vm.hasJFR diff --git a/test/jdk/jdk/jfr/jvm/TestPid.java b/test/jdk/jdk/jfr/jvm/TestPid.java index 20a8b42f8a54c..f71042d1c847f 100644 --- a/test/jdk/jdk/jfr/jvm/TestPid.java +++ b/test/jdk/jdk/jfr/jvm/TestPid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test TestPid - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestPrimitiveClasses.java b/test/jdk/jdk/jfr/jvm/TestPrimitiveClasses.java index bb0163bc925f0..548bb3fc19e44 100644 --- a/test/jdk/jdk/jfr/jvm/TestPrimitiveClasses.java +++ b/test/jdk/jdk/jfr/jvm/TestPrimitiveClasses.java @@ -34,7 +34,7 @@ /** * @test TestPrimitiveClasses - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.jvm.TestPrimitiveClasses diff --git a/test/jdk/jdk/jfr/jvm/TestThreadExclusion.java b/test/jdk/jdk/jfr/jvm/TestThreadExclusion.java index 411710881cad4..000923d26785b 100644 --- a/test/jdk/jdk/jfr/jvm/TestThreadExclusion.java +++ b/test/jdk/jdk/jfr/jvm/TestThreadExclusion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestUnloadEventClassCount.java b/test/jdk/jdk/jfr/jvm/TestUnloadEventClassCount.java index ddb7ec3c757a7..23b45f0b5f728 100644 --- a/test/jdk/jdk/jfr/jvm/TestUnloadEventClassCount.java +++ b/test/jdk/jdk/jfr/jvm/TestUnloadEventClassCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Unit test for JVM#getUnloadedEventClassCount * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/jvm/TestUnsupportedVM.java b/test/jdk/jdk/jfr/jvm/TestUnsupportedVM.java index 81a83222c75f9..a3dbeef6d5c9b 100644 --- a/test/jdk/jdk/jfr/jvm/TestUnsupportedVM.java +++ b/test/jdk/jdk/jfr/jvm/TestUnsupportedVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ /** * @test TestUnsupportedVM - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/jvm/TestVerifyInstrumentation.java b/test/jdk/jdk/jfr/jvm/TestVerifyInstrumentation.java index e003a4b3e4849..ec9e64972ec3c 100644 --- a/test/jdk/jdk/jfr/jvm/TestVerifyInstrumentation.java +++ b/test/jdk/jdk/jfr/jvm/TestVerifyInstrumentation.java @@ -29,7 +29,7 @@ /** * @test * @bug 8316271 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -Xverify:all jdk.jfr.jvm.TestVerifyInstrumentation diff --git a/test/jdk/jdk/jfr/jvm/TestVirtualThreadExclusion.java b/test/jdk/jdk/jfr/jvm/TestVirtualThreadExclusion.java index e7a4713c223fc..c2a820aaf9ad1 100644 --- a/test/jdk/jdk/jfr/jvm/TestVirtualThreadExclusion.java +++ b/test/jdk/jdk/jfr/jvm/TestVirtualThreadExclusion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/jvm/TestWaste.java b/test/jdk/jdk/jfr/jvm/TestWaste.java index afa2dda4ee12c..c755ca4c3d02d 100644 --- a/test/jdk/jdk/jfr/jvm/TestWaste.java +++ b/test/jdk/jdk/jfr/jvm/TestWaste.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test diff --git a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java index 50514e0202441..bae1dcd08cbe6 100644 --- a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java +++ b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @library /test/lib diff --git a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java index bca93044fc906..66b27e5978d2f 100644 --- a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java +++ b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ /** * @test * @summary Start a FlightRecording with dumponexit. Verify dump exists. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.startupargs.TestDumpOnExit diff --git a/test/jdk/jdk/jfr/startupargs/TestEventSettings.java b/test/jdk/jdk/jfr/startupargs/TestEventSettings.java index 41e59523339c4..37af394affdfe 100644 --- a/test/jdk/jdk/jfr/startupargs/TestEventSettings.java +++ b/test/jdk/jdk/jfr/startupargs/TestEventSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Start a recording with custom settings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java index 83c4d07c23bb7..25beb590879f4 100644 --- a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java +++ b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Start a recording with a flush interval - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java b/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java index cf0cb0212169b..092ec73546f21 100644 --- a/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java +++ b/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Start a recording with custom settings - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java index 9c90d04691ab1..6827c663ee37b 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java +++ b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java index 24be874a87f60..c70f98105689e 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java +++ b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * * @library /test/lib diff --git a/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java b/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java index 0613906aface7..f85baed6f9003 100644 --- a/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java +++ b/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @requires vm.hasJFR * @modules jdk.jfr/jdk.jfr.internal.test * @library /test/lib - * @key jfr + * @requires vm.flagless * * @run main/othervm -XX:TLABSize=2k -XX:FlightRecorderOptions:old-object-queue-size=0 jdk.jfr.startupargs.TestOldObjectQueueSize off * @run main/othervm -XX:TLABSize=2k -Xlog:gc+tlab=trace -XX:FlightRecorderOptions:old-object-queue-size=10000 jdk.jfr.startupargs.TestOldObjectQueueSize many diff --git a/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java b/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java index 3a4d3f207326a..27c1533ca3b2c 100644 --- a/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java +++ b/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java @@ -12,7 +12,7 @@ * @test * @summary Checks that locale is respected when using -XX:FlightRecorderOptions * See JDK-8244508 - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr * @library /test/lib diff --git a/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java b/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java index 4f4ee195e1fae..74023639f47c8 100644 --- a/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java +++ b/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java @@ -31,7 +31,7 @@ /** * @test * @summary Tests that -XX:FlightRecorderOptions:preserve-repository works - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @modules jdk.jfr * @library /test/lib diff --git a/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java b/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java index a5052b42d6d93..fcddff8aca471 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java +++ b/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Set repository path. Verify recording created in repo. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=TestStartRecording,settings=profile -XX:FlightRecorderOptions:repository=./repo jdk.jfr.startupargs.TestRepositoryPath diff --git a/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java b/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java index 4dda1ab23d2e1..73bc600d782b3 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java +++ b/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Set repository path. Verify recording created in repo. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=myrec,settings=profile -XX:FlightRecorderOptions:repository=./subdirectory/subdirectory1/subdirectory2/subdirectory3/subdirectory4/subdirectory5/subdirectory6/subdirectory7/subdirectory8/subdirectory9/subdirectory10/subdirectory11/subdirectory12/subdirectory13/subdirectory14/subdirectory15 jdk.jfr.startupargs.TestRepositoryPathLong diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransform.java b/test/jdk/jdk/jfr/startupargs/TestRetransform.java index 2e4067ae5441d..5d26a4bb0a98b 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRetransform.java +++ b/test/jdk/jdk/jfr/startupargs/TestRetransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm -XX:FlightRecorderOptions:retransform=false jdk.jfr.startupargs.TestRetransform diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java index 186a87a12c2d2..02636e4b715d1 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java +++ b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.startupargs.TestRetransformUsingLog diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDelay.java b/test/jdk/jdk/jfr/startupargs/TestStartDelay.java index 7036e373a416c..5470ae7936ee8 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartDelay.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartDelay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +34,7 @@ /** * @test * @summary Start a recording with delay. Verify recording starts later. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=TestStartDelay,delay=5000s jdk.jfr.startupargs.TestStartDelay diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java b/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java index b74714b9bdd6c..b7563c35c3670 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Verify that a recopding with a delay is started. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=TestStartDelay,delay=1s jdk.jfr.startupargs.TestStartDelayRunning diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java index d9697492d94fb..fcc2f4abdd571 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 +36,7 @@ /** * @test * @summary Start a recording with duration. Verify recording stops. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires vm.flagless * @library /test/lib /test/jdk diff --git a/test/jdk/jdk/jfr/startupargs/TestStartHelp.java b/test/jdk/jdk/jfr/startupargs/TestStartHelp.java index 4d4edbf68dc36..0b3b5869cad5b 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartHelp.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartHelp.java @@ -30,7 +30,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main jdk.jfr.startupargs.TestStartHelp diff --git a/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java b/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java index 95a6b436ddb26..df9af580b401b 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Start a recording with delay. Verify recording starts later. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=TestStartMaxAgeSize,maxage=10s,maxsize=1000000 jdk.jfr.startupargs.TestStartMaxAgeSize diff --git a/test/jdk/jdk/jfr/startupargs/TestStartName.java b/test/jdk/jdk/jfr/startupargs/TestStartName.java index 7ab4a7d0f7e98..7dd11125f8f49 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartName.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main jdk.jfr.startupargs.TestStartName diff --git a/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java b/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java index ac5f5efa5c195..61188f224e0c0 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Start a FlightRecording without any settings (not even default). - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib * @run main/othervm jdk.jfr.startupargs.TestStartNoSettings diff --git a/test/jdk/jdk/jfr/startupargs/TestStartRecording.java b/test/jdk/jdk/jfr/startupargs/TestStartRecording.java index 7eb24cc8fa69e..6b3239951c7f3 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartRecording.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Start a recording with -XX:StartFlightRecording. Dump recording with jcmd. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm -XX:StartFlightRecording:name=TestStartRecording,settings=profile jdk.jfr.startupargs.TestStartRecording diff --git a/test/jdk/jdk/jfr/startupargs/TestStartupMessage.java b/test/jdk/jdk/jfr/startupargs/TestStartupMessage.java index b919f80e9da0c..4a934ebb36da3 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartupMessage.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartupMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main jdk.jfr.startupargs.TestStartupMessage diff --git a/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java b/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java index 756402b0c607f..11749504eba0c 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java @@ -26,7 +26,7 @@ /** * @test The test verifies that options can only be specified once with --XX:StartFlightRecording - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main jdk.jfr.startupargs.TestStartupOptionSpecifiedOnce diff --git a/test/jdk/jdk/jfr/threading/TestDeepVirtualStackTrace.java b/test/jdk/jdk/jfr/threading/TestDeepVirtualStackTrace.java index 3fecd91ea62c2..2be7262600639 100644 --- a/test/jdk/jdk/jfr/threading/TestDeepVirtualStackTrace.java +++ b/test/jdk/jdk/jfr/threading/TestDeepVirtualStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @summary Tests emitting an event, both in Java and native, in a virtual * thread with the maximum number of allowed stack frames for JFR - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/threading/TestManyVirtualThreads.java b/test/jdk/jdk/jfr/threading/TestManyVirtualThreads.java index f0c3b52cf144c..228abb6439e2a 100644 --- a/test/jdk/jdk/jfr/threading/TestManyVirtualThreads.java +++ b/test/jdk/jdk/jfr/threading/TestManyVirtualThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ /** * @test * @summary Tests starting virtual threads from a set of ordinary threads - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/threading/TestNestedVirtualThreads.java b/test/jdk/jdk/jfr/threading/TestNestedVirtualThreads.java index 26be901804a50..15901be949049 100644 --- a/test/jdk/jdk/jfr/threading/TestNestedVirtualThreads.java +++ b/test/jdk/jdk/jfr/threading/TestNestedVirtualThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * @test * @summary Tests committing an event in a virtual thread created by a virtual * thread - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java b/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java index 0dc1ef8566139..ef2a3698edcac 100644 --- a/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java +++ b/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java @@ -41,7 +41,7 @@ * @test * @bug 8338417 * @summary Tests pinning of virtual threads when the JFR string pool monitor is contended. - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR & vm.continuations * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.threading.TestStringPoolVirtualThreadPinning diff --git a/test/jdk/jdk/jfr/tool/TestAssemble.java b/test/jdk/jdk/jfr/tool/TestAssemble.java index 2ac90b535a526..43c862d8999ae 100644 --- a/test/jdk/jdk/jfr/tool/TestAssemble.java +++ b/test/jdk/jdk/jfr/tool/TestAssemble.java @@ -41,7 +41,7 @@ /** * @test * @summary Test jfr reconstruct - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal diff --git a/test/jdk/jdk/jfr/tool/TestConfigure.java b/test/jdk/jdk/jfr/tool/TestConfigure.java index 90f6f39be00be..e200054319eaa 100644 --- a/test/jdk/jdk/jfr/tool/TestConfigure.java +++ b/test/jdk/jdk/jfr/tool/TestConfigure.java @@ -34,7 +34,7 @@ /** * @test * @summary Test jfr configure - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestConfigure diff --git a/test/jdk/jdk/jfr/tool/TestDisassemble.java b/test/jdk/jdk/jfr/tool/TestDisassemble.java index da7f9489665bf..68088fdc5bb90 100644 --- a/test/jdk/jdk/jfr/tool/TestDisassemble.java +++ b/test/jdk/jdk/jfr/tool/TestDisassemble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ * @test * @bug 8253050 * @summary Test jfr split - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestDisassemble diff --git a/test/jdk/jdk/jfr/tool/TestHelp.java b/test/jdk/jdk/jfr/tool/TestHelp.java index 91bd7d82a2bed..b0113fca5bf91 100644 --- a/test/jdk/jdk/jfr/tool/TestHelp.java +++ b/test/jdk/jdk/jfr/tool/TestHelp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /** * @test * @summary Test help - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestHelp diff --git a/test/jdk/jdk/jfr/tool/TestMetadata.java b/test/jdk/jdk/jfr/tool/TestMetadata.java index c321f4e3fe66a..76afc110f5d62 100644 --- a/test/jdk/jdk/jfr/tool/TestMetadata.java +++ b/test/jdk/jdk/jfr/tool/TestMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test * @summary Test jfr info - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestMetadata diff --git a/test/jdk/jdk/jfr/tool/TestPrint.java b/test/jdk/jdk/jfr/tool/TestPrint.java index 6f7e89f83552b..fcedca3bcb9de 100644 --- a/test/jdk/jdk/jfr/tool/TestPrint.java +++ b/test/jdk/jdk/jfr/tool/TestPrint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ /** * @test * @summary Test jfr print - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestPrint diff --git a/test/jdk/jdk/jfr/tool/TestPrintDefault.java b/test/jdk/jdk/jfr/tool/TestPrintDefault.java index 215845e6c990c..8dd04c61e047d 100644 --- a/test/jdk/jdk/jfr/tool/TestPrintDefault.java +++ b/test/jdk/jdk/jfr/tool/TestPrintDefault.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests print --json * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/tool/TestPrintJSON.java b/test/jdk/jdk/jfr/tool/TestPrintJSON.java index 6a8977a672e66..3d79c75300f35 100644 --- a/test/jdk/jdk/jfr/tool/TestPrintJSON.java +++ b/test/jdk/jdk/jfr/tool/TestPrintJSON.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests print --json * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/tool/TestPrintXML.java b/test/jdk/jdk/jfr/tool/TestPrintXML.java index c8d60166d4c89..2c1c4a518e2b6 100644 --- a/test/jdk/jdk/jfr/tool/TestPrintXML.java +++ b/test/jdk/jdk/jfr/tool/TestPrintXML.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ /** * @test - * @key jfr + * @requires vm.flagless * @summary Tests print --xml * @requires vm.hasJFR * diff --git a/test/jdk/jdk/jfr/tool/TestScrub.java b/test/jdk/jdk/jfr/tool/TestScrub.java index ba02f7d31268c..43b9fca7ee4c0 100644 --- a/test/jdk/jdk/jfr/tool/TestScrub.java +++ b/test/jdk/jdk/jfr/tool/TestScrub.java @@ -40,7 +40,7 @@ /** * @test * @summary Test jfr scrub - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestScrub diff --git a/test/jdk/jdk/jfr/tool/TestSummary.java b/test/jdk/jdk/jfr/tool/TestSummary.java index 641d951f63ca2..550de0c081144 100644 --- a/test/jdk/jdk/jfr/tool/TestSummary.java +++ b/test/jdk/jdk/jfr/tool/TestSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ /** * @test * @summary Test jfr info - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib /test/jdk * @run main/othervm jdk.jfr.tool.TestSummary diff --git a/test/jdk/jdk/jfr/tool/TestView.java b/test/jdk/jdk/jfr/tool/TestView.java index 89c74133286f9..89c45c3e06862 100644 --- a/test/jdk/jdk/jfr/tool/TestView.java +++ b/test/jdk/jdk/jfr/tool/TestView.java @@ -31,7 +31,7 @@ /** * @test * @summary Test jfr view - * @key jfr + * @requires vm.flagless * @requires vm.hasJFR * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != false From 002679ac9fe4de8150b7dd4c9aeb44eeef1257d6 Mon Sep 17 00:00:00 2001 From: Koushik Thirupattur Date: Sat, 25 Jan 2025 19:06:47 +0000 Subject: [PATCH 236/263] 8347065: Add missing @spec tags for Java Security Standard Algorithm Names Reviewed-by: weijun --- .../java/security/AlgorithmParameterGenerator.java | 6 +++++- .../classes/java/security/AlgorithmParameters.java | 6 +++++- .../share/classes/java/security/DrbgParameters.java | 1 + .../share/classes/java/security/KeyFactory.java | 6 +++++- .../classes/java/security/KeyPairGenerator.java | 8 +++++++- .../share/classes/java/security/KeyStore.java | 7 ++++++- .../share/classes/java/security/MessageDigest.java | 8 +++++++- .../share/classes/java/security/SecureRandom.java | 12 ++++++++++-- .../share/classes/java/security/SecureRandomSpi.java | 3 ++- .../share/classes/java/security/Signature.java | 7 ++++++- .../share/classes/java/security/cert/CertPath.java | 1 + .../classes/java/security/cert/CertPathBuilder.java | 6 +++++- .../java/security/cert/CertPathValidator.java | 6 +++++- .../share/classes/java/security/cert/CertStore.java | 6 +++++- .../classes/java/security/cert/Certificate.java | 1 + .../java/security/cert/CertificateFactory.java | 8 +++++++- .../java/security/cert/CertificateFactorySpi.java | 3 ++- .../java/security/spec/ECGenParameterSpec.java | 3 ++- .../classes/java/security/spec/EncodedKeySpec.java | 3 ++- .../java/security/spec/NamedParameterSpec.java | 4 +++- .../java/security/spec/PKCS8EncodedKeySpec.java | 3 ++- .../classes/java/security/spec/PSSParameterSpec.java | 3 ++- .../java/security/spec/X509EncodedKeySpec.java | 3 ++- src/java.base/share/classes/javax/crypto/Cipher.java | 6 +++++- .../classes/javax/crypto/ExemptionMechanism.java | 5 ++++- src/java.base/share/classes/javax/crypto/KDF.java | 8 +++++++- src/java.base/share/classes/javax/crypto/KEM.java | 5 ++++- .../share/classes/javax/crypto/KeyAgreement.java | 6 +++++- .../share/classes/javax/crypto/KeyGenerator.java | 6 +++++- src/java.base/share/classes/javax/crypto/Mac.java | 6 +++++- .../share/classes/javax/crypto/SecretKeyFactory.java | 6 +++++- .../classes/javax/net/ssl/KeyManagerFactory.java | 5 ++++- .../share/classes/javax/net/ssl/SSLContext.java | 6 +++++- .../share/classes/javax/net/ssl/SSLEngine.java | 5 ++++- .../share/classes/javax/net/ssl/SSLParameters.java | 10 +++++++++- .../share/classes/javax/net/ssl/SSLServerSocket.java | 5 ++++- .../javax/net/ssl/SSLServerSocketFactory.java | 4 +++- .../share/classes/javax/net/ssl/SSLSocket.java | 5 ++++- .../classes/javax/net/ssl/SSLSocketFactory.java | 4 +++- .../classes/javax/net/ssl/TrustManagerFactory.java | 6 +++++- .../javax/security/auth/login/Configuration.java | 6 +++++- .../jmx/remote/security/HashedPasswordManager.java | 3 ++- .../javax/xml/crypto/dsig/TransformService.java | 6 +++++- .../javax/xml/crypto/dsig/XMLSignatureFactory.java | 6 +++++- .../xml/crypto/dsig/keyinfo/KeyInfoFactory.java | 6 +++++- .../classes/jdk/security/jarsigner/JarSigner.java | 6 +++++- 46 files changed, 201 insertions(+), 44 deletions(-) diff --git a/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java b/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java index cec473cef9686..0410179550b2d 100644 --- a/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java +++ b/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,6 +88,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @@ -161,6 +162,7 @@ public final String getAlgorithm() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code AlgorithmParameterGenerator} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports an @@ -208,6 +210,7 @@ public static AlgorithmParameterGenerator getInstance(String algorithm) * * @param provider the string name of the {@code Provider}. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code AlgorithmParameterGenerator} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -258,6 +261,7 @@ public static AlgorithmParameterGenerator getInstance(String algorithm, * * @param provider the {@code Provider} object. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code AlgorithmParameterGenerator} object * * @throws IllegalArgumentException if the specified provider is diff --git a/src/java.base/share/classes/java/security/AlgorithmParameters.java b/src/java.base/share/classes/java/security/AlgorithmParameters.java index 7747d642c20c1..defe25571f7ab 100644 --- a/src/java.base/share/classes/java/security/AlgorithmParameters.java +++ b/src/java.base/share/classes/java/security/AlgorithmParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @@ -147,6 +148,7 @@ public final String getAlgorithm() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new parameter object * * @throws NoSuchAlgorithmException if no {@code Provider} supports an @@ -194,6 +196,7 @@ public static AlgorithmParameters getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new parameter object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -244,6 +247,7 @@ public static AlgorithmParameters getInstance(String algorithm, * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new parameter object * * @throws IllegalArgumentException if the provider is {@code null} diff --git a/src/java.base/share/classes/java/security/DrbgParameters.java b/src/java.base/share/classes/java/security/DrbgParameters.java index 4bcb179fecaff..5cd8b171c72ff 100644 --- a/src/java.base/share/classes/java/security/DrbgParameters.java +++ b/src/java.base/share/classes/java/security/DrbgParameters.java @@ -229,6 +229,7 @@ * * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf * Recommendation for Random Number Generation Using Deterministic Random Bit Generators + * @spec security/standard-names.html Java Security Standard Algorithm Names * * @since 9 */ diff --git a/src/java.base/share/classes/java/security/KeyFactory.java b/src/java.base/share/classes/java/security/KeyFactory.java index 7c51faf6aa2db..8eaf72f1b83b5 100644 --- a/src/java.base/share/classes/java/security/KeyFactory.java +++ b/src/java.base/share/classes/java/security/KeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @see Key @@ -169,6 +170,7 @@ private KeyFactory(String algorithm) throws NoSuchAlgorithmException { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyFactory} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -205,6 +207,7 @@ public static KeyFactory getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyFactory} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -247,6 +250,7 @@ public static KeyFactory getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyFactory} object * * @throws IllegalArgumentException if the specified provider is diff --git a/src/java.base/share/classes/java/security/KeyPairGenerator.java b/src/java.base/share/classes/java/security/KeyPairGenerator.java index 3583248f81e6c..6d7148a76f5cc 100644 --- a/src/java.base/share/classes/java/security/KeyPairGenerator.java +++ b/src/java.base/share/classes/java/security/KeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,6 +131,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Benjamin Renaud * @since 1.1 * @@ -157,6 +158,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected KeyPairGenerator(String algorithm) { this.algorithm = algorithm; @@ -169,6 +171,7 @@ protected KeyPairGenerator(String algorithm) { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the standard string name of the algorithm. */ public String getAlgorithm() { @@ -221,6 +224,7 @@ private static KeyPairGenerator getInstance(Instance instance, * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyPairGenerator} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -280,6 +284,7 @@ public static KeyPairGenerator getInstance(String algorithm) * * @param provider the string name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyPairGenerator} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -320,6 +325,7 @@ public static KeyPairGenerator getInstance(String algorithm, * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @param provider the provider. * * @return the new {@code KeyPairGenerator} object diff --git a/src/java.base/share/classes/java/security/KeyStore.java b/src/java.base/share/classes/java/security/KeyStore.java index b420cc69aa6e2..9e50a1588e77d 100644 --- a/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/java.base/share/classes/java/security/KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -183,6 +183,7 @@ * Consult the release documentation for your implementation to see if any * other types are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @see java.security.PrivateKey @@ -300,6 +301,7 @@ public PasswordProtection(char[] password) { * @throws NullPointerException if {@code protectionAlgorithm} is * {@code null} * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.8 */ public PasswordProtection(char[] password, String protectionAlgorithm, @@ -852,6 +854,7 @@ private String getProviderName() { * Java Security Standard Algorithm Names Specification * for information about standard keystore types. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a keystore object of the specified type * * @throws KeyStoreException if no provider supports a @@ -893,6 +896,7 @@ public static KeyStore getInstance(String type) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a keystore object of the specified type * * @throws IllegalArgumentException if the provider name is {@code null} @@ -939,6 +943,7 @@ public static KeyStore getInstance(String type, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a keystore object of the specified type * * @throws IllegalArgumentException if the specified provider is diff --git a/src/java.base/share/classes/java/security/MessageDigest.java b/src/java.base/share/classes/java/security/MessageDigest.java index f83c4ed6d3b8b..fa8d3dea8fd91 100644 --- a/src/java.base/share/classes/java/security/MessageDigest.java +++ b/src/java.base/share/classes/java/security/MessageDigest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,6 +96,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Benjamin Renaud * @since 1.1 * @@ -128,6 +129,7 @@ public abstract class MessageDigest extends MessageDigestSpi { * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected MessageDigest(String algorithm) { this.algorithm = algorithm; @@ -166,6 +168,7 @@ private MessageDigest(String algorithm, Provider p) { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code MessageDigest} object that implements the * specified algorithm * @@ -221,6 +224,7 @@ public static MessageDigest getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code MessageDigest} object that implements the * specified algorithm * @@ -275,6 +279,7 @@ public static MessageDigest getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code MessageDigest} object that implements the * specified algorithm * @@ -513,6 +518,7 @@ public void reset() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the name of the algorithm */ public final String getAlgorithm() { diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index e6cc1134c09b6..e53341be9dad4 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * RFC 4086: Randomness Requirements for Security * @spec https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf * Security Requirements for Cryptographic Modules - * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see java.security.SecureRandomSpi * @see java.util.Random * @@ -214,6 +214,7 @@ public class SecureRandom extends java.util.Random { * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public SecureRandom() { /* @@ -257,6 +258,7 @@ private boolean getThreadSafe() { * for information about standard RNG algorithm names. * * @param seed the seed. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code seed} is {@code null} */ public SecureRandom(byte[] seed) { @@ -371,6 +373,7 @@ private String getProviderName() { * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -412,6 +415,7 @@ public static SecureRandom getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -456,6 +460,7 @@ public static SecureRandom getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws IllegalArgumentException if the specified provider is @@ -511,6 +516,7 @@ public static SecureRandom getInstance(String algorithm, * @param params the {@code SecureRandomParameters} * the newly created {@code SecureRandom} object must support. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws IllegalArgumentException if the specified params is @@ -563,6 +569,7 @@ public static SecureRandom getInstance( * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -615,6 +622,7 @@ public static SecureRandom getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecureRandom} object * * @throws IllegalArgumentException if the specified provider or params diff --git a/src/java.base/share/classes/java/security/SecureRandomSpi.java b/src/java.base/share/classes/java/security/SecureRandomSpi.java index 3185f61720a61..4c7c58cae1163 100644 --- a/src/java.base/share/classes/java/security/SecureRandomSpi.java +++ b/src/java.base/share/classes/java/security/SecureRandomSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,6 +79,7 @@ * {@code SecureRandom} will call the applicable engine methods * without any synchronization. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.2 */ diff --git a/src/java.base/share/classes/java/security/Signature.java b/src/java.base/share/classes/java/security/Signature.java index 006188aac616a..52aa4328b2cfb 100644 --- a/src/java.base/share/classes/java/security/Signature.java +++ b/src/java.base/share/classes/java/security/Signature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,6 +122,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Benjamin Renaud * @since 1.1 * @@ -206,6 +207,7 @@ public void initSign(Signature s, PrivateKey privateKey, * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected Signature(String algorithm) { this.algorithm = algorithm; @@ -252,6 +254,7 @@ protected Signature(String algorithm) { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Signature} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -375,6 +378,7 @@ private static boolean isSpi(Service s) { * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Signature} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -428,6 +432,7 @@ public static Signature getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Signature} object * * @throws IllegalArgumentException if the provider is {@code null} diff --git a/src/java.base/share/classes/java/security/cert/CertPath.java b/src/java.base/share/classes/java/security/cert/CertPath.java index ffbbf0291b141..54c47c36119aa 100644 --- a/src/java.base/share/classes/java/security/cert/CertPath.java +++ b/src/java.base/share/classes/java/security/cert/CertPath.java @@ -111,6 +111,7 @@ * generally not difficult, since the {@code CertPath} and * {@code List} objects in question are immutable. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see CertificateFactory * @see CertPathBuilder * diff --git a/src/java.base/share/classes/java/security/cert/CertPathBuilder.java b/src/java.base/share/classes/java/security/cert/CertPathBuilder.java index de1a86312c486..692bfa0fb8e79 100644 --- a/src/java.base/share/classes/java/security/cert/CertPathBuilder.java +++ b/src/java.base/share/classes/java/security/cert/CertPathBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +90,7 @@ * threads each manipulating a different {@code CertPathBuilder} instance * need not synchronize. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see CertPath * * @since 1.4 @@ -154,6 +155,7 @@ protected CertPathBuilder(CertPathBuilderSpi builderSpi, Provider provider, * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathBuilder} object that implements the * specified algorithm * @@ -194,6 +196,7 @@ public static CertPathBuilder getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathBuilder} object that implements the * specified algorithm * @@ -237,6 +240,7 @@ public static CertPathBuilder getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathBuilder} object that implements the * specified algorithm * diff --git a/src/java.base/share/classes/java/security/cert/CertPathValidator.java b/src/java.base/share/classes/java/security/cert/CertPathValidator.java index c79283b536f65..539bee3419247 100644 --- a/src/java.base/share/classes/java/security/cert/CertPathValidator.java +++ b/src/java.base/share/classes/java/security/cert/CertPathValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,6 +92,7 @@ * threads each manipulating a different {@code CertPathValidator} * instance need not synchronize. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see CertPath * * @since 1.4 @@ -155,6 +156,7 @@ protected CertPathValidator(CertPathValidatorSpi validatorSpi, * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathValidator} object that implements the * specified algorithm * @@ -195,6 +197,7 @@ public static CertPathValidator getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathValidator} object that implements the * specified algorithm * @@ -239,6 +242,7 @@ public static CertPathValidator getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPathValidator} object that implements the * specified algorithm * diff --git a/src/java.base/share/classes/java/security/cert/CertStore.java b/src/java.base/share/classes/java/security/cert/CertStore.java index 3801a1fbcaf73..ce213a7c2e8f3 100644 --- a/src/java.base/share/classes/java/security/cert/CertStore.java +++ b/src/java.base/share/classes/java/security/cert/CertStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ * Multiple threads may concurrently invoke the static methods defined in * this class with no ill effects. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 * @author Sean Mullan, Steve Hanna */ @@ -216,6 +217,7 @@ public final Collection getCRLs(CRLSelector selector) * * @param params the initialization parameters (may be {@code null}). * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertStore} object that implements the specified * {@code CertStore} type * @@ -282,6 +284,7 @@ private static CertStore handleException(NoSuchAlgorithmException e) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertStore} object that implements the * specified type * @@ -343,6 +346,7 @@ public static CertStore getInstance(String type, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertStore} object that implements the * specified type * diff --git a/src/java.base/share/classes/java/security/cert/Certificate.java b/src/java.base/share/classes/java/security/cert/Certificate.java index 618026c894d35..50e70da0689f5 100644 --- a/src/java.base/share/classes/java/security/cert/Certificate.java +++ b/src/java.base/share/classes/java/security/cert/Certificate.java @@ -79,6 +79,7 @@ public abstract class Certificate implements java.io.Serializable { * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> * Java Security Standard Algorithm Names Specification * for information about standard certificate types. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected Certificate(String type) { this.type = type; diff --git a/src/java.base/share/classes/java/security/cert/CertificateFactory.java b/src/java.base/share/classes/java/security/cert/CertificateFactory.java index fb47ca29af165..3ee375c163c08 100644 --- a/src/java.base/share/classes/java/security/cert/CertificateFactory.java +++ b/src/java.base/share/classes/java/security/cert/CertificateFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,6 +109,7 @@ * Consult the release documentation for your implementation to see if any * other types or encodings are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Hemma Prafullchandra * @author Jan Luehe * @author Sean Mullan @@ -176,6 +177,7 @@ protected CertificateFactory(CertificateFactorySpi certFacSpi, * Java Security Standard Algorithm Names Specification * for information about standard certificate types. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a certificate factory object for the specified type * * @throws CertificateException if no {@code Provider} supports a @@ -219,6 +221,7 @@ public static final CertificateFactory getInstance(String type) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a certificate factory object for the specified type * * @throws CertificateException if a {@code CertificateFactorySpi} @@ -265,6 +268,7 @@ public static final CertificateFactory getInstance(String type, * for information about standard certificate types. * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a certificate factory object for the specified type * * @throws CertificateException if a {@code CertificateFactorySpi} @@ -369,6 +373,7 @@ public final Certificate generateCertificate(InputStream inStream) * {@code remove} method result in an * {@code UnsupportedOperationException}. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an {@code Iterator} over the names of the supported * {@code CertPath} encodings (as {@code String}s) * @since 1.4 @@ -407,6 +412,7 @@ public final CertPath generateCertPath(InputStream inStream) * * @param inStream an {@code InputStream} containing the data * @param encoding the encoding used for the data + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code CertPath} initialized with the data from the * {@code InputStream} * @throws CertificateException if an exception occurs while decoding or diff --git a/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java b/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java index 7a782dcc65913..1bf346198e673 100644 --- a/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java +++ b/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,6 +198,7 @@ public CertPath engineGenerateCertPath(InputStream inStream, * existing service providers, this method cannot be {@code abstract} * and by default throws an {@code UnsupportedOperationException}. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an {@code Iterator} over the names of the supported * {@code CertPath} encodings (as {@code String}s) * @throws UnsupportedOperationException if the method is not supported diff --git a/src/java.base/share/classes/java/security/spec/ECGenParameterSpec.java b/src/java.base/share/classes/java/security/spec/ECGenParameterSpec.java index 4d506726c9f66..553793fa4691d 100644 --- a/src/java.base/share/classes/java/security/spec/ECGenParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/ECGenParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ public class ECGenParameterSpec extends NamedParameterSpec { * "{@docRoot}/../specs/security/standard-names.html#ecgenparameterspec"> * Java Security Standard Algorithm Names Specification for * information about standard names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code stdName} is null. */ public ECGenParameterSpec(String stdName) { diff --git a/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java index 8bb23d08df35b..7ddc9bf8e03ae 100644 --- a/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,6 +79,7 @@ public EncodedKeySpec(byte[] encodedKey) { * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is diff --git a/src/java.base/share/classes/java/security/spec/NamedParameterSpec.java b/src/java.base/share/classes/java/security/spec/NamedParameterSpec.java index d50426b6ccf6d..c4091705df02e 100644 --- a/src/java.base/share/classes/java/security/spec/NamedParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/NamedParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ * "{@docRoot}/../specs/security/standard-names.html#namedparameterspec"> * Java Security Standard Algorithm Names Specification. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 11 * */ @@ -131,6 +132,7 @@ public class NamedParameterSpec implements AlgorithmParameterSpec { * Java Security Standard Algorithm Names Specification for * information about standard names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code stdName} is null. */ public NamedParameterSpec(String stdName) { diff --git a/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java index 73d79a413216b..799de3599560c 100644 --- a/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,6 +88,7 @@ public PKCS8EncodedKeySpec(byte[] encodedKey) { * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is diff --git a/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java b/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java index a05ce1b4b7a7c..504154b23601e 100644 --- a/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -140,6 +140,7 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * getMGFParameters(). * @param saltLen the length of salt in bytes * @param trailerField the value of the trailer field + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code mdName}, or {@code mgfName} * is null * @throws IllegalArgumentException if {@code saltLen} or diff --git a/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java index 7de4a2a14179a..e9801f6f7f30d 100644 --- a/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,7 @@ public X509EncodedKeySpec(byte[] encodedKey) { * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is diff --git a/src/java.base/share/classes/javax/crypto/Cipher.java b/src/java.base/share/classes/javax/crypto/Cipher.java index 8187f863b5c2a..3de732c66871f 100644 --- a/src/java.base/share/classes/javax/crypto/Cipher.java +++ b/src/java.base/share/classes/javax/crypto/Cipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +169,7 @@ * RFC 5116: An Interface and Algorithms for Authenticated Encryption * @spec https://www.rfc-editor.org/info/rfc7539 * RFC 7539: ChaCha20 and Poly1305 for IETF Protocols + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * @see KeyGenerator * @see SecretKey @@ -520,6 +521,7 @@ private static Transform getTransform(Service s, * Java Security Standard Algorithm Names Specification * for information about standard transformation names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code Cipher} object that implements the requested * transformation * @@ -611,6 +613,7 @@ public static final Cipher getInstance(String transformation) * * @param provider the name of the provider * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code Cipher} object that implements the requested * transformation * @@ -683,6 +686,7 @@ private String getProviderName() { * * @param provider the provider * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code Cipher} object that implements the requested * transformation * diff --git a/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java b/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java index d360b3577a01c..63686b8433f38 100644 --- a/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java +++ b/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -129,6 +129,7 @@ public final String getName() { * Java Security Standard Algorithm Names Specification * for information about standard exemption mechanism names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code ExemptionMechanism} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports an @@ -170,6 +171,7 @@ public static final ExemptionMechanism getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code ExemptionMechanism} object * * @throws IllegalArgumentException if the {@code provider} @@ -214,6 +216,7 @@ public static final ExemptionMechanism getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code ExemptionMechanism} object * * @throws IllegalArgumentException if the {@code provider} diff --git a/src/java.base/share/classes/javax/crypto/KDF.java b/src/java.base/share/classes/javax/crypto/KDF.java index 0ee0904c1c2c4..9859bd4778725 100644 --- a/src/java.base/share/classes/javax/crypto/KDF.java +++ b/src/java.base/share/classes/javax/crypto/KDF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,6 +222,7 @@ public KDFParameters getParameters() { * Java Security Standard Algorithm Names Specification for * information about standard KDF algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException @@ -256,6 +257,7 @@ public static KDF getInstance(String algorithm) * @param provider * the provider to use for this key derivation * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException @@ -291,6 +293,7 @@ public static KDF getInstance(String algorithm, String provider) * @param provider * the provider to use for this key derivation * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException @@ -332,6 +335,7 @@ public static KDF getInstance(String algorithm, Provider provider) * the {@code KDFParameters} used to configure the derivation * algorithm or {@code null} if no parameters are provided * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException @@ -375,6 +379,7 @@ public static KDF getInstance(String algorithm, * @param provider * the provider to use for this key derivation * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException @@ -428,6 +433,7 @@ public static KDF getInstance(String algorithm, * @param provider * the provider to use for this key derivation * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a {@code KDF} object * * @throws NoSuchAlgorithmException diff --git a/src/java.base/share/classes/javax/crypto/KEM.java b/src/java.base/share/classes/javax/crypto/KEM.java index 3cb053c194c48..287efc75371b7 100644 --- a/src/java.base/share/classes/javax/crypto/KEM.java +++ b/src/java.base/share/classes/javax/crypto/KEM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -531,6 +531,7 @@ private KEM(String algorithm, DelayedKEM delayed) { * "{@docRoot}/../specs/security/standard-names.html#kem-algorithms"> * Java Security Standard Algorithm Names Specification * for information about standard KEM algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KEM} object * @throws NoSuchAlgorithmException if no {@code Provider} supports a * {@code KEM} implementation for the specified algorithm @@ -568,6 +569,7 @@ public static KEM getInstance(String algorithm) * for information about standard KEM algorithm names. * @param provider the provider. If {@code null}, this method is equivalent * to {@link #getInstance(String)}. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KEM} object * @throws NoSuchAlgorithmException if a {@code provider} is specified and * it does not support the specified KEM algorithm, @@ -599,6 +601,7 @@ public static KEM getInstance(String algorithm, Provider provider) * for information about standard KEM algorithm names. * @param provider the provider. If {@code null}, this method is equivalent * to {@link #getInstance(String)}. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KEM} object * @throws NoSuchAlgorithmException if a {@code provider} is specified and * it does not support the specified KEM algorithm, diff --git a/src/java.base/share/classes/javax/crypto/KeyAgreement.java b/src/java.base/share/classes/javax/crypto/KeyAgreement.java index 5e2ceb185aa5b..e3a68e88d03d4 100644 --- a/src/java.base/share/classes/javax/crypto/KeyAgreement.java +++ b/src/java.base/share/classes/javax/crypto/KeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +71,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @see KeyGenerator @@ -170,6 +171,7 @@ public final String getAlgorithm() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyAgreement} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -217,6 +219,7 @@ public static final KeyAgreement getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyAgreement} object * * @throws IllegalArgumentException if the {@code provider} @@ -261,6 +264,7 @@ public static final KeyAgreement getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyAgreement} object * * @throws IllegalArgumentException if the {@code provider} diff --git a/src/java.base/share/classes/javax/crypto/KeyGenerator.java b/src/java.base/share/classes/javax/crypto/KeyGenerator.java index ad112e6ffebe7..02d0bd757531a 100644 --- a/src/java.base/share/classes/javax/crypto/KeyGenerator.java +++ b/src/java.base/share/classes/javax/crypto/KeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,6 +109,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @see SecretKey @@ -226,6 +227,7 @@ public final String getAlgorithm() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyGenerator} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -262,6 +264,7 @@ public static final KeyGenerator getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyGenerator} object * * @throws IllegalArgumentException if the {@code provider} @@ -305,6 +308,7 @@ public static final KeyGenerator getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyGenerator} object * * @throws IllegalArgumentException if the {@code provider} diff --git a/src/java.base/share/classes/javax/crypto/Mac.java b/src/java.base/share/classes/javax/crypto/Mac.java index d4de87304b3aa..fb1eb2c310a92 100644 --- a/src/java.base/share/classes/javax/crypto/Mac.java +++ b/src/java.base/share/classes/javax/crypto/Mac.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,6 +66,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @since 1.4 @@ -165,6 +166,7 @@ public final String getAlgorithm() { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Mac} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -210,6 +212,7 @@ public static final Mac getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Mac} object * * @throws IllegalArgumentException if the {@code provider} @@ -251,6 +254,7 @@ public static final Mac getInstance(String algorithm, String provider) * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Mac} object * * @throws IllegalArgumentException if the {@code provider} is diff --git a/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java b/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java index 1156c40b77c7d..49b8605ad4d30 100644 --- a/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java +++ b/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,6 +68,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Jan Luehe * * @see SecretKey @@ -146,6 +147,7 @@ private SecretKeyFactory(String algorithm) throws NoSuchAlgorithmException { * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecretKeyFactory} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -183,6 +185,7 @@ public static final SecretKeyFactory getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecretKeyFactory} object * * @throws IllegalArgumentException if the {@code provider} @@ -227,6 +230,7 @@ public static final SecretKeyFactory getInstance(String algorithm, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SecretKeyFactory} object * * @throws IllegalArgumentException if the {@code provider} diff --git a/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java b/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java index 4ff8d35f7178c..652a20c837705 100644 --- a/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java +++ b/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,6 +124,7 @@ public final String getAlgorithm() { * Algorithm Names Specification for information about standard * algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyManagerFactory} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -165,6 +166,7 @@ public static final KeyManagerFactory getInstance(String algorithm) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyManagerFactory} object * * @throws IllegalArgumentException if the provider name is {@code null} @@ -210,6 +212,7 @@ public static final KeyManagerFactory getInstance(String algorithm, * * @param provider an instance of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code KeyManagerFactory} object * * @throws IllegalArgumentException if provider is {@code null} diff --git a/src/java.base/share/classes/javax/net/ssl/SSLContext.java b/src/java.base/share/classes/javax/net/ssl/SSLContext.java index 861c7645b733e..b8759d0414de1 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLContext.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,7 @@ * Consult the release documentation for your implementation to see if any * other protocols are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 */ public class SSLContext { @@ -161,6 +162,7 @@ public static void setDefault(SSLContext context) { * Java Security Standard Algorithm Names Specification * for information about standard protocol names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SSLContext} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -200,6 +202,7 @@ public static SSLContext getInstance(String protocol) * * @param provider the name of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SSLContext} object * * @throws IllegalArgumentException if the provider name is @@ -242,6 +245,7 @@ public static SSLContext getInstance(String protocol, String provider) * * @param provider an instance of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code SSLContext} object * * @throws IllegalArgumentException if the provider is {@code null} diff --git a/src/java.base/share/classes/javax/net/ssl/SSLEngine.java b/src/java.base/share/classes/javax/net/ssl/SSLEngine.java index 6d066ea5ca9f8..228750e080c25 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLEngine.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -917,6 +917,7 @@ public abstract SSLEngineResult unwrap(ByteBuffer src, * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getEnabledCipherSuites() * @see #setEnabledCipherSuites(String[]) @@ -943,6 +944,7 @@ public abstract SSLEngineResult unwrap(ByteBuffer src, * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getSupportedCipherSuites() * @see #setEnabledCipherSuites(String[]) @@ -970,6 +972,7 @@ public abstract SSLEngineResult unwrap(ByteBuffer src, * on why a specific cipher suite may never be used on an engine. * * @param suites Names of all the cipher suites to enable + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws IllegalArgumentException when one or more of the ciphers * named by the parameter is not supported, or when the * parameter is null. diff --git a/src/java.base/share/classes/javax/net/ssl/SSLParameters.java b/src/java.base/share/classes/javax/net/ssl/SSLParameters.java index e1f4399406471..88fa692489943 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLParameters.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,6 +113,7 @@ public SSLParameters() { * Algorithm Names Specification. Providers may support cipher suite * names not found in this list. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @param cipherSuites the array of ciphersuites (or null) */ @SuppressWarnings("this-escape") @@ -134,6 +135,7 @@ public SSLParameters(String[] cipherSuites) { * Algorithm Names Specification. Providers may support cipher suite * names not found in this list. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @param cipherSuites the array of ciphersuites (or null) * @param protocols the array of protocols (or null) */ @@ -158,6 +160,7 @@ private static String[] clone(String[] s) { * Algorithm Names Specification, and may also include other cipher suites * that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a copy of the array of ciphersuites or null if none * have been set. */ @@ -175,6 +178,7 @@ public String[] getCipherSuites() { * Algorithm Names Specification. Providers may support cipher suite * names not found in this list or might not use the recommended name * for a certain cipher suite. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public void setCipherSuites(String[] cipherSuites) { this.cipherSuites = clone(cipherSuites); @@ -749,6 +753,7 @@ public void setApplicationProtocols(String[] protocols) { * with the SunJSSE provider to override the provider-specific default * signature schemes. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of signature scheme {@code Strings} or {@code null} if * none have been set. For non-null returns, this method will * return a new array each time it is invoked. The array is @@ -794,6 +799,7 @@ public String[] getSignatureSchemes() { * method will make a copy of this array. Providers should ignore * unknown signature scheme names while establishing the * SSL/TLS/DTLS connections. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws IllegalArgumentException if any element in the * {@code signatureSchemes} array is {@code null} or * {@linkplain String#isBlank() blank}. @@ -868,6 +874,7 @@ public void setSignatureSchemes(String[] signatureSchemes) { * {@systemProperty jdk.tls.namedGroups} system property with the SunJSSE * provider to override the provider-specific default named groups. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of key exchange named group names {@code Strings} or * {@code null} if none have been set. For non-null returns, this * method will return a new array each time it is invoked. The @@ -913,6 +920,7 @@ public String[] getNamedGroups() { * This method will make a copy of this array. Providers should * ignore unknown named group scheme names while establishing the * SSL/TLS/DTLS connections. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws IllegalArgumentException if any element in the * {@code namedGroups} array is a duplicate, {@code null} or * {@linkplain String#isBlank() blank}. diff --git a/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java b/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java index b4afed41a1b53..71cb304edbcdc 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -177,6 +177,7 @@ protected SSLServerSocket(int port, int backlog, InetAddress address) * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suites enabled * @see #getSupportedCipherSuites() * @see #setEnabledCipherSuites(String[]) @@ -211,6 +212,7 @@ protected SSLServerSocket(int port, int backlog, InetAddress address) * @exception IllegalArgumentException when one or more of ciphers * named by the parameter is not supported, or when * the parameter is null. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getSupportedCipherSuites() * @see #getEnabledCipherSuites() */ @@ -233,6 +235,7 @@ protected SSLServerSocket(int port, int backlog, InetAddress address) * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getEnabledCipherSuites() * @see #setEnabledCipherSuites(String[]) diff --git a/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java b/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java index 22f64f98f29fc..6a35a34e5f42d 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,6 +91,7 @@ public static ServerSocketFactory getDefault() { * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getSupportedCipherSuites() * @return array of the cipher suites enabled by default */ @@ -112,6 +113,7 @@ public static ServerSocketFactory getDefault() { * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getDefaultCipherSuites() */ diff --git a/src/java.base/share/classes/javax/net/ssl/SSLSocket.java b/src/java.base/share/classes/javax/net/ssl/SSLSocket.java index a77968ada16d3..a18c203320d22 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLSocket.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -305,6 +305,7 @@ protected SSLSocket(InetAddress address, int port, * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getEnabledCipherSuites() * @see #setEnabledCipherSuites(String []) @@ -331,6 +332,7 @@ protected SSLSocket(InetAddress address, int port, * Algorithm Names Specification, and may also include other cipher * suites that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return an array of cipher suite names * @see #getSupportedCipherSuites() * @see #setEnabledCipherSuites(String []) @@ -358,6 +360,7 @@ protected SSLSocket(InetAddress address, int port, * on why a specific ciphersuite may never be used on a connection. * * @param suites Names of all the cipher suites to enable + * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws IllegalArgumentException when one or more of the ciphers * named by the parameter is not supported, or when the * parameter is null. diff --git a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java index b90a9d4c25cef..6d0815ef80dad 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,6 +109,7 @@ static String getSecurityProperty(final String name) { * Algorithm Names Specification, and may also include other cipher suites * that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getSupportedCipherSuites() * @return array of the cipher suites enabled by default */ @@ -128,6 +129,7 @@ static String getSecurityProperty(final String name) { * Algorithm Names Specification, and may also include other cipher suites * that the provider supports. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getDefaultCipherSuites() * @return an array of cipher suite names */ diff --git a/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java b/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java index af08d97f0d2c3..76c7680640389 100644 --- a/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java +++ b/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ * Consult the release documentation for your implementation to see if any * other algorithms are supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 * @see TrustManager */ @@ -138,6 +139,7 @@ public final String getAlgorithm() { * Algorithm Names Specification for information about standard * algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code TrustManagerFactory} object * * @throws NoSuchAlgorithmException if no {@code Provider} supports a @@ -177,6 +179,7 @@ public static final TrustManagerFactory getInstance(String algorithm) * Algorithm Names Specification for information about standard * algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @param provider the name of the provider. * * @return the new {@code TrustManagerFactory} object @@ -224,6 +227,7 @@ public static final TrustManagerFactory getInstance(String algorithm, * * @param provider an instance of the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code TrustManagerFactory} object * * @throws IllegalArgumentException if the provider is {@code null} diff --git a/src/java.base/share/classes/javax/security/auth/login/Configuration.java b/src/java.base/share/classes/javax/security/auth/login/Configuration.java index bebf5f6901a6f..6e69d0746ff23 100644 --- a/src/java.base/share/classes/javax/security/auth/login/Configuration.java +++ b/src/java.base/share/classes/javax/security/auth/login/Configuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -176,6 +176,7 @@ * Java Security Standard Algorithm Names Specification * for a list of standard Configuration types. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 * @see javax.security.auth.login.LoginContext * @see java.security.Security security properties @@ -268,6 +269,7 @@ public static void setConfiguration(Configuration configuration) { * * @param params parameters for the Configuration, which may be null. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Configuration} object * * @throws IllegalArgumentException if the specified parameters @@ -324,6 +326,7 @@ public static Configuration getInstance(String type, * * @param provider the provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Configuration} object * * @throws IllegalArgumentException if the specified provider @@ -387,6 +390,7 @@ public static Configuration getInstance(String type, * * @param provider the Provider. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the new {@code Configuration} object * * @throws IllegalArgumentException if the specified {@code Provider} diff --git a/src/java.management/share/classes/com/sun/jmx/remote/security/HashedPasswordManager.java b/src/java.management/share/classes/com/sun/jmx/remote/security/HashedPasswordManager.java index c50b22fade6ed..a247ba665333d 100644 --- a/src/java.management/share/classes/com/sun/jmx/remote/security/HashedPasswordManager.java +++ b/src/java.management/share/classes/com/sun/jmx/remote/security/HashedPasswordManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ * A user generated hashed password file can also be used instead of a * clear-text password file. If generated by the user, hashed passwords must * follow the format specified above. + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public final class HashedPasswordManager { diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java index bf5486f4d32ad..9040552beb762 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * 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,6 +101,7 @@ * necessary locking. Multiple threads each manipulating a different * TransformService instance need not synchronize. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Sean Mullan * @author JSR 105 Expert Group * @since 1.6 @@ -153,6 +154,7 @@ protected TransformService() {} * "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms"> * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new TransformService * @throws NullPointerException if algorithm or * mechanismType is null @@ -215,6 +217,7 @@ protected TransformService() {} * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. * @param provider the Provider object + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new TransformService * @throws NullPointerException if provider, * algorithm, or mechanismType is @@ -277,6 +280,7 @@ protected TransformService() {} * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. * @param provider the string name of the provider + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new TransformService * @throws NoSuchProviderException if the specified provider is not * registered in the security provider list diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java index 07fb9a271f287..4af0591691aca 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,6 +143,7 @@ * necessary locking. Multiple threads each manipulating a different * XMLSignatureFactory instance need not synchronize. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Sean Mullan * @author JSR 105 Expert Group * @since 1.6 @@ -186,6 +187,7 @@ protected XMLSignatureFactory() {} * "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms"> * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new XMLSignatureFactory * @throws NullPointerException if mechanismType is * null @@ -234,6 +236,7 @@ public static XMLSignatureFactory getInstance(String mechanismType) { * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. * @param provider the Provider object + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new XMLSignatureFactory * @throws NullPointerException if provider or * mechanismType is null @@ -287,6 +290,7 @@ public static XMLSignatureFactory getInstance(String mechanismType, * Java Security Standard Algorithm Names Specification for a list of * standard mechanism types. * @param provider the string name of the provider + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new XMLSignatureFactory * @throws NoSuchProviderException if the specified provider is not * registered in the security provider list diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java index be5e4cef3675b..09f8a12e486bc 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,6 +99,7 @@ * Multiple threads each manipulating a different KeyInfoFactory * instance need not synchronize. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @author Sean Mullan * @author JSR 105 Expert Group * @since 1.6 @@ -142,6 +143,7 @@ protected KeyInfoFactory() {} * "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms"> * Java Security Standard Algorithm Names Specification for a list * of standard mechanism types. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new KeyInfoFactory * @throws NullPointerException if mechanismType is * null @@ -189,6 +191,7 @@ public static KeyInfoFactory getInstance(String mechanismType) { * Java Security Standard Algorithm Names Specification for a list * of standard mechanism types. * @param provider the Provider object + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new KeyInfoFactory * @throws NullPointerException if mechanismType or * provider are null @@ -241,6 +244,7 @@ public static KeyInfoFactory getInstance(String mechanismType, * Java Security Standard Algorithm Names Specification for a list * of standard mechanism types. * @param provider the string name of the provider + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return a new KeyInfoFactory * @throws NoSuchProviderException if the specified provider is not * registered in the security provider list diff --git a/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java b/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java index 3ff0f2663a223..97ccd65dd05ce 100644 --- a/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java +++ b/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -181,6 +181,7 @@ public Builder(PrivateKey privateKey, CertPath certPath) { * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> * Java Cryptography Architecture Standard Algorithm Name * Documentation for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the {@code JarSigner.Builder} itself. * @throws NoSuchAlgorithmException if {@code algorithm} is not available. */ @@ -202,6 +203,7 @@ public Builder digestAlgorithm(String algorithm) throws NoSuchAlgorithmException * Java Cryptography Architecture Standard Algorithm Name * Documentation for information about standard algorithm names. * @param provider the provider. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the {@code JarSigner.Builder} itself. * @throws NoSuchAlgorithmException if {@code algorithm} is not * available in the specified provider. @@ -227,6 +229,7 @@ public Builder digestAlgorithm(String algorithm, Provider provider) * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> * Java Cryptography Architecture Standard Algorithm Name * Documentation for information about standard algorithm names. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the {@code JarSigner.Builder} itself. * @throws NoSuchAlgorithmException if {@code algorithm} is not available. * @throws IllegalArgumentException if {@code algorithm} is not @@ -254,6 +257,7 @@ public Builder signatureAlgorithm(String algorithm) * Java Cryptography Architecture Standard Algorithm Name * Documentation for information about standard algorithm names. * @param provider the provider. + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the {@code JarSigner.Builder} itself. * @throws NoSuchAlgorithmException if {@code algorithm} is not * available in the specified provider. From a1fd5f4e88f52125eef4feea91a60641981177c1 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 27 Jan 2025 07:13:00 +0000 Subject: [PATCH 237/263] 8348554: Enhance Linux kernel version checks Reviewed-by: shade, fyang --- src/hotspot/os/linux/os_linux.cpp | 30 +++++++++++++++---- src/hotspot/os/linux/os_linux.hpp | 8 ++++- .../os/linux/systemMemoryBarrier_linux.cpp | 10 +++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 92996789394e5..57b8a37baf253 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -378,9 +378,10 @@ static void next_line(FILE *f) { } while (c != '\n' && c != EOF); } -void os::Linux::kernel_version(long* major, long* minor) { - *major = -1; - *minor = -1; +void os::Linux::kernel_version(long* major, long* minor, long* patch) { + *major = 0; + *minor = 0; + *patch = 0; struct utsname buffer; int ret = uname(&buffer); @@ -388,12 +389,29 @@ void os::Linux::kernel_version(long* major, long* minor) { log_warning(os)("uname(2) failed to get kernel version: %s", os::errno_name(ret)); return; } - int nr_matched = sscanf(buffer.release, "%ld.%ld", major, minor); - if (nr_matched != 2) { - log_warning(os)("Parsing kernel version failed, expected 2 version numbers, only matched %d", nr_matched); + int nr_matched = sscanf(buffer.release, "%ld.%ld.%ld", major, minor, patch); + if (nr_matched != 3) { + log_warning(os)("Parsing kernel version failed, expected 3 version numbers, only matched %d", nr_matched); } } +int os::Linux::kernel_version_compare(long major1, long minor1, long patch1, + long major2, long minor2, long patch2) { + // Compare major versions + if (major1 > major2) return 1; + if (major1 < major2) return -1; + + // Compare minor versions + if (minor1 > minor2) return 1; + if (minor1 < minor2) return -1; + + // Compare patchlevel versions + if (patch1 > patch2) return 1; + if (patch1 < patch2) return -1; + + return 0; +} + bool os::Linux::get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu) { FILE* fh; uint64_t userTicks, niceTicks, systemTicks, idleTicks; diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index 29848580c4ad5..bd2e1ea323048 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -91,7 +91,13 @@ class os::Linux { }; static int active_processor_count(); - static void kernel_version(long* major, long* minor); + static void kernel_version(long* major, long* minor, long* patch); + + // If kernel1 > kernel2 return 1 + // If kernel1 < kernel2 return -1 + // If kernel1 = kernel2 return 0 + static int kernel_version_compare(long major1, long minor1, long patch1, + long major2, long minor2, long patch2); // which_logical_cpu=-1 returns accumulated ticks for all cpus. static bool get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu); diff --git a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp index 870b3f5016a97..766bb70a97710 100644 --- a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp +++ b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp @@ -66,11 +66,11 @@ bool LinuxSystemMemoryBarrier::initialize() { // RISCV port was introduced in kernel 4.4. // 4.4 also made membar private expedited mandatory. // But RISCV actually don't support it until 6.9. - long major, minor; - os::Linux::kernel_version(&major, &minor); - if (!(major > 6 || (major == 6 && minor >= 9))) { - log_info(os)("Linux kernel %ld.%ld does not support MEMBARRIER PRIVATE_EXPEDITED on RISC-V.", - major, minor); + long major, minor, patch; + os::Linux::kernel_version(&major, &minor, &patch); + if (os::Linux::kernel_version_compare(major, minor, patch, 6, 9, 0) == -1) { + log_info(os)("Linux kernel %ld.%ld.%ld does not support MEMBARRIER PRIVATE_EXPEDITED on RISC-V.", + major, minor, patch); return false; } #endif From 70eec9001a550888f35476f9e2cf3c62d41442dd Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Mon, 27 Jan 2025 07:35:40 +0000 Subject: [PATCH 238/263] 8338303: Linux ppc64le with toolchain clang - detection failure in early JVM startup Reviewed-by: mdoerr, erikj, ihse --- make/autoconf/flags-cflags.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 729e508cc2624..7f2a783576ec3 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -736,6 +736,11 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], # for all archs except arm and ppc, prevent gcc to omit frame pointer $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer" fi + if test "x$FLAGS_CPU" = xppc64le; then + # Little endian machine uses ELFv2 ABI. + # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. + $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8" + fi fi if test "x$OPENJDK_TARGET_OS" = xaix; then $1_CFLAGS_CPU="-mcpu=pwr8" From b8c68c0e8c9aee43378fe16349c083cb868447f4 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Mon, 27 Jan 2025 08:14:33 +0000 Subject: [PATCH 239/263] 8348207: Linux PPC64 PCH build broken after JDK-8347909 Co-authored-by: Stefan Karlsson Reviewed-by: clanger, erikj, mdoerr --- make/hotspot/lib/JvmOverrideFiles.gmk | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 6a513e10c61d4..20776afded8e3 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. # 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,15 +52,23 @@ ifneq ($(FDLIBM_CFLAGS), ) endif ifeq ($(call isTargetOs, linux), true) - BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) - BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) + BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) + BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) ifeq ($(TOOLCHAIN_TYPE), clang) JVM_PRECOMPILED_HEADER_EXCLUDE := \ - sharedRuntimeTrig.cpp \ - sharedRuntimeTrans.cpp \ + sharedRuntimeTrig.cpp \ + sharedRuntimeTrans.cpp \ + $(OPT_SPEED_SRC) \ + # + endif + + ifeq ($(call isTargetCpu, ppc64le)+$(TOOLCHAIN_TYPE), true+gcc) + JVM_PRECOMPILED_HEADER_EXCLUDE := \ + sharedRuntimeTrig.cpp \ + sharedRuntimeTrans.cpp \ $(OPT_SPEED_SRC) \ - # + # endif ifeq ($(call isTargetCpu, x86), true) From 175e58b2e321b779276a9a98a5e72cedb9638d0c Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Mon, 27 Jan 2025 08:19:55 +0000 Subject: [PATCH 240/263] 8332980: [IR Framework] Add option to measure IR rule processing time Reviewed-by: kvn, chagedorn --- .../jtreg/compiler/lib/ir_framework/README.md | 1 + .../lib/ir_framework/TestFramework.java | 3 ++- .../driver/irmatching/irmethod/IRMethod.java | 20 +++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/README.md b/test/hotspot/jtreg/compiler/lib/ir_framework/README.md index c807a2651b675..6bdae26259908 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/README.md +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/README.md @@ -178,6 +178,7 @@ The framework provides various stress and debug flags. They should mainly be use - `-DVerbose=true`: Enable more fain-grained logging (slows the execution down). - `-DReproduce=true`: Flag to use when directly running a test VM to bypass dependencies to the driver VM state (for example, when reproducing an issue). - `-DPrintTimes=true`: Print the execution time measurements of each executed test. +- `-DPrintRuleMatchingTime=true`: Print the time of matching IR rules per method. Slows down the execution as the rules are warmed up before meassurement. - `-DVerifyVM=true`: The framework runs the test VM with additional verification flags (slows the execution down). - `-DExcluceRandom=true`: The framework randomly excludes some methods from compilation. IR verification is disabled completely with this flag. - `-DFlipC1C2=true`: The framework compiles all `@Test` annotated method with C1 if a C2 compilation would have been applied and vice versa. IR verification is disabled completely with this flag. diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java index caef911f73a03..889bd39413bf7 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -148,6 +148,7 @@ public class TestFramework { ); public static final boolean VERBOSE = Boolean.getBoolean("Verbose"); + public static final boolean PRINT_RULE_MATCHING_TIME = Boolean.getBoolean("PrintRuleMatchingTime"); public static final boolean TESTLIST = !System.getProperty("Test", "").isEmpty(); public static final boolean EXCLUDELIST = !System.getProperty("Exclude", "").isEmpty(); private static final boolean REPORT_STDOUT = Boolean.getBoolean("ReportStdout"); diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java index dbd431d22e048..714af5c651949 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ import java.util.ArrayList; import java.util.List; +import static compiler.lib.ir_framework.TestFramework.PRINT_RULE_MATCHING_TIME; + /** * This class represents a {@link Test @Test} annotated method that has an associated non-empty list of applicable * {@link IR @IR} rules. @@ -83,6 +85,20 @@ public String name() { */ @Override public MatchResult match() { - return new IRMethodMatchResult(method, matcher.match()); + if (!PRINT_RULE_MATCHING_TIME) { + return new IRMethodMatchResult(method, matcher.match()); + } + + List match; + for (int i = 0; i < 10; i++) { // warm up + match = matcher.match(); + } + + long startTime = System.nanoTime(); + match = matcher.match(); + long endTime = System.nanoTime(); + long duration = (endTime - startTime); + System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1000000) + " ms"); + return new IRMethodMatchResult(method, match); } } From afcc2b03afc77f730300e1d92471466d56ed75fb Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Mon, 27 Jan 2025 10:11:53 +0000 Subject: [PATCH 241/263] 8348562: ZGC: segmentation fault due to missing node type check in barrier elision analysis Reviewed-by: rcastanedalo, rrich --- src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp index 538e87a8f1930..311ea2871f7b8 100644 --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp @@ -558,7 +558,9 @@ static const Node* get_base_and_offset(const MachNode* mach, intptr_t& offset) { // The memory address is computed by 'base' and fed to 'mach' via an // indirect memory operand (indicated by offset == 0). The ultimate base and // offset can be fetched directly from the inputs and Ideal type of 'base'. - offset = base->bottom_type()->isa_oopptr()->offset(); + const TypeOopPtr* oopptr = base->bottom_type()->isa_oopptr(); + if (oopptr == nullptr) return nullptr; + offset = oopptr->offset(); // Even if 'base' is not an Ideal AddP node anymore, Matcher::ReduceInst() // guarantees that the base address is still available at the same slot. base = base->in(AddPNode::Base); From ffeb9b5aff6b91297b4bbedb7b33670dc17309ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Bj=C3=B8rsn=C3=B8s?= Date: Mon, 27 Jan 2025 12:46:43 +0000 Subject: [PATCH 242/263] 8342807: Update links in java.base to use https:// Reviewed-by: rriggs, ihse, jkern --- src/java.base/aix/native/libjli/java_md_aix.h | 2 +- src/java.base/linux/native/libsimdsort/xss-common-qsort.h | 2 +- src/java.base/share/man/keytool.md | 4 ++-- src/java.base/unix/classes/sun/net/PortConfig.java | 4 ++-- src/java.base/unix/native/libjava/ProcessEnvironment_md.c | 6 +++--- src/java.base/unix/native/libjava/ProcessImpl_md.c | 7 +++---- src/java.base/unix/native/libjava/childproc.c | 4 ++-- src/java.base/unix/native/libjava/childproc.h | 6 +++--- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/java.base/aix/native/libjli/java_md_aix.h b/src/java.base/aix/native/libjli/java_md_aix.h index 231b7b2d0fd47..d319a1d63531b 100644 --- a/src/java.base/aix/native/libjli/java_md_aix.h +++ b/src/java.base/aix/native/libjli/java_md_aix.h @@ -29,7 +29,7 @@ /* * Very limited AIX port of dladdr() for libjli.so. * - * We try to mimic dladdr(3) on Linux (see http://linux.die.net/man/3/dladdr) + * We try to mimic dladdr(3) on Linux (see https://linux.die.net/man/3/dladdr) * dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. * * We only support Dl_info.dli_fname here as this is the only thing that is diff --git a/src/java.base/linux/native/libsimdsort/xss-common-qsort.h b/src/java.base/linux/native/libsimdsort/xss-common-qsort.h index 07279a487c441..95fe8738d35e2 100644 --- a/src/java.base/linux/native/libsimdsort/xss-common-qsort.h +++ b/src/java.base/linux/native/libsimdsort/xss-common-qsort.h @@ -49,7 +49,7 @@ * [3] https://github.com/simd-sorting/fast-and-robust: SPDX-License-Identifier: * MIT * - * [4] http://mitp-content-server.mit.edu:18180/books/content/sectbyfn?collid=books_pres_0&fn=Chapter%2027.pdf&id=8030 + * [4] https://mitp-content-server.mit.edu/books/content/sectbyfn?collid=books_pres_0&fn=Chapter%2027.pdf&id=8030 * */ diff --git a/src/java.base/share/man/keytool.md b/src/java.base/share/man/keytool.md index 8484ec6b5b312..19ba8c3491251 100644 --- a/src/java.base/share/man/keytool.md +++ b/src/java.base/share/man/keytool.md @@ -1,5 +1,5 @@ --- -# Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -1661,7 +1661,7 @@ To import a certificate for the CA, complete the following process: The `cacerts` keystore ships with a set of root certificates issued by the CAs of [the Oracle Java Root Certificate program]( - http://www.oracle.com/technetwork/java/javase/javasecarootcertsprogram-1876540.html). + https://www.oracle.com/java/technologies/javase/carootcertsprogram.html). If you request a signed certificate from a CA, and a certificate authenticating that CA's public key hasn't been added to `cacerts`, then you must import a certificate from that CA as a trusted certificate. diff --git a/src/java.base/unix/classes/sun/net/PortConfig.java b/src/java.base/unix/classes/sun/net/PortConfig.java index 428870c922204..e0130ac2acb80 100644 --- a/src/java.base/unix/classes/sun/net/PortConfig.java +++ b/src/java.base/unix/classes/sun/net/PortConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ private PortConfig() {} break; case AIX: // The ephemeral port is OS version dependent on AIX: - // http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm + // https://www.ibm.com/support/pages/node/886227 // However, on AIX 5.3 / 6.1 / 7.1 we always see the // settings below by using: // /usr/sbin/no -a | fgrep ephemeral diff --git a/src/java.base/unix/native/libjava/ProcessEnvironment_md.c b/src/java.base/unix/native/libjava/ProcessEnvironment_md.c index 46ccc5db071a2..556ef60942201 100644 --- a/src/java.base/unix/native/libjava/ProcessEnvironment_md.c +++ b/src/java.base/unix/native/libjava/ProcessEnvironment_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,8 @@ * The declaration is standardized as part of UNIX98, but there is * no standard (not even de-facto) header file where the * declaration is to be found. See: - * http://www.opengroup.org/onlinepubs/009695399/functions/environ.html - * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html + * https://pubs.opengroup.org/onlinepubs/009695399/functions/environ.html + * https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html * * "All identifiers in this volume of IEEE Std 1003.1-2001, except * environ, are defined in at least one of the headers" (!) diff --git a/src/java.base/unix/native/libjava/ProcessImpl_md.c b/src/java.base/unix/native/libjava/ProcessImpl_md.c index 5a3a5cd088a6a..fc97eb187ebe9 100644 --- a/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,7 +106,7 @@ * Note that when using posix_spawn(3), we exec twice: first a tiny binary called * the jspawnhelper, then in the jspawnhelper we do the pre-exec work and exec a * second time, this time the target binary (similar to the "exec-twice-technique" - * described in http://mail.openjdk.org/pipermail/core-libs-dev/2018-September/055333.html). + * described in https://mail.openjdk.org/pipermail/core-libs-dev/2018-September/055333.html). * * This is a JDK-specific implementation detail which just happens to be * implemented for jdk.lang.Process.launchMechanism=POSIX_SPAWN. @@ -200,8 +200,7 @@ setSIGCHLDHandler(JNIEnv *env) * non-standard-compliant, and we shouldn't rely on it. * * References: - * http://www.opengroup.org/onlinepubs/7908799/xsh/exec.html - * http://www.pasc.org/interps/unofficial/db/p1003.1/pasc-1003.1-132.html + * https://pubs.opengroup.org/onlinepubs/7908799/xsh/exec.html */ struct sigaction sa; sa.sa_handler = SIG_DFL; diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c index a061bc0e210ff..1543e269223c7 100644 --- a/src/java.base/unix/native/libjava/childproc.c +++ b/src/java.base/unix/native/libjava/childproc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ readFully(int fd, void *buf, size_t nbyte) buf = (void *) (((char *)buf) + n); } else if (errno == EINTR) { /* Strange signals like SIGJVM1 are possible at any time. - * See http://www.dreamsongs.com/WorseIsBetter.html */ + * See https://dreamsongs.com/WorseIsBetter.html */ } else { return -1; } diff --git a/src/java.base/unix/native/libjava/childproc.h b/src/java.base/unix/native/libjava/childproc.h index 77ec41921d220..974fac3bdddda 100644 --- a/src/java.base/unix/native/libjava/childproc.h +++ b/src/java.base/unix/native/libjava/childproc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,8 @@ * The declaration is standardized as part of UNIX98, but there is * no standard (not even de-facto) header file where the * declaration is to be found. See: - * http://www.opengroup.org/onlinepubs/009695399/functions/environ.html - * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html + * https://pubs.opengroup.org/onlinepubs/009695399/functions/environ.html + * https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html * * "All identifiers in this volume of IEEE Std 1003.1-2001, except * environ, are defined in at least one of the headers" (!) From f1e07974a09e5deaecdfe0d9e18553f1cde15e2d Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 27 Jan 2025 13:10:43 +0000 Subject: [PATCH 243/263] 8348586: Optionally silence make warnings about non-control variables Reviewed-by: mcimadamore, erikj --- bin/idea.sh | 2 +- make/Global.gmk | 3 ++- make/InitSupport.gmk | 17 +++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/idea.sh b/bin/idea.sh index 1ebe9d96c7fa1..eb37964f39685 100644 --- a/bin/idea.sh +++ b/bin/idea.sh @@ -99,7 +99,7 @@ if [ "$VERBOSE" = "true" ] ; then echo "idea template dir: $IDEA_TEMPLATE" fi -cd $TOP ; make idea-gen-config IDEA_OUTPUT=$IDEA_OUTPUT MODULES="$*" $CONF_ARG || exit 1 +cd $TOP ; make idea-gen-config ALLOW=IDEA_OUTPUT,MODULES IDEA_OUTPUT=$IDEA_OUTPUT MODULES="$*" $CONF_ARG || exit 1 cd $SCRIPT_DIR . $IDEA_OUTPUT/env.cfg diff --git a/make/Global.gmk b/make/Global.gmk index 86487c1c2fc19..25753f1ae5763 100644 --- a/make/Global.gmk +++ b/make/Global.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -108,6 +108,7 @@ help: $(info $(_) MICRO="OPT1=x;OPT2=y" # Control the MICRO test harness, use 'make test-only MICRO=help' to list) $(info $(_) TEST_OPTS="OPT1=x;..." # Generic control of all test harnesses) $(info $(_) TEST_VM_OPTS="ARG ..." # Same as setting TEST_OPTS to VM_OPTIONS="ARG ...") + $(info $(_) ALLOW="FOO,BAR" # Do not warn that FOO and BAR are non-control variables) $(info ) $(if $(all_confs), $(info Available configurations in $(build_dir):) $(foreach var,$(all_confs),$(info * $(var))), \ $(info No configurations were found in $(build_dir).) $(info Run 'bash configure' to create a configuration.)) diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index fdd351be6d2d1..baee52a888edc 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -48,12 +48,15 @@ ifeq ($(HAS_SPEC), ) # from the command-line. ############################################################################## - # Make control variables, handled by Init.gmk - INIT_CONTROL_VARIABLES += LOG CONF CONF_NAME SPEC JOBS TEST_JOBS CONF_CHECK \ - COMPARE_BUILD JTREG GTEST MICRO TEST_OPTS TEST_VM_OPTS TEST_DEPS + # Essential control variables that are handled by Init.gmk + INIT_CONTROL_VARIABLES := LOG CONF CONF_NAME SPEC JOBS CONF_CHECK ALLOW \ + COMPARE_BUILD - # All known make control variables - MAKE_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) TEST JDK_FILTER SPEC_FILTER + # All known make control variables; these are handled in other makefiles + MAKE_CONTROL_VARIABLES += JDK_FILTER SPEC_FILTER \ + TEST TEST_JOBS JTREG GTEST MICRO TEST_OPTS TEST_VM_OPTS TEST_DEPS + + ALL_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) $(MAKE_CONTROL_VARIABLES) # Define a simple reverse function. # Should maybe move to MakeBase.gmk, but we can't include that file now. @@ -87,8 +90,10 @@ ifeq ($(HAS_SPEC), ) command_line_variables := $$(strip $$(foreach var, \ $$(subst \ ,_,$$(MAKEOVERRIDES)), \ $$(firstword $$(subst =, , $$(var))))) + allowed_command_line_variables := $$(strip $$(subst $$(COMMA), , $$(ALLOW))) unknown_command_line_variables := $$(strip \ - $$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables))) + $$(filter-out $$(ALL_CONTROL_VARIABLES) $$(allowed_command_line_variables), \ + $$(command_line_variables))) ifneq ($$(unknown_command_line_variables), ) $$(info Note: Command line contains non-control variables:) $$(foreach var, $$(unknown_command_line_variables), $$(info * $$(var)=$$($$(var)))) From 7d6055a786ba5e146bcdd6f58b5d47f968a4af90 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 27 Jan 2025 13:11:03 +0000 Subject: [PATCH 244/263] 8348429: Update cross-compilation devkits to Fedora 41/gcc 13.2 Reviewed-by: erikj --- make/autoconf/flags-cflags.m4 | 7 ++++--- make/conf/jib-profiles.js | 8 ++++---- make/devkit/Tools.gmk | 23 ++++++++++------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 7f2a783576ec3..38021267f42df 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -235,9 +235,10 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], CFLAGS_WARNINGS_ARE_ERRORS="-Werror" # Additional warnings that are not activated by -Wall and -Wextra - WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wreturn-type -Wsign-compare \ - -Wtrampolines -Wundef -Wunused-const-variable=1 -Wunused-function \ - -Wunused-result -Wunused-value -Wtype-limits -Wuninitialized" + WARNINGS_ENABLE_ADDITIONAL="-Winvalid-pch -Wpointer-arith -Wreturn-type \ + -Wsign-compare -Wtrampolines -Wtype-limits -Wundef -Wuninitialized \ + -Wunused-const-variable=1 -Wunused-function -Wunused-result \ + -Wunused-value" WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder" WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL" WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX" diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index e6204d2995edb..9f04fce2ca6c5 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1092,9 +1092,9 @@ var getJibProfilesDependencies = function (input, common) { windows_x64: "VS2022-17.6.5+1.0", linux_aarch64: "gcc13.2.0-OL7.6+1.0", linux_arm: "gcc8.2.0-Fedora27+1.0", - linux_ppc64le: "gcc8.2.0-Fedora27+1.0", - linux_s390x: "gcc8.2.0-Fedora27+1.0", - linux_riscv64: "gcc11.3.0-Fedora_rawhide_68692+1.1" + linux_ppc64le: "gcc13.2.0-Fedora_41+1.0", + linux_s390x: "gcc13.2.0-Fedora_41+1.0", + linux_riscv64: "gcc13.2.0-Fedora_41+1.0" }; var devkit_platform = (input.target_cpu == "x86" diff --git a/make/devkit/Tools.gmk b/make/devkit/Tools.gmk index 300501f5f35ff..249eaa6624715 100644 --- a/make/devkit/Tools.gmk +++ b/make/devkit/Tools.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. # 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,18 +63,14 @@ ifeq ($(BASE_OS), OL) LINUX_VERSION := OL6.4 endif else ifeq ($(BASE_OS), Fedora) + DEFAULT_OS_VERSION := 41 + ifeq ($(BASE_OS_VERSION), ) + BASE_OS_VERSION := $(DEFAULT_OS_VERSION) + endif ifeq ($(ARCH), riscv64) - DEFAULT_OS_VERSION := rawhide/68692 - ifeq ($(BASE_OS_VERSION), ) - BASE_OS_VERSION := $(DEFAULT_OS_VERSION) - endif - BASE_URL := http://fedora.riscv.rocks/repos-dist/$(BASE_OS_VERSION)/$(ARCH)/Packages/ + BASE_URL := http://fedora.riscv.rocks/repos-dist/f$(BASE_OS_VERSION)/latest/$(ARCH)/Packages/ else - DEFAULT_OS_VERSION := 27 LATEST_ARCHIVED_OS_VERSION := 35 - ifeq ($(BASE_OS_VERSION), ) - BASE_OS_VERSION := $(DEFAULT_OS_VERSION) - endif ifeq ($(filter x86_64 armhfp, $(ARCH)), ) FEDORA_TYPE := fedora-secondary else @@ -203,7 +199,7 @@ RPM_LIST := \ glibc glibc-headers glibc-devel \ cups-libs cups-devel \ libX11 libX11-devel \ - xorg-x11-proto-devel \ + libxcb xorg-x11-proto-devel \ alsa-lib alsa-lib-devel \ libXext libXext-devel \ libXtst libXtst-devel \ @@ -441,8 +437,9 @@ $(gcc) \ # wants. $(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS)) -ifneq ($(ARCH), riscv64) - # gold is not available for riscv64 for some reason, +ifeq ($(filter $(ARCH), s390x riscv64 ppc64le), ) + # gold compiles but cannot link properly on s390x @ gcc 13.2 and Fedore 41 + # gold is not available for riscv64 and ppc64le, # and subsequent linking will fail if we try to enable it. LINKER_CONFIG := --enable-gold=default endif From 1d8ccb89204cc5efbcecdaa0c9de7b2c5a109d5d Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Mon, 27 Jan 2025 14:03:35 +0000 Subject: [PATCH 245/263] 8342465: Improve API documentation for java.lang.classfile Reviewed-by: asotona, darcy --- .../java/lang/classfile/AccessFlags.java | 55 +- .../java/lang/classfile/AnnotationValue.java | 26 +- .../lang/classfile/AttributedElement.java | 7 + .../java/lang/classfile/ClassBuilder.java | 189 +- .../java/lang/classfile/ClassElement.java | 18 +- .../java/lang/classfile/ClassFile.java | 686 +++++-- .../java/lang/classfile/ClassFileBuilder.java | 80 +- .../java/lang/classfile/ClassFileElement.java | 36 +- .../lang/classfile/ClassFileTransform.java | 111 +- .../java/lang/classfile/ClassFileVersion.java | 46 +- .../classfile/ClassHierarchyResolver.java | 113 +- .../java/lang/classfile/ClassModel.java | 75 +- .../java/lang/classfile/ClassTransform.java | 46 +- .../java/lang/classfile/CodeBuilder.java | 1795 +++++++++++++---- .../java/lang/classfile/CodeElement.java | 21 +- .../java/lang/classfile/CodeModel.java | 33 +- .../java/lang/classfile/CodeTransform.java | 26 +- .../java/lang/classfile/CompoundElement.java | 49 +- .../java/lang/classfile/FieldBuilder.java | 27 +- .../java/lang/classfile/FieldElement.java | 15 +- .../java/lang/classfile/FieldModel.java | 33 +- .../java/lang/classfile/FieldTransform.java | 22 +- .../java/lang/classfile/Instruction.java | 7 +- .../java/lang/classfile/Interfaces.java | 16 +- .../java/lang/classfile/MethodBuilder.java | 46 +- .../java/lang/classfile/MethodElement.java | 15 +- .../java/lang/classfile/MethodModel.java | 33 +- .../java/lang/classfile/MethodTransform.java | 27 +- .../classes/java/lang/classfile/Opcode.java | 6 +- .../lang/classfile/PseudoInstruction.java | 17 +- .../java/lang/classfile/Superclass.java | 18 +- .../classes/java/lang/classfile/TypeKind.java | 11 +- .../classfile/attribute/CodeAttribute.java | 1 + .../classfile/attribute/InnerClassInfo.java | 3 +- .../attribute/MethodParameterInfo.java | 3 +- .../classfile/attribute/ModuleAttribute.java | 3 +- .../classfile/attribute/ModuleExportInfo.java | 1 + .../classfile/attribute/ModuleOpenInfo.java | 1 + .../attribute/ModuleRequireInfo.java | 1 + .../attribute/ModuleResolutionAttribute.java | 3 +- .../constantpool/ConstantPoolBuilder.java | 6 + .../classfile/instruction/ExceptionCatch.java | 3 +- .../java/lang/classfile/package-info.java | 193 +- .../snippet-files/PackageSnippets.java | 23 +- 44 files changed, 2932 insertions(+), 1014 deletions(-) diff --git a/src/java.base/share/classes/java/lang/classfile/AccessFlags.java b/src/java.base/share/classes/java/lang/classfile/AccessFlags.java index b1d026f52e4c4..33db731efc80c 100644 --- a/src/java.base/share/classes/java/lang/classfile/AccessFlags.java +++ b/src/java.base/share/classes/java/lang/classfile/AccessFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,10 +30,33 @@ import jdk.internal.classfile.impl.AccessFlagsImpl; /** - * Models the access flags for a class, method, or field. Delivered as a - * {@link ClassElement}, {@link FieldElement}, or {@link MethodElement} - * when traversing the corresponding model type. + * Models the access flags for a class, method, or field. The access flags + * appears exactly once in each class, method, or field; a {@link + * ClassBuilder} and a {@link FieldBuilder} chooses an unspecified default value + * if access flags are not provided, and a {@link MethodBuilder} is always + * created with access flags. + *

+ * {@code AccessFlags} cannot be created via a factory method directly; it can + * be created with {@code withFlags} methods on the respective builders. + *

+ * A {@link MethodBuilder} throws an {@link IllegalArgumentException} if it is + * supplied an {@code AccessFlags} object that changes the preexisting + * {@link ClassFile#ACC_STATIC ACC_STATIC} flag of the builder, because the + * access flag change may invalidate previously supplied data to the builder. * + * @apiNote + * The access flags of classes, methods, and fields are modeled as a standalone + * object to support streaming as elements for {@link ClassFileTransform}. + * Other access flags are not elements of a {@link CompoundElement} and thus not + * modeled by {@code AccessFlags}; they provide their own {@code flagsMask}, + * {@code flags}, and {@code has} methods. + * + * @see ClassModel#flags() + * @see FieldModel#flags() + * @see MethodModel#flags() + * @see ClassBuilder#withFlags + * @see FieldBuilder#withFlags + * @see MethodBuilder#withFlags * @since 24 */ public sealed interface AccessFlags @@ -41,26 +64,36 @@ public sealed interface AccessFlags permits AccessFlagsImpl { /** - * {@return the access flags, as a bit mask} + * {@return the access flags, as a bit mask} It is in the range of unsigned + * short, {@code [0, 0xFFFF]}. */ int flagsMask(); /** - * {@return the access flags} + * {@return the access flags, as a set of flag enums} + * + * @throws IllegalArgumentException if the flags mask has any undefined bit set + * @see #location() */ Set flags(); /** - * {@return whether the specified flag is present} The specified flag - * should be a valid flag for the classfile location associated with this - * element otherwise false is returned. + * {@return whether the specified flag is set} If the specified flag + * is not available to this {@linkplain #location() location}, returns + * {@code false}. + * * @param flag the flag to test + * @see #location() */ boolean has(AccessFlag flag); /** - * {@return the classfile location for this element, which is either class, - * method, or field} + * {@return the {@code class} file location for this element, which is + * either class, method, or field} + * + * @see AccessFlag.Location#CLASS + * @see AccessFlag.Location#FIELD + * @see AccessFlag.Location#METHOD */ AccessFlag.Location location(); } diff --git a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java index 54a9ed80573ce..ae31fdf3967bb 100644 --- a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java +++ b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java @@ -54,7 +54,7 @@ public sealed interface AnnotationValue { /** * Models an annotation value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_ANNOTATION}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_ANNOTATION}. * * @since 24 */ @@ -66,7 +66,7 @@ sealed interface OfAnnotation extends AnnotationValue /** * Models an array value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_ARRAY}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_ARRAY}. * * @since 24 */ @@ -122,7 +122,7 @@ sealed interface OfConstant extends AnnotationValue { /** * Models a string value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_STRING}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_STRING}. * * @since 24 */ @@ -149,7 +149,7 @@ default String resolvedValue() { /** * Models a double value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_DOUBLE}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_DOUBLE}. * * @since 24 */ @@ -176,7 +176,7 @@ default Double resolvedValue() { /** * Models a float value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_FLOAT}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_FLOAT}. * * @since 24 */ @@ -203,7 +203,7 @@ default Float resolvedValue() { /** * Models a long value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_LONG}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_LONG}. * * @since 24 */ @@ -230,7 +230,7 @@ default Long resolvedValue() { /** * Models an int value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_INT}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_INT}. * * @since 24 */ @@ -257,7 +257,7 @@ default Integer resolvedValue() { /** * Models a short value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_SHORT}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_SHORT}. * * @since 24 */ @@ -287,7 +287,7 @@ default Short resolvedValue() { /** * Models a char value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_CHAR}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_CHAR}. * * @since 24 */ @@ -317,7 +317,7 @@ default Character resolvedValue() { /** * Models a byte value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_BYTE}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_BYTE}. * * @since 24 */ @@ -347,7 +347,7 @@ default Byte resolvedValue() { /** * Models a boolean value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_BOOLEAN}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_BOOLEAN}. * * @since 24 */ @@ -377,7 +377,7 @@ default Boolean resolvedValue() { /** * Models a class value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_CLASS}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_CLASS}. * * @since 24 */ @@ -394,7 +394,7 @@ default ClassDesc classSymbol() { /** * Models an enum value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value TAG_ENUM}. + * The {@linkplain #tag tag} of this value is {@value %c TAG_ENUM}. * * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java index 0edb79a863d91..1feef1ba35e4f 100644 --- a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java +++ b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java @@ -39,7 +39,14 @@ * A {@link ClassFileElement} describing a {@code class} file structure that has * attributes, such as a {@code class} file, a field, a method, a {@link * CodeAttribute Code} attribute, or a record component. + *

+ * Unless otherwise specified, most attributes that can be discovered in a + * {@link CompoundElement} implements the corresponding {@linkplain + * ClassFileElement##membership membership subinterface} of {@code + * ClassFileElement}, and can be sent to a {@link ClassFileBuilder} to be + * integrated into the built structure. * + * @see java.lang.classfile.attribute * @jvms 4.7 Attributes * @sealedGraph * @since 24 diff --git a/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java index 996c63ddd0126..6efd240d8af73 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 +25,8 @@ package java.lang.classfile; -import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.Utf8Entry; import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; @@ -41,14 +41,19 @@ import jdk.internal.classfile.impl.Util; /** - * A builder for classfiles. Builders are not created directly; they are passed - * to handlers by methods such as {@link ClassFile#build(ClassDesc, Consumer)} - * or to class transforms. The elements of a classfile can be specified - * abstractly (by passing a {@link ClassElement} to {@link #with(ClassFileElement)}) - * or concretely by calling the various {@code withXxx} methods. + * A builder for a {@code class} file. {@link ClassFile} provides different + * {@code build} methods that accept handlers to configure such a builder; + * {@link ClassFile#build(ClassDesc, Consumer)} suffices for basic usage, while + * {@link ClassFile#build(ClassEntry, ConstantPoolBuilder, Consumer)} allows + * fine-grained control over {@linkplain ClassFileBuilder#constantPool() the + * constant pool}. + *

+ * Refer to {@link ClassFileBuilder} for general guidance and caution around + * the use of builders for structures in the {@code class} file format. * + * @see ClassFile#build(ClassEntry, ConstantPoolBuilder, Consumer) + * @see ClassModel * @see ClassTransform - * * @since 24 */ public sealed interface ClassBuilder @@ -56,28 +61,38 @@ public sealed interface ClassBuilder permits ChainedClassBuilder, DirectClassBuilder { /** - * Sets the classfile version. + * Sets the version of this class. + * * @param major the major version number * @param minor the minor version number * @return this builder + * @see ClassFileVersion */ default ClassBuilder withVersion(int major, int minor) { return with(ClassFileVersion.of(major, minor)); } /** - * Sets the classfile access flags. + * Sets the access flags of this class. + * * @param flags the access flags, as a bit mask * @return this builder + * @see AccessFlags + * @see AccessFlag.Location#CLASS */ default ClassBuilder withFlags(int flags) { return with(new AccessFlagsImpl(AccessFlag.Location.CLASS, flags)); } /** - * Sets the classfile access flags. - * @param flags the access flags + * Sets the access flags of this class. + * + * @param flags the access flags, as flag enums * @return this builder + * @throws IllegalArgumentException if any flag cannot be applied to the + * {@link AccessFlag.Location#CLASS} location + * @see AccessFlags + * @see AccessFlag.Location#CLASS */ default ClassBuilder withFlags(AccessFlag... flags) { return with(new AccessFlagsImpl(AccessFlag.Location.CLASS, flags)); @@ -85,8 +100,10 @@ default ClassBuilder withFlags(AccessFlag... flags) { /** * Sets the superclass of this class. + * * @param superclassEntry the superclass * @return this builder + * @see Superclass */ default ClassBuilder withSuperclass(ClassEntry superclassEntry) { return with(Superclass.of(superclassEntry)); @@ -94,9 +111,11 @@ default ClassBuilder withSuperclass(ClassEntry superclassEntry) { /** * Sets the superclass of this class. + * * @param desc the superclass * @return this builder * @throws IllegalArgumentException if {@code desc} represents a primitive type + * @see Superclass */ default ClassBuilder withSuperclass(ClassDesc desc) { return withSuperclass(constantPool().classEntry(desc)); @@ -104,8 +123,10 @@ default ClassBuilder withSuperclass(ClassDesc desc) { /** * Sets the interfaces of this class. + * * @param interfaces the interfaces * @return this builder + * @see Interfaces */ default ClassBuilder withInterfaces(List interfaces) { return with(Interfaces.of(interfaces)); @@ -113,8 +134,10 @@ default ClassBuilder withInterfaces(List interfaces) { /** * Sets the interfaces of this class. + * * @param interfaces the interfaces * @return this builder + * @see Interfaces */ default ClassBuilder withInterfaces(ClassEntry... interfaces) { return withInterfaces(List.of(interfaces)); @@ -122,8 +145,11 @@ default ClassBuilder withInterfaces(ClassEntry... interfaces) { /** * Sets the interfaces of this class. + * * @param interfaces the interfaces * @return this builder + * @throws IllegalArgumentException if any element of {@code interfaces} is primitive + * @see Interfaces */ default ClassBuilder withInterfaceSymbols(List interfaces) { return withInterfaces(Util.entryList(interfaces)); @@ -131,32 +157,39 @@ default ClassBuilder withInterfaceSymbols(List interfaces) { /** * Sets the interfaces of this class. + * * @param interfaces the interfaces * @return this builder + * @throws IllegalArgumentException if any element of {@code interfaces} is primitive + * @see Interfaces */ default ClassBuilder withInterfaceSymbols(ClassDesc... interfaces) { - // List view, since ref to interfaces is temporary + // list version does defensive copy return withInterfaceSymbols(Arrays.asList(interfaces)); } /** * Adds a field. - * @param name the name of the field - * @param descriptor the field descriptor - * @param handler handler which receives a {@link FieldBuilder} which can - * further define the contents of the field + * + * @param name the field name + * @param descriptor the field descriptor string + * @param handler handler to supply the contents of the field * @return this builder + * @see FieldModel */ ClassBuilder withField(Utf8Entry name, Utf8Entry descriptor, Consumer handler); /** - * Adds a field. - * @param name the name of the field - * @param descriptor the field descriptor - * @param flags the access flags for this field + * Adds a field, with only access flags. + * + * @param name the field name + * @param descriptor the field descriptor string + * @param flags the access flags for this field, as a bit mask * @return this builder + * @see FieldModel + * @see FieldBuilder#withFlags(int) */ default ClassBuilder withField(Utf8Entry name, Utf8Entry descriptor, @@ -166,11 +199,12 @@ default ClassBuilder withField(Utf8Entry name, /** * Adds a field. - * @param name the name of the field - * @param descriptor the field descriptor - * @param handler handler which receives a {@link FieldBuilder} which can - * further define the contents of the field + * + * @param name the field name + * @param descriptor the symbolic field descriptor + * @param handler handler to supply the contents of the field * @return this builder + * @see FieldModel */ default ClassBuilder withField(String name, ClassDesc descriptor, @@ -181,11 +215,14 @@ default ClassBuilder withField(String name, } /** - * Adds a field. - * @param name the name of the field - * @param descriptor the field descriptor - * @param flags the access flags for this field + * Adds a field, with only access flags. + * + * @param name the field name + * @param descriptor the symbolic field descriptor + * @param flags the access flags for this field, as a bit mask * @return this builder + * @see FieldModel + * @see FieldBuilder#withFlags(int) */ default ClassBuilder withField(String name, ClassDesc descriptor, @@ -197,28 +234,33 @@ default ClassBuilder withField(String name, /** * Adds a field by transforming a field from another class. - * - * @implNote - *

This method behaves as if: + *

+ * This method behaves as if: * {@snippet lang=java : - * withField(field.fieldName(), field.fieldType(), - * b -> b.transformField(field, transform)); + * // @link substring=withField target="#withField(Utf8Entry, Utf8Entry, Consumer)" : + * withField(field.fieldName(), field.fieldType(), + * fb -> fb.transform(field, transform)) // @link regex="transform(?=\()" target="FieldBuilder#transform" * } * * @param field the field to be transformed * @param transform the transform to apply to the field * @return this builder + * @see FieldTransform */ ClassBuilder transformField(FieldModel field, FieldTransform transform); /** - * Adds a method. - * @param name the name of the method + * Adds a method. The bit for {@link ClassFile#ACC_STATIC ACC_STATIC} flag + * cannot be modified by the {@code handler} later, and must be set through + * {@code methodFlags}. + * + * @param name the method name * @param descriptor the method descriptor - * @param methodFlags the access flags - * @param handler handler which receives a {@link MethodBuilder} which can - * further define the contents of the method + * @param methodFlags the access flags as a bit mask, with the {@code + * ACC_STATIC} bit definitely set + * @param handler handler to supply the contents of the method * @return this builder + * @see MethodModel */ ClassBuilder withMethod(Utf8Entry name, Utf8Entry descriptor, @@ -226,14 +268,23 @@ ClassBuilder withMethod(Utf8Entry name, Consumer handler); /** - * Adds a method, with only a {@code Code} attribute. + * Adds a method, with only access flags and a {@link CodeModel}. The bit + * for {@link ClassFile#ACC_STATIC ACC_STATIC} flag cannot be modified by + * the {@code handler} later, and must be set through {@code methodFlags}. + *

+ * This method behaves as if: + * {@snippet lang=java : + * // @link substring=withMethod target="#withMethod(Utf8Entry, Utf8Entry, int, Consumer)" : + * withMethod(name, descriptor, methodFlags, mb -> mb.withCode(handler)) // @link substring=withCode target="MethodBuilder#withCode" + * } * - * @param name the name of the method + * @param name the method name * @param descriptor the method descriptor - * @param methodFlags the access flags - * @param handler handler which receives a {@link CodeBuilder} which can - * define the contents of the method body + * @param methodFlags the access flags as a bit mask, with the {@code + * ACC_STATIC} bit definitely set + * @param handler handler to supply the contents of the method body * @return this builder + * @see MethodModel */ default ClassBuilder withMethodBody(Utf8Entry name, Utf8Entry descriptor, @@ -243,13 +294,17 @@ default ClassBuilder withMethodBody(Utf8Entry name, } /** - * Adds a method. - * @param name the name of the method + * Adds a method. The bit for {@link ClassFile#ACC_STATIC ACC_STATIC} flag + * cannot be modified by the {@code handler}, and must be set through + * {@code methodFlags}. + * + * @param name the method name * @param descriptor the method descriptor - * @param methodFlags the access flags - * @param handler handler which receives a {@link MethodBuilder} which can - * further define the contents of the method + * @param methodFlags the access flags as a bit mask, with the {@code + * ACC_STATIC} bit definitely set + * @param handler handler to supply the contents of the method * @return this builder + * @see MethodModel */ default ClassBuilder withMethod(String name, MethodTypeDesc descriptor, @@ -262,13 +317,23 @@ default ClassBuilder withMethod(String name, } /** - * Adds a method, with only a {@link CodeAttribute}. - * @param name the name of the method + * Adds a method, with only access flags and a {@link CodeModel}. The bit + * for {@link ClassFile#ACC_STATIC ACC_STATIC} flag cannot be modified by + * the {@code handler}, and must be set through {@code methodFlags}. + *

+ * This method behaves as if: + * {@snippet lang=java : + * // @link substring=withMethod target="#withMethod(String, MethodTypeDesc, int, Consumer)" : + * withMethod(name, descriptor, methodFlags, mb -> mb.withCode(handler)) // @link substring=withCode target="MethodBuilder#withCode" + * } + * + * @param name the method name * @param descriptor the method descriptor - * @param methodFlags the access flags - * @param handler handler which receives a {@link CodeBuilder} which can - * define the contents of the method body + * @param methodFlags the access flags as a bit mask, with the {@code + * ACC_STATIC} bit definitely set + * @param handler handler to supply the contents of the method body * @return this builder + * @see MethodModel */ default ClassBuilder withMethodBody(String name, MethodTypeDesc descriptor, @@ -278,17 +343,21 @@ default ClassBuilder withMethodBody(String name, } /** - * Adds a method by transforming a method from another class. - * - * @implNote - *

This method behaves as if: + * Adds a method by transforming a method from another class. The transform + * cannot modify the {@link ClassFile#ACC_STATIC ACC_STATIC} flag of the + * original method. + *

+ * This method behaves as if: * {@snippet lang=java : - * withMethod(method.methodName(), method.methodType(), - * b -> b.transformMethod(method, transform)); + * // @link substring=withMethod target="#withMethod(Utf8Entry, Utf8Entry, int, Consumer)" : + * withMethod(method.methodName(), method.methodType(), method.flags().flagMask(), + * mb -> mb.transform(method, transform)) // @link regex="transform(?=\()" target="MethodBuilder#transform" * } + * * @param method the method to be transformed * @param transform the transform to apply to the method * @return this builder + * @see MethodTransform */ ClassBuilder transformMethod(MethodModel method, MethodTransform transform); } diff --git a/src/java.base/share/classes/java/lang/classfile/ClassElement.java b/src/java.base/share/classes/java/lang/classfile/ClassElement.java index c39ab3c4a64d8..866d1bafcc4aa 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassElement.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,21 @@ import java.lang.classfile.attribute.*; /** - * A marker interface for elements that can appear when traversing - * a {@link ClassModel} or be presented to a {@link ClassBuilder}. + * Marker interface for a member element of a {@link ClassModel}. Such an + * element can appear when traversing a {@link ClassModel} unless otherwise + * specified, be supplied to a {@link ClassBuilder}, and be processed by a + * {@link ClassTransform}. + *

+ * {@link AccessFlags}, and {@link ClassFileVersion} are member elements of a + * class that appear exactly once during the traversal of a {@link ClassModel}. + * {@link Superclass} and {@link Interfaces} may be absent or appear at most + * once. A {@link ClassBuilder} may provide an alternative superclass if it is + * not defined but required. * + * @see ClassFileElement##membership Membership Elements + * @see MethodElement + * @see FieldElement + * @see CodeElement * @sealedGraph * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFile.java b/src/java.base/share/classes/java/lang/classfile/ClassFile.java index 43fb1927b3873..4b529c390993c 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFile.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFile.java @@ -25,18 +25,27 @@ package java.lang.classfile; import java.io.IOException; +import java.lang.classfile.AttributeMapper.AttributeStability; import java.lang.classfile.attribute.CharacterRangeInfo; +import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.LocalVariableInfo; import java.lang.classfile.attribute.LocalVariableTypeInfo; import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.StackMapTableAttribute; +import java.lang.classfile.attribute.UnknownAttribute; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.Utf8Entry; import java.lang.classfile.instruction.BranchInstruction; +import java.lang.classfile.instruction.CharacterRange; import java.lang.classfile.instruction.DiscontinuedInstruction; import java.lang.classfile.instruction.ExceptionCatch; +import java.lang.classfile.instruction.LineNumber; +import java.lang.classfile.instruction.LocalVariable; +import java.lang.classfile.instruction.LocalVariableType; import java.lang.constant.ClassDesc; import java.lang.reflect.AccessFlag; +import java.lang.reflect.ClassFileFormatVersion; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -50,9 +59,9 @@ import static jdk.internal.constant.ConstantUtils.CD_module_info; /** - * Represents a context for parsing, transforming, and generating classfiles. - * A {@code ClassFile} has a set of options that condition how parsing and - * generation is done. + * Provides ability to parse, transform, and generate {@code class} files. + * A {@code ClassFile} is a context with a set of options that condition how + * parsing and generation are done. * * @since 24 */ @@ -60,14 +69,20 @@ public sealed interface ClassFile permits ClassFileImpl { /** - * {@return a context with default options} + * {@return a context with default options} Each subtype of {@link Option} + * specifies its default. + *

+ * The default {@link AttributeMapperOption} and {@link + * ClassHierarchyResolverOption} may be unsuitable for some {@code class} + * files and result in parsing or generation errors. */ static ClassFile of() { return ClassFileImpl.DEFAULT_CONTEXT; } /** - * {@return a new context with options altered from the default} + * {@return a context with options altered from the default} Equivalent to + * {@link #of() ClassFile.of().withOptions(options)}. * @param options the desired processing options */ static ClassFile of(Option... options) { @@ -75,14 +90,15 @@ static ClassFile of(Option... options) { } /** - * {@return a copy of the context with altered options} + * {@return a context with altered options from this context} * @param options the desired processing options */ ClassFile withOptions(Option... options); /** - * An option that affects the parsing and writing of classfiles. + * An option that affects the parsing or writing of {@code class} files. * + * @see java.lang.classfile##options Options * @sealedGraph * @since 24 */ @@ -90,16 +106,32 @@ sealed interface Option { } /** - * Option describing attribute mappers for custom attributes. - * Default is only to process standard attributes. + * The option describing user-defined attributes for parsing {@code class} + * files. The default does not recognize any user-defined attribute. + *

+ * An {@code AttributeMapperOption} contains a function that maps an + * attribute name to a user attribute mapper. The function may return {@code + * null} if it does not recognize an attribute name. The returned mapper + * must ensure its {@link AttributeMapper#name() name()} is equivalent to + * the {@link Utf8Entry#stringValue() stringValue()} of the input {@link + * Utf8Entry}. + *

+ * The mapping function in this attribute has lower priority than mappers in + * {@link Attributes}, so it is impossible to override built-in attributes + * with this option. If an attribute is not recognized by any mapper in + * {@link Attributes} and is not assigned a mapper, or recognized, by this + * option, that attribute will be modeled by an {@link UnknownAttribute}. * + * @see AttributeMapper + * @see CustomAttribute * @since 24 */ sealed interface AttributeMapperOption extends Option permits ClassFileImpl.AttributeMapperOptionImpl { /** - * {@return an option describing attribute mappers for custom attributes} + * {@return an option describing user-defined attributes for parsing} + * * @param attributeMapper a function mapping attribute names to attribute mappers */ static AttributeMapperOption of(Function> attributeMapper) { @@ -114,17 +146,31 @@ static AttributeMapperOption of(Function> attribut } /** - * Option describing the class hierarchy resolver to use when generating - * stack maps. + * The option describing the class hierarchy resolver to use when generating + * stack maps or verifying classes. The default is {@link + * ClassHierarchyResolver#defaultResolver()}, which uses core reflection to + * find a class with a given name in {@linkplain ClassLoader#getSystemClassLoader() + * system class loader} and inspect it, and is insufficient if a class is + * not present in the system class loader as in applications, or if loading + * of system classes is not desired as in agents. + *

+ * A {@code ClassHierarchyResolverOption} contains a {@link ClassHierarchyResolver}. + * The resolver must be able to process all classes and interfaces, including + * those appearing as the component types of array types, that appear in the + * operand stack of the generated bytecode. If the resolver fails on any + * of the classes and interfaces with an {@link IllegalArgumentException}, + * the {@code class} file generation fails. * + * @see ClassHierarchyResolver + * @jvms 4.10.1.2 Verification Type System * @since 24 */ sealed interface ClassHierarchyResolverOption extends Option permits ClassFileImpl.ClassHierarchyResolverOptionImpl { /** - * {@return an option describing the class hierarchy resolver to use when - * generating stack maps} + * {@return an option describing the class hierarchy resolver to use} + * * @param classHierarchyResolver the resolver */ static ClassHierarchyResolverOption of(ClassHierarchyResolver classHierarchyResolver) { @@ -139,14 +185,22 @@ static ClassHierarchyResolverOption of(ClassHierarchyResolver classHierarchyReso } /** - * Option describing whether to preserve the original constant pool when - * transforming a {@code class} file. Reusing the constant pool enables - * significant optimizations in processing time and minimizes differences - * between the original and transformed {@code class} files, but may result - * in a bigger transformed {@code class} file when many elements of the - * original {@code class} file are dropped and many original constant - * pool entries become unused. Default is {@link #SHARED_POOL} to preserve - * the original constant pool. + * Option describing whether to extend from the original constant pool when + * transforming a {@code class} file. The default is {@link #SHARED_POOL} + * to extend from the original constant pool. + *

+ * This option affects all overloads of {@link #transformClass transformClass}. + * Extending from the original constant pool keeps the indices into the + * constant pool intact, which enables significant optimizations in processing + * time and minimizes differences between the original and transformed {@code + * class} files, but may result in a bigger transformed {@code class} file + * when many elements of the original {@code class} file are dropped and + * many original constant pool entries become unused. + *

+ * An alternative to this option is to use {@link #build(ClassEntry, + * ConstantPoolBuilder, Consumer)} directly. It allows extension from + * arbitrary constant pools, and may be useful if a built {@code class} file + * reuses structures from multiple original {@code class} files. * * @see ConstantPoolBuilder * @see #build(ClassEntry, ConstantPoolBuilder, Consumer) @@ -156,8 +210,8 @@ static ClassHierarchyResolverOption of(ClassHierarchyResolver classHierarchyReso enum ConstantPoolSharingOption implements Option { /** - * Preserves the original constant pool when transforming the {@code - * class} file. + * Extend the new constant pool from the original constant pool when + * transforming the {@code class} file. *

* These two transformations below are equivalent: * {@snippet lang=java : @@ -194,87 +248,143 @@ enum ConstantPoolSharingOption implements Option { } /** - * Option describing whether to patch out unreachable code. - * Default is {@code PATCH_DEAD_CODE} to automatically patch out unreachable - * code with NOPs. + * The option describing whether to patch out unreachable code for stack map + * generation. The default is {@link #PATCH_DEAD_CODE} to automatically + * patch unreachable code and generate a valid stack map entry for the + * patched code. + *

+ * The stack map generation process may fail when it encounters unreachable + * code and {@link #KEEP_DEAD_CODE} is set. In such cases, users should + * set {@link StackMapsOption#DROP_STACK_MAPS} and provide their own stack + * maps that passes verification (JVMS {@jvms 4.10.1}). * + * @see StackMapsOption + * @jvms 4.10.1 Verification by Type Checking * @since 24 */ enum DeadCodeOption implements Option { - /** Patch unreachable code */ + /** + * Patch unreachable code with dummy code, and generate valid dummy + * stack map entries. This ensures the generated code can pass + * verification (JVMS {@jvms 4.10.1}). + */ PATCH_DEAD_CODE, - /** Keep the unreachable code */ + /** + * Keep the unreachable code for the accuracy of the generated {@code + * class} file. Users should set {@link StackMapsOption#DROP_STACK_MAPS} + * to prevent stack map generation from running and provide their own + * {@link StackMapTableAttribute} to a {@link CodeBuilder}. + */ KEEP_DEAD_CODE } /** - * Option describing whether to filter unresolved labels. - * Default is {@code FAIL_ON_DEAD_LABELS} to throw IllegalArgumentException - * when any {@link ExceptionCatch}, {@link LocalVariableInfo}, - * {@link LocalVariableTypeInfo}, or {@link CharacterRangeInfo} - * reference to unresolved {@link Label} during bytecode serialization. - * Setting this option to {@code DROP_DEAD_LABELS} filters the above - * elements instead. + * The option describing whether to filter {@linkplain + * CodeBuilder#labelBinding(Label) unbound labels} and drop their + * enclosing structures if possible. The default is {@link + * #FAIL_ON_DEAD_LABELS} to fail fast with an {@link IllegalArgumentException} + * when a {@link PseudoInstruction} refers to an unbound label during + * bytecode generation. + *

+ * The affected {@link PseudoInstruction}s include {@link ExceptionCatch}, + * {@link LocalVariable}, {@link LocalVariableType}, and {@link + * CharacterRange}. Setting this option to {@link #DROP_DEAD_LABELS} + * filters these pseudo-instructions from a {@link CodeBuilder} instead. + * Note that instructions, such as {@link BranchInstruction}, with unbound + * labels always fail-fast with an {@link IllegalArgumentException}. * + * @see DebugElementsOption * @since 24 */ enum DeadLabelsOption implements Option { - /** Fail on unresolved labels */ + /** + * Fail fast on {@linkplain CodeBuilder#labelBinding(Label) unbound + * labels}. This also ensures the accuracy of the generated {@code + * class} files. + */ FAIL_ON_DEAD_LABELS, - /** Filter unresolved labels */ + /** + * Filter {@link PseudoInstruction}s with {@linkplain + * CodeBuilder#labelBinding(Label) unbound labels}. Note that + * instructions with unbound labels still cause an {@link + * IllegalArgumentException}. + */ DROP_DEAD_LABELS } /** - * Option describing whether to process or discard debug elements. - * Debug elements include the local variable table, local variable type - * table, and character range table. Discarding debug elements may - * reduce the overhead of parsing or transforming classfiles. - * Default is {@code PASS_DEBUG} to process debug elements. + * The option describing whether to process or discard debug {@link + * PseudoInstruction}s in the traversal of a {@link CodeModel} or a {@link + * CodeBuilder}. The default is {@link #PASS_DEBUG} to process debug + * pseudo-instructions as all other {@link CodeElement}. + *

+ * Debug pseudo-instructions include {@link LocalVariable}, {@link + * LocalVariableType}, and {@link CharacterRange}. Discarding debug + * elements may reduce the overhead of parsing or transforming {@code class} + * files and has no impact on the run-time behavior. * + * @see LineNumbersOption * @since 24 */ enum DebugElementsOption implements Option { - /** Process debug elements */ + /** + * Process debug pseudo-instructions like other member elements of a + * {@link CodeModel}. + */ PASS_DEBUG, - /** Drop debug elements */ + /** + * Drop debug pseudo-instructions from traversal and builders. + */ DROP_DEBUG } /** - * Option describing whether to process or discard line numbers. + * The option describing whether to process or discard {@link LineNumber}s + * in the traversal of a {@link CodeModel} or a {@link CodeBuilder}. The + * default is {@link #PASS_LINE_NUMBERS} to process all line number entries + * as all other {@link CodeElement}. + *

* Discarding line numbers may reduce the overhead of parsing or transforming - * classfiles. - * Default is {@code PASS_LINE_NUMBERS} to process line numbers. + * {@code class} files and has no impact on the run-time behavior. * + * @see DebugElementsOption * @since 24 */ enum LineNumbersOption implements Option { - /** Process line numbers */ + /** + * Process {@link LineNumber} like other member elements of a {@link + * CodeModel}. + */ PASS_LINE_NUMBERS, - /** Drop line numbers */ + /** + * Drop {@link LineNumber} from traversal and builders. + */ DROP_LINE_NUMBERS; } /** - * Option describing whether to automatically rewrite short jumps to - * long when necessary. - * Default is {@link #FIX_SHORT_JUMPS} to automatically rewrite jump - * instructions. + * The option describing whether to automatically rewrite short jumps to + * equivalent instructions when necessary. The default is {@link + * #FIX_SHORT_JUMPS} to automatically rewrite. *

* Due to physical restrictions, some types of instructions cannot encode * certain jump targets with bci offsets less than -32768 or greater than * 32767, as they use a {@code s2} to encode such an offset. (The maximum * length of the {@code code} array is 65535.) These types of instructions * are called "short jumps". + *

+ * Disabling rewrite can ensure the physical accuracy of a generated {@code + * class} file and avoid the overhead from a failed first attempt for + * overflowing forward jumps in some cases, if the generated {@code class} + * file is stable. * * @see BranchInstruction * @see DiscontinuedInstruction.JsrInstruction @@ -294,80 +404,153 @@ enum ShortJumpsOption implements Option { * Fail with an {@link IllegalArgumentException} if short jump overflows. *

* This is useful to ensure the physical accuracy of a generated {@code - * class} file. + * class} file and avoids the overhead from a failed first attempt for + * overflowing forward jumps in some cases. */ FAIL_ON_SHORT_JUMPS } /** - * Option describing whether to generate stackmaps. - * Default is {@code STACK_MAPS_WHEN_REQUIRED} to generate stack - * maps for {@link #JAVA_6_VERSION} or above, where specifically for - * {@link #JAVA_6_VERSION} the stack maps may not be generated. - * @jvms 4.10.1 Verification by Type Checking + * The option describing whether to generate stack maps. The default is + * {@link #STACK_MAPS_WHEN_REQUIRED} to generate stack maps or reuse + * existing ones if compatible. + *

+ * The {@link StackMapTableAttribute} is a derived property from a {@link + * CodeAttribute Code} attribute to allow a Java Virtual Machine to perform + * verification in one pass. Thus, it is not modeled as part of a {@link + * CodeModel}, but computed on-demand instead via stack maps generation. + *

+ * Stack map generation may fail with an {@link IllegalArgumentException} if + * there is {@linkplain DeadCodeOption unreachable code} or legacy + * {@linkplain DiscontinuedInstruction.JsrInstruction jump routine} + * instructions. When {@link #DROP_STACK_MAPS} option is used, users can + * provide their own stack maps by supplying a {@link StackMapTableAttribute} + * to a {@link CodeBuilder}. * + * @see StackMapTableAttribute + * @see DeadCodeOption + * @jvms 4.10.1 Verification by Type Checking * @since 24 */ enum StackMapsOption implements Option { - /** Generate stack maps when required */ + /** + * Generate stack maps or reuse existing ones if compatible. Stack maps + * are present on major versions {@value #JAVA_6_VERSION} or above. For + * these versions, {@link CodeBuilder} tries to reuse compatible stack + * maps information if the code array and exception handlers are still + * compatible after a transformation; otherwise, it runs stack map + * generation. However, it does not fail fast if the major version is + * {@value #JAVA_6_VERSION}, which allows jump subroutine instructions + * that are incompatible with stack maps to exist in the {@code code} + * array. + */ STACK_MAPS_WHEN_REQUIRED, - /** Always generate stack maps */ + /** + * Forces running stack map generation. This runs stack map generation + * unconditionally and fails fast if the generation fails due to any + * reason. + */ GENERATE_STACK_MAPS, - /** Drop stack maps from code */ + /** + * Do not run stack map generation. Users must supply their own + * {@link StackMapTableAttribute} to a {@link CodeBuilder} if the code + * has branches or exception handlers; otherwise, the generated code + * will fail verification (JVMS {@jvms 4.10.1}). + *

+ * This option is required for user-supplied {@link StackMapTableAttribute} + * to be respected. Stack maps on an existing {@link CodeAttribute Code} + * attribute can be reused as below with this option: + * {@snippet lang=java file="PackageSnippets.java" region="manual-reuse-stack-maps"} + */ DROP_STACK_MAPS } /** - * Option describing whether to process or discard unrecognized or problematic - * original attributes when a class, record component, field, method or code is - * transformed in its exploded form. - * Default is {@code PASS_ALL_ATTRIBUTES} to process all original attributes. - * @see AttributeMapper.AttributeStability + * The option describing whether to retain or discard attributes that cannot + * verify their correctness after a transformation. The default is {@link + * #PASS_ALL_ATTRIBUTES} to retain all attributes as-is. + *

+ * Many attributes only depend on data managed by the Class-File API, such + * as constant pool entries or labels into the {@code code} array. If they + * change, the Class-File API knows their updated values and can write a + * correct version by expanding the structures and recomputing the updated + * indexes, known as "explosion". However, some attributes, such as type + * annotations, depend on arbitrary data that may be modified during + * transformations but the Class-File API does not track, such as index to + * an entry in the {@linkplain ClassModel#interfaces() interfaces} of a + * {@code ClassFile} structure. As a result, the Class-File API cannot + * verify the correctness of such information. * + * @see AttributeStability * @since 24 */ enum AttributesProcessingOption implements Option { - /** Process all original attributes during transformation */ + /** + * Retain all original attributes during transformation. + */ PASS_ALL_ATTRIBUTES, - /** Drop unknown attributes during transformation */ + /** + * Drop attributes with {@link AttributeStability#UNKNOWN} data + * dependency during transformation. + */ DROP_UNKNOWN_ATTRIBUTES, - /** Drop unknown and unstable original attributes during transformation */ + /** + * Drop attributes with {@link AttributeStability#UNSTABLE} or higher + * data dependency during transformation. + */ DROP_UNSTABLE_ATTRIBUTES } /** - * Parse a classfile into a {@link ClassModel}. - * @param bytes the bytes of the classfile + * Parses a {@code class} file into a {@link ClassModel}. + *

+ * Due to the on-demand nature of {@code class} file parsing, an {@link + * IllegalArgumentException} may be thrown on any accessor method invocation + * on the returned model or any structure returned by the accessors in the + * structure hierarchy. + * + * @param bytes the bytes of the {@code class} file * @return the class model - * @throws IllegalArgumentException or its subclass if the classfile format is - * not supported or an incompatibility prevents parsing of the classfile + * @throws IllegalArgumentException if the {@code class} file is malformed + * or of a version {@linkplain #latestMajorVersion() not supported} + * by the current runtime */ ClassModel parse(byte[] bytes); /** - * Parse a classfile into a {@link ClassModel}. - * @param path the path to the classfile + * Parses a {@code class} into a {@link ClassModel}. + *

+ * Due to the on-demand nature of {@code class} file parsing, an {@link + * IllegalArgumentException} may be thrown on any accessor method invocation + * on the returned model or any structure returned by the accessors in the + * structure hierarchy. + * + * @param path the path to the {@code class} file * @return the class model - * @throws java.io.IOException if an I/O error occurs - * @throws IllegalArgumentException or its subclass if the classfile format is - * not supported or an incompatibility prevents parsing of the classfile + * @throws IOException if an I/O error occurs + * @throws IllegalArgumentException if the {@code class} file is malformed + * or of a version {@linkplain #latestMajorVersion() not supported} + * by the current runtime + * @see #parse(byte[]) */ default ClassModel parse(Path path) throws IOException { return parse(Files.readAllBytes(path)); } /** - * Build a classfile into a byte array. + * Builds a {@code class} file into a byte array. + * * @param thisClass the name of the class to build * @param handler a handler that receives a {@link ClassBuilder} - * @return the classfile bytes - * @throws IllegalArgumentException if {@code thisClass} represents a primitive type + * @return the {@code class} file bytes + * @throws IllegalArgumentException if {@code thisClass} represents a + * primitive type or building encounters a failure */ default byte[] build(ClassDesc thisClass, Consumer handler) { @@ -376,24 +559,27 @@ default byte[] build(ClassDesc thisClass, } /** - * Build a classfile into a byte array using the provided constant pool - * builder. + * Builds a {@code class} file into a byte array using the provided constant + * pool builder. * * @param thisClassEntry the name of the class to build * @param constantPool the constant pool builder * @param handler a handler that receives a {@link ClassBuilder} - * @return the classfile bytes + * @return the {@code class} file bytes + * @throws IllegalArgumentException if building encounters a failure */ byte[] build(ClassEntry thisClassEntry, ConstantPoolBuilder constantPool, Consumer handler); /** - * Build a classfile into a file. + * Builds a {@code class} file into a file in a file system. + * * @param path the path to the file to write * @param thisClass the name of the class to build * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs + * @throws IllegalArgumentException if building encounters a failure */ default void buildTo(Path path, ClassDesc thisClass, @@ -402,14 +588,15 @@ default void buildTo(Path path, } /** - * Build a classfile into a file using the provided constant pool - * builder. + * Builds a {@code class} file into a file in a file system using the + * provided constant pool builder. * * @param path the path to the file to write * @param thisClassEntry the name of the class to build * @param constantPool the constant pool builder * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs + * @throws IllegalArgumentException if building encounters a failure */ default void buildTo(Path path, ClassEntry thisClassEntry, @@ -419,22 +606,26 @@ default void buildTo(Path path, } /** - * Build a module descriptor into a byte array. + * Builds a module descriptor into a byte array. + * * @param moduleAttribute the {@code Module} attribute - * @return the classfile bytes + * @return the {@code class} file bytes + * @throws IllegalArgumentException if building encounters a failure */ default byte[] buildModule(ModuleAttribute moduleAttribute) { return buildModule(moduleAttribute, clb -> {}); } /** - * Build a module descriptor into a byte array. + * Builds a module descriptor into a byte array. + * * @param moduleAttribute the {@code Module} attribute * @param handler a handler that receives a {@link ClassBuilder} - * @return the classfile bytes + * @return the {@code class} file bytes + * @throws IllegalArgumentException if building encounters a failure */ default byte[] buildModule(ModuleAttribute moduleAttribute, - Consumer handler) { + Consumer handler) { return build(CD_module_info, clb -> { clb.withFlags(AccessFlag.MODULE); clb.with(moduleAttribute); @@ -443,10 +634,12 @@ default byte[] buildModule(ModuleAttribute moduleAttribute, } /** - * Build a module descriptor into a file. + * Builds a module descriptor into a file in a file system. + * * @param path the file to write * @param moduleAttribute the {@code Module} attribute - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs + * @throws IllegalArgumentException if building encounters a failure */ default void buildModuleTo(Path path, ModuleAttribute moduleAttribute) throws IOException { @@ -454,11 +647,13 @@ default void buildModuleTo(Path path, } /** - * Build a module descriptor into a file. + * Builds a module descriptor into a file in a file system. + * * @param path the file to write * @param moduleAttribute the {@code Module} attribute * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs + * @throws IllegalArgumentException if building encounters a failure */ default void buildModuleTo(Path path, ModuleAttribute moduleAttribute, @@ -467,257 +662,396 @@ default void buildModuleTo(Path path, } /** - * Transform one classfile into a new classfile with the aid of a - * {@link ClassTransform}. The transform will receive each element of + * Transform one {@code class} file into a new {@code class} file according + * to a {@link ClassTransform}. The transform will receive each element of * this class, as well as a {@link ClassBuilder} for building the new class. * The transform is free to preserve, remove, or replace elements as it * sees fit. - * - * @implNote + *

* This method behaves as if: * {@snippet lang=java : - * this.build(model.thisClass(), ConstantPoolBuilder.of(model), - * clb -> clb.transform(model, transform)); + * ConstantPoolBuilder cpb = null; // @replace substring=null; replacement=... + * this.build(model.thisClass(), cpb, + * clb -> clb.transform(model, transform)); * } + * where {@code cpb} is determined by {@link ConstantPoolSharingOption}. + * + * @apiNote + * This is named {@code transformClass} instead of {@code transform} for + * consistency with {@link ClassBuilder#transformField}, {@link + * ClassBuilder#transformMethod}, and {@link MethodBuilder#transformCode}, + * and to distinguish from {@link ClassFileBuilder#transform}, which is + * more generic and powerful. * * @param model the class model to transform * @param transform the transform * @return the bytes of the new class + * @throws IllegalArgumentException if building encounters a failure + * @see ConstantPoolSharingOption */ default byte[] transformClass(ClassModel model, ClassTransform transform) { return transformClass(model, model.thisClass(), transform); } /** - * Transform one classfile into a new classfile with the aid of a - * {@link ClassTransform}. The transform will receive each element of + * Transform one {@code class} file into a new {@code class} file according + * to a {@link ClassTransform}. The transform will receive each element of * this class, as well as a {@link ClassBuilder} for building the new class. * The transform is free to preserve, remove, or replace elements as it * sees fit. * + * @apiNote + * This is named {@code transformClass} instead of {@code transform} for + * consistency with {@link ClassBuilder#transformField}, {@link + * ClassBuilder#transformMethod}, and {@link MethodBuilder#transformCode}, + * and to distinguish from {@link ClassFileBuilder#transform}, which is + * more generic and powerful. + * * @param model the class model to transform * @param newClassName new class name * @param transform the transform * @return the bytes of the new class + * @throws IllegalArgumentException if building encounters a failure + * @see ConstantPoolSharingOption */ default byte[] transformClass(ClassModel model, ClassDesc newClassName, ClassTransform transform) { return transformClass(model, TemporaryConstantPool.INSTANCE.classEntry(newClassName), transform); } /** - * Transform one classfile into a new classfile with the aid of a - * {@link ClassTransform}. The transform will receive each element of + * Transform one {@code class} file into a new {@code class} file according + * to a {@link ClassTransform}. The transform will receive each element of * this class, as well as a {@link ClassBuilder} for building the new class. * The transform is free to preserve, remove, or replace elements as it * sees fit. - * - * @implNote + *

* This method behaves as if: * {@snippet lang=java : - * this.build(newClassName, ConstantPoolBuilder.of(model), - * clb -> clb.transform(model, transform)); + * ConstantPoolBuilder cpb = null; // @replace substring=null; replacement=... + * this.build(newClassName, cpb, clb -> clb.transform(model, transform)); * } + * where {@code cpb} is determined by {@link ConstantPoolSharingOption}. + * + * @apiNote + * This is named {@code transformClass} instead of {@code transform} for + * consistency with {@link ClassBuilder#transformField}, {@link + * ClassBuilder#transformMethod}, and {@link MethodBuilder#transformCode}, + * and to distinguish from {@link ClassFileBuilder#transform}, which is + * more generic and powerful. * * @param model the class model to transform * @param newClassName new class name * @param transform the transform * @return the bytes of the new class + * @throws IllegalArgumentException if building encounters a failure + * @see ConstantPoolSharingOption */ byte[] transformClass(ClassModel model, ClassEntry newClassName, ClassTransform transform); /** - * Verify a classfile. Any verification errors found will be returned. + * Verify a {@code class} file. All verification errors found will be returned. + * * @param model the class model to verify - * @return a list of verification errors, or an empty list if no errors are + * @return a list of verification errors, or an empty list if no error is * found */ List verify(ClassModel model); /** - * Verify a classfile. Any verification errors found will be returned. - * @param bytes the classfile bytes to verify - * @return a list of verification errors, or an empty list if no errors are + * Verify a {@code class} file. All verification errors found will be returned. + * + * @param bytes the {@code class} file bytes to verify + * @return a list of verification errors, or an empty list if no error is * found */ List verify(byte[] bytes); /** - * Verify a classfile. Any verification errors found will be returned. - * @param path the classfile path to verify - * @return a list of verification errors, or an empty list if no errors are + * Verify a {@code class} file. All verification errors found will be returned. + * + * @param path the {@code class} file path to verify + * @return a list of verification errors, or an empty list if no error is * found - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs */ default List verify(Path path) throws IOException { return verify(Files.readAllBytes(path)); } - /** 0xCAFEBABE */ + /** + * The magic number identifying the {@code class} file format, {@value + * "0x%04x" #MAGIC_NUMBER}. It is a big-endian 4-byte value. + */ int MAGIC_NUMBER = 0xCAFEBABE; - /** The bit mask of PUBLIC access and property modifier. */ + /** The bit mask of {@link AccessFlag#PUBLIC} access and property modifier. */ int ACC_PUBLIC = 0x0001; - /** The bit mask of PROTECTED access and property modifier. */ + /** The bit mask of {@link AccessFlag#PROTECTED} access and property modifier. */ int ACC_PROTECTED = 0x0004; - /** The bit mask of PRIVATE access and property modifier. */ + /** The bit mask of {@link AccessFlag#PRIVATE} access and property modifier. */ int ACC_PRIVATE = 0x0002; - /** The bit mask of INTERFACE access and property modifier. */ + /** The bit mask of {@link AccessFlag#INTERFACE} access and property modifier. */ int ACC_INTERFACE = 0x0200; - /** The bit mask of ENUM access and property modifier. */ + /** The bit mask of {@link AccessFlag#ENUM} access and property modifier. */ int ACC_ENUM = 0x4000; - /** The bit mask of ANNOTATION access and property modifier. */ + /** The bit mask of {@link AccessFlag#ANNOTATION} access and property modifier. */ int ACC_ANNOTATION = 0x2000; - /** The bit mask of SUPER access and property modifier. */ + /** The bit mask of {@link AccessFlag#SUPER} access and property modifier. */ int ACC_SUPER = 0x0020; - /** The bit mask of ABSTRACT access and property modifier. */ + /** The bit mask of {@link AccessFlag#ABSTRACT} access and property modifier. */ int ACC_ABSTRACT = 0x0400; - /** The bit mask of VOLATILE access and property modifier. */ + /** The bit mask of {@link AccessFlag#VOLATILE} access and property modifier. */ int ACC_VOLATILE = 0x0040; - /** The bit mask of TRANSIENT access and property modifier. */ + /** The bit mask of {@link AccessFlag#TRANSIENT} access and property modifier. */ int ACC_TRANSIENT = 0x0080; - /** The bit mask of SYNTHETIC access and property modifier. */ + /** The bit mask of {@link AccessFlag#SYNTHETIC} access and property modifier. */ int ACC_SYNTHETIC = 0x1000; - /** The bit mask of STATIC access and property modifier. */ + /** The bit mask of {@link AccessFlag#STATIC} access and property modifier. */ int ACC_STATIC = 0x0008; - /** The bit mask of FINAL access and property modifier. */ + /** The bit mask of {@link AccessFlag#FINAL} access and property modifier. */ int ACC_FINAL = 0x0010; - /** The bit mask of SYNCHRONIZED access and property modifier. */ + /** The bit mask of {@link AccessFlag#SYNCHRONIZED} access and property modifier. */ int ACC_SYNCHRONIZED = 0x0020; - /** The bit mask of BRIDGE access and property modifier. */ + /** The bit mask of {@link AccessFlag#BRIDGE} access and property modifier. */ int ACC_BRIDGE = 0x0040; - /** The bit mask of VARARGS access and property modifier. */ + /** The bit mask of {@link AccessFlag#VARARGS} access and property modifier. */ int ACC_VARARGS = 0x0080; - /** The bit mask of NATIVE access and property modifier. */ + /** The bit mask of {@link AccessFlag#NATIVE} access and property modifier. */ int ACC_NATIVE = 0x0100; - /** The bit mask of STRICT access and property modifier. */ + /** The bit mask of {@link AccessFlag#STRICT} access and property modifier. */ int ACC_STRICT = 0x0800; - /** The bit mask of MODULE access and property modifier. */ + /** The bit mask of {@link AccessFlag#MODULE} access and property modifier. */ int ACC_MODULE = 0x8000; - /** The bit mask of OPEN access and property modifier. */ + /** The bit mask of {@link AccessFlag#OPEN} access and property modifier. */ int ACC_OPEN = 0x20; - /** The bit mask of MANDATED access and property modifier. */ + /** The bit mask of {@link AccessFlag#MANDATED} access and property modifier. */ int ACC_MANDATED = 0x8000; - /** The bit mask of TRANSITIVE access and property modifier. */ + /** The bit mask of {@link AccessFlag#TRANSITIVE} access and property modifier. */ int ACC_TRANSITIVE = 0x20; - /** The bit mask of STATIC_PHASE access and property modifier. */ + /** The bit mask of {@link AccessFlag#STATIC_PHASE} access and property modifier. */ int ACC_STATIC_PHASE = 0x40; - /** The class major version of JAVA_1. */ + /** + * The class major version of the initial version of Java, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_0 + * @see ClassFileFormatVersion#RELEASE_1 + */ int JAVA_1_VERSION = 45; - /** The class major version of JAVA_2. */ + /** + * The class major version introduced by Java 2 SE 1.2, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_2 + */ int JAVA_2_VERSION = 46; - /** The class major version of JAVA_3. */ + /** + * The class major version introduced by Java 2 SE 1.3, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_3 + */ int JAVA_3_VERSION = 47; - /** The class major version of JAVA_4. */ + /** + * The class major version introduced by Java 2 SE 1.4, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_4 + */ int JAVA_4_VERSION = 48; - /** The class major version of JAVA_5. */ + /** + * The class major version introduced by Java 2 SE 5.0, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_5 + */ int JAVA_5_VERSION = 49; - /** The class major version of JAVA_6. */ + /** + * The class major version introduced by Java SE 6, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_6 + */ int JAVA_6_VERSION = 50; - /** The class major version of JAVA_7. */ + /** + * The class major version introduced by Java SE 7, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_7 + */ int JAVA_7_VERSION = 51; - /** The class major version of JAVA_8. */ + /** + * The class major version introduced by Java SE 8, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_8 + */ int JAVA_8_VERSION = 52; - /** The class major version of JAVA_9. */ + /** + * The class major version introduced by Java SE 9, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_9 + */ int JAVA_9_VERSION = 53; - /** The class major version of JAVA_10. */ + /** + * The class major version introduced by Java SE 10, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_10 + */ int JAVA_10_VERSION = 54; - /** The class major version of JAVA_11. */ + /** + * The class major version introduced by Java SE 11, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_11 + */ int JAVA_11_VERSION = 55; - /** The class major version of JAVA_12. */ + /** + * The class major version introduced by Java SE 12, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_12 + */ int JAVA_12_VERSION = 56; - /** The class major version of JAVA_13. */ + /** + * The class major version introduced by Java SE 13, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_13 + */ int JAVA_13_VERSION = 57; - /** The class major version of JAVA_14. */ + /** + * The class major version introduced by Java SE 14, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_14 + */ int JAVA_14_VERSION = 58; - /** The class major version of JAVA_15. */ + /** + * The class major version introduced by Java SE 15, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_15 + */ int JAVA_15_VERSION = 59; - /** The class major version of JAVA_16. */ + /** + * The class major version introduced by Java SE 16, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_16 + */ int JAVA_16_VERSION = 60; - /** The class major version of JAVA_17. */ + /** + * The class major version introduced by Java SE 17, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_17 + */ int JAVA_17_VERSION = 61; - /** The class major version of JAVA_18. */ + /** + * The class major version introduced by Java SE 18, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_18 + */ int JAVA_18_VERSION = 62; - /** The class major version of JAVA_19. */ + /** + * The class major version introduced by Java SE 19, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_19 + */ int JAVA_19_VERSION = 63; - /** The class major version of JAVA_20. */ + /** + * The class major version introduced by Java SE 20, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_20 + */ int JAVA_20_VERSION = 64; - /** The class major version of JAVA_21. */ + /** + * The class major version introduced by Java SE 21, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_21 + */ int JAVA_21_VERSION = 65; - /** The class major version of JAVA_22. */ + /** + * The class major version introduced by Java SE 22, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_22 + */ int JAVA_22_VERSION = 66; - /** The class major version of JAVA_23. */ + /** + * The class major version introduced by Java SE 23, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_23 + */ int JAVA_23_VERSION = 67; - /** The class major version of JAVA_24. */ + /** + * The class major version introduced by Java SE 24, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_24 + */ int JAVA_24_VERSION = 68; /** - * The class major version of JAVA_25. + * The class major version introduced by Java SE 25, {@value}. + * + * @see ClassFileFormatVersion#RELEASE_25 * @since 25 */ int JAVA_25_VERSION = 69; /** - * A minor version number indicating a class uses preview features - * of a Java SE version since 12, for major versions {@value + * A minor version number {@value} indicating a class uses preview features + * of a Java SE release since 12, for major versions {@value * #JAVA_12_VERSION} and above. */ int PREVIEW_MINOR_VERSION = 65535; /** - * {@return the latest major Java version} + * {@return the latest class major version supported by the current runtime} */ static int latestMajorVersion() { return JAVA_25_VERSION; } /** - * {@return the latest minor Java version} + * {@return the latest class minor version supported by the current runtime} + * + * @apiNote + * This does not report the {@link #PREVIEW_MINOR_VERSION} when the current + * runtime has preview feature enabled, as {@code class} files with a major + * version other than {@link #latestMajorVersion()} and the preview minor + * version are not supported. */ static int latestMinorVersion() { return 0; diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java b/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java index 01eeefd0b9b1a..172daa83cf862 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,17 +31,36 @@ import jdk.internal.classfile.impl.TransformImpl; /** - * A builder for a classfile or portion of a classfile. Builders are rarely - * created directly; they are passed to handlers by methods such as - * {@link ClassFile#build(ClassDesc, Consumer)} or to transforms. - * Elements of the newly built entity can be specified - * abstractly (by passing a {@link ClassFileElement} to {@link #with(ClassFileElement)} - * or concretely by calling the various {@code withXxx} methods. + * A builder for a {@link CompoundElement}, which accepts the member elements + * to be integrated into the built structure. Builders are usually passed as + * an argument to {@link Consumer} handlers, such as in {@link + * ClassFile#build(ClassDesc, Consumer)}. The handlers should deliver elements + * to a builder similar to how a {@link CompoundElement} traverses its member + * elements. + *

+ * The basic way a builder accepts elements is through {@link #with}, which + * supports call chaining. Concrete subtypes of builders usually define extra + * methods to define elements directly to the builder, such as {@link + * ClassBuilder#withFlags(int)} or {@link CodeBuilder#aload(int)}. + *

+ * Whether a member element can appear multiple times in a compound structure + * affects the behavior of the element in {@code ClassFileBuilder}s. If an + * element can appear at most once but multiple instances are supplied to a + * {@code ClassFileBuilder}, the last supplied instance appears on the built + * structure. If an element appears exactly once but no instance is supplied, + * an unspecified default value element may be used in that structure. + *

+ * Due to restrictions of the {@code class} file format, certain member elements + * that can be modeled by the API cannot be represented in the built structure + * under specific circumstances. Passing such elements to the builder causes + * {@link IllegalArgumentException}. Some {@link ClassFile.Option}s control + * whether such elements should be altered or dropped to produce valid {@code + * class} files. * - * @param the element type - * @param the builder type + * @param the member element type + * @param the self type of this builder + * @see CompoundElement * @see ClassFileTransform - * * @sealedGraph * @since 24 */ @@ -49,8 +68,15 @@ public sealed interface ClassFileBuilder permits ClassBuilder, FieldBuilder, MethodBuilder, CodeBuilder { /** - * Integrate the {@link ClassFileElement} into the entity being built. - * @param e the element + * Integrates the member element into the structure being built. + * + * @apiNote + * This method exists to implement {@link Consumer}; users can use {@link + * #with} for call chaining. + * + * @param e the member element + * @throws IllegalArgumentException if the member element cannot be + * represented in the {@code class} file format */ @Override default void accept(E e) { @@ -58,9 +84,12 @@ default void accept(E e) { } /** - * Integrate the {@link ClassFileElement} into the entity being built. - * @param e the element + * Integrates the member element into the structure being built. + * + * @param e the member element * @return this builder + * @throws IllegalArgumentException if the member element cannot be + * represented in the {@code class} file format */ B with(E e); @@ -70,10 +99,29 @@ default void accept(E e) { ConstantPoolBuilder constantPool(); /** - * Apply a transform to a model, directing results to this builder. - * @param model the model to transform + * Applies a transform to a compound structure, directing results to this + * builder. + *

+ * The transform will receive each element of the compound structure, as + * well as this builder for building the structure. The transform is free + * to preserve, remove, or replace elements as it sees fit. + *

+ * A builder can run multiple transforms against different compound + * structures, integrating member elements of different origins. + * + * @apiNote + * Many subinterfaces have methods like {@link ClassBuilder#transformMethod} + * or {@link MethodBuilder#transformCode}. However, calling them is + * fundamentally different from calling this method: those methods call the + * {@code transform} on the child builders instead of on itself. For + * example, {@code classBuilder.transformMethod} calls {@code + * methodBuilder.transform} with a new method builder instead of calling + * {@code classBuilder.transform} on itself. + * + * @param model the structure to transform * @param transform the transform to apply * @return this builder + * @see ClassFileTransform */ default B transform(CompoundElement model, ClassFileTransform transform) { @SuppressWarnings("unchecked") diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java b/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java index ed84eb39d53b8..5d5d00209498c 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,34 @@ package java.lang.classfile; /** - * Immutable model for a portion of (or the entirety of) a classfile. Elements - * that model parts of the classfile that have attributes will implement {@link - * AttributedElement}; elements that model complex parts of the classfile that - * themselves contain their own child elements will implement {@link - * CompoundElement}. Elements specific to various locations in the classfile - * will implement {@link ClassElement}, {@link MethodElement}, etc. + * Marker interface for structures with special capabilities in the {@code + * class} file format. {@link AttributedElement} indicates a structure has + * {@link Attribute}s. {@link CompoundElement} indicates a structure can be + * viewed as a composition of member structures, whose memberships are marked by + * {@link ClassElement}, {@link MethodElement}, {@link FieldElement}, or {@link + * CodeElement}. + * + *

Membership Elements

+ * {@link ClassModel}, {@link MethodModel}, {@link FieldModel}, and {@link + * CodeModel} each has a dedicated interface marking its member structures: + * {@link ClassElement}, {@link MethodElement}, {@link FieldElement}, and + * {@link CodeElement}. They can be supplied to a {@link ClassBuilder}, a + * {@link MethodBuilder}, a {@link FieldBuilder}, or a {@link CodeBuilder} to be + * included as members of the built model. Unless otherwise specified, these + * structures are delivered during the {@linkplain CompoundElement traversal} of + * the corresponding models. Some of these elements may appear at most once or + * exactly once in the traversal of the models; such elements have special + * treatment by {@link ClassFileBuilder} and are specified in their modeling + * interfaces. If such elements appear multiple times during traversal, the + * last occurrence should be used and all previous instances should be + * discarded. + *

+ * These membership element marker interfaces are sealed; future versions of the + * Java SE Platform may define new elements to the sealed hierarchy when the + * {@code class} file format for the Java Platform evolves. Using an exhaustive + * pattern matching switch over these hierarchies indicates the user only wish + * the processing code to run on a specific version of Java Platform, and will + * fail if unknown new elements are encountered. * * @sealedGraph * @since 24 diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java b/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java index 7d9385eed6898..9126b13bce942 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,44 +25,74 @@ package java.lang.classfile; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.util.function.Predicate; import java.util.function.Supplier; /** - * A transformation on streams of elements. Transforms are used during - * transformation of classfile entities; a transform is provided to a method like - * {@link ClassFile#transformClass(ClassModel, ClassTransform)}, and the elements of the class, - * along with a builder, are presented to the transform. - * - *

The subtypes of {@linkplain - * ClassFileTransform} (e.g., {@link ClassTransform}) are functional interfaces - * that accept an element and a corresponding builder. Since any element can be - * reproduced on the builder via {@link ClassBuilder#with(ClassFileElement)}, a - * transform can easily leave elements in place, remove them, replace them, or - * augment them with other elements. This enables localized transforms to be - * represented concisely. - * - *

Transforms also have an {@link #atEnd(ClassFileBuilder)} method, for - * which the default implementation does nothing, so that a transform can - * perform additional building after the stream of elements is exhausted. - * - *

Transforms can be chained together via the {@link - * #andThen(ClassFileTransform)} method, so that the output of one becomes the - * input to another. This allows smaller units of transformation to be captured - * and reused. - * - *

Some transforms are stateful; for example, a transform that injects an - * annotation on a class may watch for the {@link RuntimeVisibleAnnotationsAttribute} - * element and transform it if found, but if it is not found, will generate a - * {@linkplain RuntimeVisibleAnnotationsAttribute} element containing the - * injected annotation from the {@linkplain #atEnd(ClassFileBuilder)} handler. - * To do this, the transform must accumulate some state during the traversal so - * that the end handler knows what to do. If such a transform is to be reused, - * its state must be reset for each traversal; this will happen automatically if - * the transform is created with {@link ClassTransform#ofStateful(Supplier)} (or - * corresponding methods for other classfile locations.) + * A transformation on a {@link CompoundElement} by processing its individual + * member elements and sending the results to a {@link ClassFileBuilder}, + * through {@link ClassFileBuilder#transform}. A subtype of {@code + * ClassFileTransform} is defined for each subtype of {@link CompoundElement} + * and {@link ClassFileBuilder}, as shown in the sealed class hierarchy below. + *

+ * For example, this is a basic transformation of a {@link CodeModel} that + * redirects all calls to static methods in the {@code Foo} class to the {@code + * Bar} class, preserving all other elements: + * {@snippet file="PackageSnippets.java" region=fooToBarTransform} + * Note that if no transformation of a member element is desired, the element + * should be presented to {@link ClassFileBuilder#with builder::with}. If no + * action is taken, that member element is dropped. + *

+ * More advanced usages of transforms include {@linkplain ##start-end start or + * end handling}, {@linkplain ##stateful stateful transformation} that makes a + * decision based on previously encountered member elements, and {@linkplain + * ##composition composition} of transforms, where one transform processes the + * results of a previous transform on the input compound structure. All these + * capabilities are supported by this interface and accessible to user transform + * implementations. + *

+ * Users can define custom start and end handling for a transform by overriding + * {@link #atStart} and {@link #atEnd}. The start handler is called before any + * member element is processed, and the end handler is called after all member + * elements are processed. For example, the start handler can be used to inject + * extra code elements to the beginning of a code array, and the end handler, + * combined with stateful transformation, can perform cleanup actions, such as + * determining if an attribute has been merged, or if a new attribute should be + * defined. Each subtype of {@code ClassFileTransform} defines a utility method + * {@code endHandler} that returns a transform that only has end handling. + *

+ * Transforms can have states that persist across processing of individual + * member elements. For example, if a transform injects an annotation, the + * transform may keep track if it has encountered and presented an updated + * {@link RuntimeVisibleAnnotationsAttribute} to the builder; if it has not yet, + * it can present a new attribute containing only the injected annotation in its + * end handler. If such a transform is to be shared or reused, each returned + * transform should have its own state. Each subtype of {@code ClassFileTransform} + * defines a utility method {@code ofStateful} where a supplier creates the + * transform at its initial state each time the transform is reused. + *

+ * Transforms can be composed via {@link #andThen}. When this transform is + * composed with another transform, it means the output member elements received + * by the {@link ClassFileBuilder} become the input elements to that other + * transform. Composition avoids building intermediate structures for multiple + * transforms to run on. Each subtype of {@code ClassFileTransform} implements + * {@link #andThen}, which generally should not be implemented by users. + *

+ * Transforms that run on smaller structures can be lifted to its enclosing + * structures to selectively run on all enclosed smaller structures of the same + * kind. For example, a {@link CodeTransform} can be lifted via {@link + * ClassTransform#transformingMethodBodies(Predicate, CodeTransform)} to + * transform the method body of select methods in the class it runs on. This + * allows users to write small transforms and apply to larger scales. + *

+ * Besides {@link ClassFileBuilder#transform}, there are other methods that + * accepts a transform conveniently, such as {@link ClassFile#transformClass}, + * {@link ClassBuilder#transformField}, {@link ClassBuilder#transformMethod}, or + * {@link MethodBuilder#transformCode}. They are convenience methods that suit + * the majority of transformation scenarios. * * @param the transform type - * @param the element type + * @param the member element type * @param the builder type * * @sealedGraph @@ -79,6 +109,9 @@ public sealed interface ClassFileTransform< * body.) If no transformation is desired, the element can be presented to * {@link B#with(ClassFileElement)}. If the element is to be dropped, no * action is required. + *

+ * This method is called by the Class-File API. Users should never call + * this method. * * @param builder the builder for the new entity * @param element the element @@ -89,6 +122,9 @@ public sealed interface ClassFileTransform< * Take any final action during transformation of a classfile entity. Called * after all elements of the class are presented to {@link * #accept(ClassFileBuilder, ClassFileElement)}. + *

+ * This method is called by the Class-File API. Users should never call + * this method. * * @param builder the builder for the new entity * @implSpec The default implementation does nothing. @@ -100,6 +136,9 @@ default void atEnd(B builder) { * Take any preliminary action during transformation of a classfile entity. * Called before any elements of the class are presented to {@link * #accept(ClassFileBuilder, ClassFileElement)}. + *

+ * This method is called by the Class-File API. Users should never call + * this method. * * @param builder the builder for the new entity * @implSpec The default implementation does nothing. @@ -110,6 +149,10 @@ default void atStart(B builder) { /** * Chain this transform with another; elements presented to the builder of * this transform will become the input to the next transform. + *

+ * This method is implemented by the Class-File API. Users usually don't + * have sufficient access to Class-File API functionalities to override this + * method correctly for generic downstream transforms. * * @param next the downstream transform * @return the chained transform diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java b/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java index 1916a185cc863..5a795b9486533 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,32 +24,62 @@ */ package java.lang.classfile; +import java.lang.reflect.ClassFileFormatVersion; + import jdk.internal.classfile.impl.ClassFileVersionImpl; /** - * Models the classfile version information for a class. Delivered as a {@link - * java.lang.classfile.ClassElement} when traversing the elements of a {@link - * ClassModel}. + * Models the minor and major version numbers of a {@code class} file (JVMS + * {@jvms 4.1}). The {@code class} file version appears exactly once in each + * class, and is set to an unspecified default value if not explicitly provided. + *

+ * The major versions of {@code class} file format begins at {@value + * ClassFile#JAVA_1_VERSION} for Java Platform version 1.0.2, and is continuous + * up to {@link ClassFile#latestMajorVersion()}. In general, each major version + * defines a new supported {@code class} file format, modeled by {@link + * ClassFileFormatVersion}, and supports all previous formats. + *

+ * For major versions up to {@value ClassFile#JAVA_11_VERSION} for Java SE + * Platform 11, the minor version of any value is supported. For major versions + * {@value ClassFile#JAVA_12_VERSION} for Java SE Platform version 12 and above, + * the minor version must be {@code 0} or {@value ClassFile#PREVIEW_MINOR_VERSION}. + * The minor version {@code 0} is always supported, and represents the format + * modeled by {@link ClassFileFormatVersion}. The minor version {@code 65535} + * indicates the {@code class} file uses preview features of the Java SE + * Platform release represented by the major version. A Java Virtual Machine + * can only load such a {@code class} file if it has the same Java SE Platform + * version and the JVM has preview features enabled. * + * @see ClassModel#majorVersion() + * @see ClassModel#minorVersion() + * @see ClassFileFormatVersion + * @jvms 4.1 The {@code ClassFile} Structure * @since 24 */ public sealed interface ClassFileVersion extends ClassElement permits ClassFileVersionImpl { /** - * {@return the major classfile version} + * {@return the major version} It is in the range of unsigned short, {@code + * [0, 65535]}. + * + * @apiNote + * Constants in {@link ClassFile} named {@code Java_#_VERSION}, where # is + * a release number, such as {@link ClassFile#JAVA_21_VERSION}, describe the + * class major versions of the Java Platform SE. */ int majorVersion(); /** - * {@return the minor classfile version} + * {@return the minor version} It is in the range of unsigned short, {@code + * [0, 65535]}. */ int minorVersion(); /** * {@return a {@link ClassFileVersion} element} - * @param majorVersion the major classfile version - * @param minorVersion the minor classfile version + * @param majorVersion the major version + * @param minorVersion the minor version */ static ClassFileVersion of(int majorVersion, int minorVersion) { return new ClassFileVersionImpl(majorVersion, minorVersion); diff --git a/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java index 2c612854a64d2..3bc56b43b7b1b 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,11 @@ */ package java.lang.classfile; +import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; +import java.lang.classfile.ClassFile.StackMapsOption; +import java.lang.classfile.attribute.StackMapTableAttribute; import java.lang.constant.ClassDesc; import java.lang.invoke.MethodHandles; import java.util.Collection; @@ -42,27 +46,42 @@ import static java.util.Objects.requireNonNull; /** - * Provides class hierarchy information for generating correct stack maps - * during code building. + * Provides class hierarchy information for {@linkplain StackMapsOption stack + * maps generation} and {@linkplain ClassFile#verify(byte[]) verification}. + * A class hierarchy resolver must be able to process all classes and interfaces + * encountered during these workloads. * + * @see ClassFile.ClassHierarchyResolverOption + * @see StackMapTableAttribute + * @jvms 4.10.1.2 Verification Type System * @since 24 */ @FunctionalInterface public interface ClassHierarchyResolver { /** - * {@return the default instance of {@linkplain ClassHierarchyResolver} that + * {@return the default instance of {@code ClassHierarchyResolver} that * gets {@link ClassHierarchyInfo} from system class loader with reflection} + * This default instance cannot load classes from other class loaders, such + * as the caller's class loader; it also loads the system classes if they + * are not yet loaded, which makes it unsuitable for instrumentation. */ static ClassHierarchyResolver defaultResolver() { return ClassHierarchyImpl.DEFAULT_RESOLVER; } /** - * {@return the {@link ClassHierarchyInfo} for a given class name, or null - * if the name is unknown to the resolver} + * {@return the {@code ClassHierarchyInfo} for a given class name, or {@code + * null} if the name is unknown to the resolver} + *

+ * This method is called by the Class-File API to obtain the hierarchy + * information of a class or interface; users should not call this method. + * The symbolic descriptor passed by the Class-File API always represents + * a class or interface. + * * @param classDesc descriptor of the class - * @throws IllegalArgumentException if a class shouldn't be queried for hierarchy + * @throws IllegalArgumentException if a class shouldn't be queried for + * hierarchy, such as when it is inaccessible */ ClassHierarchyInfo getClassInfo(ClassDesc classDesc); @@ -78,6 +97,7 @@ sealed interface ClassHierarchyInfo permits ClassHierarchyImpl.ClassHierarchyInf * * @param superClass descriptor of the super class, may be {@code null} * @return the info indicating the super class + * @see Superclass */ static ClassHierarchyInfo ofClass(ClassDesc superClass) { return new ClassHierarchyImpl.ClassHierarchyInfoImpl(superClass, false); @@ -94,14 +114,15 @@ static ClassHierarchyInfo ofInterface() { } /** - * Chains this {@linkplain ClassHierarchyResolver} with another to be - * consulted if this resolver does not know about the specified class. + * Chains this {@code ClassHierarchyResolver} with another to be consulted + * if this resolver does not know about the specified class. + * + * @implSpec + * The default implementation returns resolver implemented to query {@code + * other} resolver in case this resolver returns {@code null}. * * @param other the other resolver * @return the chained resolver - * - * @implSpec The default implementation returns resolver implemented to ask - * other resolver in cases where this resolver returns {@code null}. */ default ClassHierarchyResolver orElse(ClassHierarchyResolver other) { requireNonNull(other); @@ -117,32 +138,32 @@ public ClassHierarchyInfo getClassInfo(ClassDesc classDesc) { } /** - * Returns a ClassHierarchyResolver that caches class hierarchy information from this - * resolver. The returned resolver will not update if delegate resolver returns differently. - * The thread safety of the returned resolver depends on the thread safety of the map + * {@return a {@code ClassHierarchyResolver} that caches class hierarchy + * information from this resolver} The returned resolver will not update if + * the query results from this resolver changed over time. The thread + * safety of the returned resolver depends on the thread safety of the map * returned by the {@code cacheFactory}. * - * @param cacheFactory the factory for the cache - * @return the ClassHierarchyResolver with caching + * @implSpec + * The default implementation returns a resolver holding an instance of the + * cache map provided by the {@code cacheFactory}. It looks up in the cache + * map, or if a class name has not yet been queried, queries this resolver + * and caches the result, including a {@code null} that indicates unknown + * class names. The cache map may refuse {@code null} keys and values. * - * @implSpec The default implementation returns resolver holding an instance - * of the cache map provided by the {@code cacheFactory}. It asks - * the cache map always first and fills the cache map with all - * resolved and also unresolved class info. The cache map may refuse - * {@code null} keys and values. + * @param cacheFactory the factory for the cache */ default ClassHierarchyResolver cached(Supplier> cacheFactory) { return new ClassHierarchyImpl.CachedClassHierarchyResolver(this, cacheFactory.get()); } /** - * Returns a ClassHierarchyResolver that caches class hierarchy information from this - * resolver. The returned resolver will not update if delegate resolver returns differently. - * The returned resolver is not thread-safe. + * {@return a {@code ClassHierarchyResolver} that caches class hierarchy + * information from this resolver} The returned resolver will not update if + * the query results from this resolver changed over time. The returned + * resolver is not thread-safe. * {@snippet file="PackageSnippets.java" region="lookup-class-hierarchy-resolver"} * - * @return the ClassHierarchyResolver - * * @implSpec The default implementation calls {@link #cached(Supplier)} with * {@link HashMap} supplier as {@code cacheFactory}. */ @@ -160,24 +181,24 @@ public Map get() { } /** - * Returns a {@linkplain ClassHierarchyResolver} that extracts class hierarchy - * information from classfiles located by a mapping function. The mapping function - * should return null if it cannot provide a mapping for a classfile. Any IOException - * from the provided input stream is rethrown as an UncheckedIOException. + * {@return a {@code ClassHierarchyResolver} that extracts class hierarchy + * information from {@code class} files returned by a mapping function} The + * mapping function should return {@code null} if it cannot provide a + * {@code class} file for a class name. Any {@link IOException} from the + * provided input stream is rethrown as an {@link UncheckedIOException} + * in {@link #getClassInfo(ClassDesc)}. * - * @param classStreamResolver maps class descriptors to classfile input streams - * @return the {@linkplain ClassHierarchyResolver} + * @param classStreamResolver maps class descriptors to {@code class} file input streams */ static ClassHierarchyResolver ofResourceParsing(Function classStreamResolver) { return new ClassHierarchyImpl.ResourceParsingClassHierarchyResolver(requireNonNull(classStreamResolver)); } /** - * Returns a {@linkplain ClassHierarchyResolver} that extracts class hierarchy - * information from classfiles located by a class loader. + * {@return a {@code ClassHierarchyResolver} that extracts class hierarchy + * information from {@code class} files located by a class loader} * * @param loader the class loader, to find class files - * @return the {@linkplain ClassHierarchyResolver} */ static ClassHierarchyResolver ofResourceParsing(ClassLoader loader) { requireNonNull(loader); @@ -190,24 +211,22 @@ public InputStream apply(ClassDesc classDesc) { } /** - * Returns a {@linkplain ClassHierarchyResolver} that extracts class hierarchy - * information from collections of class hierarchy metadata + * {@return a {@code ClassHierarchyResolver} that extracts class hierarchy + * information from collections of class hierarchy metadata} * * @param interfaces a collection of classes known to be interfaces * @param classToSuperClass a map from classes to their super classes - * @return the {@linkplain ClassHierarchyResolver} */ static ClassHierarchyResolver of(Collection interfaces, - Map classToSuperClass) { + Map classToSuperClass) { return new StaticClassHierarchyResolver(interfaces, classToSuperClass); } /** - * Returns a ClassHierarchyResolver that extracts class hierarchy information via - * the Reflection API with a {@linkplain ClassLoader}. + * {@return a {@code ClassHierarchyResolver} that extracts class hierarchy + * information via classes loaded by a class loader with reflection} * * @param loader the class loader - * @return the class hierarchy resolver */ static ClassHierarchyResolver ofClassLoading(ClassLoader loader) { requireNonNull(loader); @@ -224,13 +243,13 @@ public Class apply(ClassDesc cd) { } /** - * Returns a ClassHierarchyResolver that extracts class hierarchy information via - * the Reflection API with a {@linkplain MethodHandles.Lookup Lookup}. If the class - * resolved is inaccessible to the given lookup, it throws {@link + * {@return a {@code ClassHierarchyResolver} that extracts class hierarchy + * information via classes accessible to a {@link MethodHandles.Lookup} + * with reflection} If the class resolved is inaccessible to the given + * lookup, {@link #getClassInfo(ClassDesc)} throws {@link * IllegalArgumentException} instead of returning {@code null}. * * @param lookup the lookup, must be able to access classes to resolve - * @return the class hierarchy resolver */ static ClassHierarchyResolver ofClassLoading(MethodHandles.Lookup lookup) { requireNonNull(lookup); diff --git a/src/java.base/share/classes/java/lang/classfile/ClassModel.java b/src/java.base/share/classes/java/lang/classfile/ClassModel.java index db804348cfe9e..2c547e6336df0 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassModel.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,18 +25,41 @@ package java.lang.classfile; +import java.lang.classfile.attribute.BootstrapMethodsAttribute; +import java.lang.classfile.attribute.ModuleAttribute; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.constant.ClassDesc; +import java.lang.reflect.AccessFlag; import java.util.List; import java.util.Optional; +import java.util.function.Consumer; import jdk.internal.classfile.impl.ClassImpl; /** - * Models a classfile. The contents of the classfile can be traversed via - * a streaming view, or via random access (e.g., - * {@link #flags()}), or by freely mixing the two. + * Models a {@code class} file. A {@code class} file can be viewed as a + * {@linkplain CompoundElement composition} of {@link ClassElement}s, or by + * random access via accessor methods if only specific parts of the {@code + * class} file is needed. + *

+ * Use {@link ClassFile#parse(byte[])}, which parses the binary data of a {@code + * class} file into a model, to obtain a {@code ClassModel}. + *

+ * To construct a {@code class} file, use {@link ClassFile#build(ClassDesc, + * Consumer)}. {@link ClassFile#transformClass(ClassModel, ClassTransform)} + * allows creating a new class by selectively processing the original class + * elements and directing the results to a class builder. + *

+ * A class holds attributes, most of which are accessible as member elements. + * {@link BootstrapMethodsAttribute} can only be accessed via {@linkplain + * AttributedElement explicit attribute reading}, as it is modeled as part of + * the {@linkplain #constantPool() constant pool}. * + * @see ClassFile#parse(byte[]) + * @see ClassTransform + * @jvms 4.1 The {@code ClassFile} Structure * @since 24 */ public sealed interface ClassModel @@ -45,19 +68,35 @@ public sealed interface ClassModel /** * {@return the constant pool for this class} + * + * @see ConstantPoolBuilder#of(ClassModel) */ ConstantPool constantPool(); - /** {@return the access flags} */ + /** + * {@return the access flags} + * + * @see AccessFlag.Location#CLASS + */ AccessFlags flags(); /** {@return the constant pool entry describing the name of this class} */ ClassEntry thisClass(); - /** {@return the major classfile version} */ + /** + * {@return the major version of this class} It is in the range of unsigned + * short, {@code [0, 65535]}. + * + * @see ClassFileVersion + */ int majorVersion(); - /** {@return the minor classfile version} */ + /** + * {@return the minor version of this class} It is in the range of unsigned + * short, {@code [0, 65535]}. + * + * @see ClassFileVersion + */ int minorVersion(); /** {@return the fields of this class} */ @@ -66,12 +105,28 @@ public sealed interface ClassModel /** {@return the methods of this class} */ List methods(); - /** {@return the superclass of this class, if there is one} */ + /** + * {@return the superclass of this class, if there is one} + * This {@code class} file may have no superclass if this represents a + * {@linkplain #isModuleInfo() module descriptor} or the {@link Object} + * class; otherwise, it must have a superclass. If this is an interface, + * the superclass must be {@link Object}. + * + * @see Superclass + */ Optional superclass(); - /** {@return the interfaces implemented by this class} */ + /** + * {@return the interfaces implemented by this class} + * + * @see Interfaces + */ List interfaces(); - /** {@return whether this class is a module descriptor} */ + /** + * {@return whether this {@code class} file is a module descriptor} + * + * @see ClassFile#buildModule(ModuleAttribute, Consumer) + */ boolean isModuleInfo(); } diff --git a/src/java.base/share/classes/java/lang/classfile/ClassTransform.java b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java index 82b61a1508952..c365b79f463a2 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +35,12 @@ /** * A transformation on streams of {@link ClassElement}. + *

+ * Refer to {@link ClassFileTransform} for general guidance and caution around + * the use of transforms for structures in the {@code class} file format. * - * @see ClassFileTransform - * + * @see ClassModel + * @see ClassFile#transformClass(ClassModel, ClassTransform) * @since 24 */ @FunctionalInterface @@ -45,7 +48,7 @@ public non-sealed interface ClassTransform extends ClassFileTransform { /** - * A class transform that sends all elements to the builder. + * A class transform that passes all elements to the builder. */ static final ClassTransform ACCEPT_ALL = new ClassTransform() { @Override @@ -55,7 +58,7 @@ public void accept(ClassBuilder builder, ClassElement element) { }; /** - * Create a stateful class transform from a {@link Supplier}. The supplier + * Creates a stateful class transform from a {@link Supplier}. The supplier * will be invoked for each transformation. * * @param supplier a {@link Supplier} that produces a fresh transform object @@ -67,7 +70,7 @@ static ClassTransform ofStateful(Supplier supplier) { } /** - * Create a class transform that passes each element through to the builder, + * Creates a class transform that passes each element through to the builder, * and calls the specified function when transformation is complete. * * @param finisher the function to call when transformation is complete @@ -89,8 +92,8 @@ public void atEnd(ClassBuilder builder) { } /** - * Create a class transform that passes each element through to the builder, - * except for those that the supplied {@link Predicate} is true for. + * Creates a class transform that passes each element through to the builder, + * except for those that the supplied {@link Predicate} returns true for. * * @param filter the predicate that determines which elements to drop * @return the class transform @@ -104,8 +107,10 @@ static ClassTransform dropping(Predicate filter) { } /** - * Create a class transform that transforms {@link MethodModel} elements - * with the supplied method transform. + * Creates a class transform that transforms {@link MethodModel} elements + * with the supplied method transform for methods that the supplied {@link + * Predicate} returns true for, passing other elements through to the + * builder. * * @param filter a predicate that determines which methods to transform * @param xform the method transform @@ -117,8 +122,9 @@ static ClassTransform transformingMethods(Predicate filter, } /** - * Create a class transform that transforms {@link MethodModel} elements - * with the supplied method transform. + * Creates a class transform that transforms {@link MethodModel} elements + * with the supplied method transform, passing other elements through to the + * builder. * * @param xform the method transform * @return the class transform @@ -128,8 +134,10 @@ static ClassTransform transformingMethods(MethodTransform xform) { } /** - * Create a class transform that transforms the {@link CodeAttribute} (method body) - * of {@link MethodModel} elements with the supplied code transform. + * Creates a class transform that transforms the {@link CodeAttribute} (method body) + * of {@link MethodModel} elements with the supplied code transform for + * methods that the supplied {@link Predicate} returns true for, passing + * other elements through to the builder. * * @param filter a predicate that determines which methods to transform * @param xform the code transform @@ -141,8 +149,9 @@ static ClassTransform transformingMethodBodies(Predicate filter, } /** - * Create a class transform that transforms the {@link CodeAttribute} (method body) - * of {@link MethodModel} elements with the supplied code transform. + * Creates a class transform that transforms the {@link CodeAttribute} (method body) + * of {@link MethodModel} elements with the supplied code transform, passing + * other elements through to the builder. * * @param xform the code transform * @return the class transform @@ -152,8 +161,9 @@ static ClassTransform transformingMethodBodies(CodeTransform xform) { } /** - * Create a class transform that transforms {@link FieldModel} elements - * with the supplied field transform. + * Creates a class transform that transforms {@link FieldModel} elements + * with the supplied field transform, passing other elements through to the + * builder. * * @param xform the field transform * @return the class transform diff --git a/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java index 3cbcb893cb11d..9eafaa2df9c3a 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.lang.classfile; +import java.lang.classfile.ClassFile.*; import java.lang.classfile.constantpool.*; import java.lang.classfile.instruction.*; import java.lang.constant.ClassDesc; @@ -44,12 +45,23 @@ import static jdk.internal.classfile.impl.BytecodeHelpers.handleDescToHandleInfo; /** - * A builder for code attributes (method bodies). Builders are not created - * directly; they are passed to handlers by methods such as {@link - * MethodBuilder#withCode(Consumer)} or to code transforms. The elements of a - * code can be specified abstractly, by passing a {@link CodeElement} to {@link - * #with(ClassFileElement)} or concretely by calling the various {@code withXxx} - * methods. + * A builder for {@link CodeModel Code} attributes (method bodies). {@link + * MethodBuilder#withCode} is the basic way to obtain a code builder; {@link + * ClassBuilder#withMethodBody} is a shortcut. There are also derived code + * builders from {@link #block}, which handles code blocks and {@link + * #transforming}, which runs transforms on existing handlers, both of which + * requires a code builder to be available first. + *

+ * Refer to {@link ClassFileBuilder} for general guidance and caution around + * the use of builders for structures in the {@code class} file format. Unlike + * in other builders, the order of member elements in a code builder is + * significant: they affect the resulting bytecode. Many Class-File API options + * affect code builders: {@link DeadCodeOption} and {@link ShortJumpsOption} + * affect the resulting bytecode, and {@link DeadLabelsOption}, {@link + * DebugElementsOption}, {@link LineNumbersOption}, {@link StackMapsOption}, and + * {@link AttributesProcessingOption} affect the resulting attributes on the + * built {@code Code} attribute, that some elements sent to a code builder is + * otherwise ignored. * *

Instruction Factories

* {@code CodeBuilder} provides convenience methods to create instructions (See @@ -60,52 +72,63 @@ * #aload aload}. Note that some constant instructions, such as {@link #iconst_1 * iconst_1}, do not have generic versions, and thus have their own factories. *
  • Instructions that accept wide operands, such as {@code ldc2_w} or {@code - * wide}, share their factories with their regular version like {@link #ldc}. Note - * that {@link #goto_w goto_w} has its own factory to avoid {@linkplain - * ClassFile.ShortJumpsOption short jumps}. + * wide}, share their factories with their regular version like {@link #ldc}. + * Note that {@link #goto_w goto_w} has its own factory to avoid {@linkplain + * ShortJumpsOption short jumps}. *
  • The {@code goto}, {@code instanceof}, {@code new}, and {@code return} * instructions' factories are named {@link #goto_ goto_}, {@link #instanceOf * instanceOf}, {@link #new_ new_}, and {@link #return_() return_} respectively, * due to clashes with keywords in the Java programming language. - *
  • Factories are not provided for instructions {@code jsr}, {@code jsr_w}, - * {@code ret}, and {@code wide ret}, which cannot appear in class files with - * major version {@value ClassFile#JAVA_7_VERSION} or higher. (JVMS {@jvms 4.9.1}) + *
  • Factories are not provided for instructions {@link Opcode#JSR jsr}, + * {@link Opcode#JSR_W jsr_w}, {@link Opcode#RET ret}, and {@link Opcode#RET_W + * wide ret}, which cannot appear in class files with major version {@value + * ClassFile#JAVA_7_VERSION} or higher. (JVMS {@jvms 4.9.1}) They can still be + * provided via {@link #with}. * * + * @see MethodBuilder#withCode + * @see CodeModel * @see CodeTransform - * * @since 24 */ public sealed interface CodeBuilder extends ClassFileBuilder permits CodeBuilder.BlockCodeBuilder, ChainedCodeBuilder, TerminalCodeBuilder, NonterminalCodeBuilder { - /** {@return a fresh unbound label} */ + /** + * {@return a fresh unbound label} + * The label can be bound with {@link #labelBinding}. + */ Label newLabel(); - /** {@return the label associated with the beginning of the current block} - * If the current {@linkplain CodeBuilder} is not a "block" builder, such as - * those provided by {@link #block(Consumer)} or {@link #ifThenElse(Consumer, Consumer)}, - * the current block will be the entire method body. */ + /** + * {@return the label associated with the beginning of the current block} + * If this builder is not a "block" builder, such as those provided by + * {@link #block(Consumer)} or {@link #ifThenElse(Consumer, Consumer)}, + * the current block will be the entire method body. + */ Label startLabel(); - /** {@return the label associated with the end of the current block} - * If the current {@linkplain CodeBuilder} is not a "block" builder, such as - * those provided by {@link #block(Consumer)} or {@link #ifThenElse(Consumer, Consumer)}, - * the current block will be the entire method body. */ + /** + * {@return the label associated with the end of the current block} + * If this builder is not a "block" builder, such as those provided by + * {@link #block(Consumer)} or {@link #ifThenElse(Consumer, Consumer)}, + * the current block will be the entire method body. + */ Label endLabel(); /** - * {@return the local variable slot associated with the receiver}. + * {@return the local variable slot associated with the receiver} * * @throws IllegalStateException if this is a static method */ int receiverSlot(); /** - * {@return the local variable slot associated with the specified parameter}. + * {@return the local variable slot associated with the specified parameter} * The returned value is adjusted for the receiver slot (if the method is - * an instance method) and for the requirement that {@code long} and {@code double} + * an instance method) and for the requirement that {@link TypeKind#LONG + * long} and {@link TypeKind#DOUBLE double} * values require two slots. * * @param paramNo the index of the parameter @@ -115,25 +138,28 @@ public sealed interface CodeBuilder /** * {@return the local variable slot of a fresh local variable} This method * makes reasonable efforts to determine which slots are in use and which - * are not. When transforming a method, fresh locals begin at the {@code maxLocals} - * of the original method. For a method being built directly, fresh locals - * begin after the last parameter slot. - * - *

    If the current code builder is a "block" code builder provided by - * {@link #block(Consumer)}, {@link #ifThen(Consumer)}, or - * {@link #ifThenElse(Consumer, Consumer)}, at the end of the block, locals - * are reset to their value at the beginning of the block. + * are not. When transforming a method, fresh locals begin at the {@code + * maxLocals} of the original method. For a method being built directly, + * fresh locals begin after the last parameter slot. + *

    + * If the current code builder is a {@link BlockCodeBuilder}, at the end of + * the block, locals are reset to their value at the beginning of the block. * * @param typeKind the type of the local variable */ int allocateLocal(TypeKind typeKind); /** - * Apply a transform to the code built by a handler, directing results to this builder. + * Apply a transform to the code built by a handler, directing results to + * this builder. + * + * @apiNote + * This is similar to {@link #transform}, but this does not require the + * code elements to be viewed as a {@link CodeModel} first. * * @param transform the transform to apply to the code built by the handler - * @param handler the handler that receives a {@linkplain CodeBuilder} to - * build the code. + * @param handler the handler that receives a {@link CodeBuilder} to + * build the code * @return this builder */ default CodeBuilder transforming(CodeTransform transform, Consumer handler) { @@ -145,32 +171,36 @@ default CodeBuilder transforming(CodeTransform transform, Consumer } /** - * A builder for blocks of code. + * A builder for blocks of code. Its {@link #startLabel()} and {@link + * #endLabel()} do not enclose the entire method body, but from the start to + * the end of the block. * * @since 24 */ sealed interface BlockCodeBuilder extends CodeBuilder permits BlockCodeBuilderImpl { /** - * {@return the label locating where control is passed back to the parent block.} - * A branch to this label "break"'s out of the current block. + * {@return the label locating where control is passed back to the + * parent block} A branch to this label "break"'s out of the current + * block. *

    - * If an instruction occurring immediately after the built block's last instruction would - * be reachable from that last instruction, then a {@linkplain #goto_ goto} instruction - * targeting the "break" label is appended to the built block. + * If the last instruction in this block does not lead to the break + * label, Class-File API may append instructions to target the "break" + * label to the built block. */ Label breakLabel(); } /** - * Add a lexical block to the method being built. + * Adds a lexical block to the method being built. *

    - * Within this block, the {@link #startLabel()} and {@link #endLabel()} correspond - * to the start and end of the block, and the {@link BlockCodeBuilder#breakLabel()} - * also corresponds to the end of the block. + * Within this block, the {@link #startLabel()} and {@link #endLabel()} + * correspond to the start and end of the block, and the {@link + * BlockCodeBuilder#breakLabel()} also corresponds to the end of the block, + * or the cursor position immediately after this call in this builder. * - * @param handler handler that receives a {@linkplain BlockCodeBuilder} to - * generate the body of the lexical block. + * @param handler handler that receives a {@link BlockCodeBuilder} to + * generate the body of the lexical block * @return this builder */ default CodeBuilder block(Consumer handler) { @@ -183,33 +213,37 @@ default CodeBuilder block(Consumer handler) { } /** - * Add an "if-then" block that is conditional on the boolean value - * on top of the operand stack. + * Adds an "if-then" block that is conditional on the {@link TypeKind#BOOLEAN + * boolean} value on top of the operand stack. Control flow enters the + * "then" block if the value represents {@code true}. *

    - * The {@link BlockCodeBuilder#breakLabel()} for the "then" block corresponds to the - * end of that block. + * The {@link BlockCodeBuilder#breakLabel()} for the "then" block corresponds + * to the cursor position immediately after this call in this builder. * - * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} to - * generate the body of the {@code if} + * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} + * to generate the body of the {@code if} * @return this builder + * @see #ifThen(Opcode, Consumer) */ default CodeBuilder ifThen(Consumer thenHandler) { return ifThen(Opcode.IFNE, thenHandler); } /** - * Add an "if-then" block that is conditional on the value(s) on top of the operand stack - * in accordance with the given opcode. + * Adds an "if-then" block that is conditional on the value(s) on top of the + * operand stack in accordance with the given opcode. Control flow enters + * the "then" block if the branching condition for {@code opcode} succeeds. *

    - * The {@link BlockCodeBuilder#breakLabel()} for the "then" block corresponds to the - * end of that block. + * The {@link BlockCodeBuilder#breakLabel()} for the "then" block corresponds + * to the cursor position immediately after this call in this builder. * - * @param opcode the operation code for a branch instructions that accepts one or two operands on the stack - * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} to + * @param opcode the operation code for a branch instruction that accepts + * one or two operands on the stack + * @param thenHandler handler that receives a {@link BlockCodeBuilder} to * generate the body of the {@code if} * @return this builder - * @throws IllegalArgumentException if the operation code is not for a branch instruction that accepts - * one or two operands + * @throws IllegalArgumentException if the operation code is not for a + * branch instruction that accepts one or two operands */ default CodeBuilder ifThen(Opcode opcode, Consumer thenHandler) { @@ -227,17 +261,20 @@ default CodeBuilder ifThen(Opcode opcode, } /** - * Add an "if-then-else" block that is conditional on the boolean value - * on top of the operand stack. + * Adds an "if-then-else" block that is conditional on the {@link + * TypeKind#BOOLEAN boolean} value on top of the operand stack. Control + * flow enters the "then" block if the value represents {@code true}, and + * enters the "else" block otherwise. *

    - * The {@link BlockCodeBuilder#breakLabel()} for each block corresponds to the - * end of the "else" block. + * The {@link BlockCodeBuilder#breakLabel()} for each block corresponds to + * the cursor position immediately after this call in this builder. * - * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} to + * @param thenHandler handler that receives a {@link BlockCodeBuilder} to * generate the body of the {@code if} - * @param elseHandler handler that receives a {@linkplain BlockCodeBuilder} to + * @param elseHandler handler that receives a {@link BlockCodeBuilder} to * generate the body of the {@code else} * @return this builder + * @see #ifThenElse(Opcode, Consumer, Consumer) */ default CodeBuilder ifThenElse(Consumer thenHandler, Consumer elseHandler) { @@ -245,20 +282,23 @@ default CodeBuilder ifThenElse(Consumer thenHandler, } /** - * Add an "if-then-else" block that is conditional on the value(s) on top of the operand stack - * in accordance with the given opcode. + * Adds an "if-then-else" block that is conditional on the value(s) on top + * of the operand stack in accordance with the given opcode. Control flow + * enters the "then" block if the branching condition for {@code opcode} + * succeeds, and enters the "else" block otherwise. *

    - * The {@link BlockCodeBuilder#breakLabel()} for each block corresponds to the - * end of the "else" block. + * The {@link BlockCodeBuilder#breakLabel()} for each block corresponds to + * the cursor position immediately after this call in this builder. * - * @param opcode the operation code for a branch instructions that accepts one or two operands on the stack - * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} to - * generate the body of the {@code if} - * @param elseHandler handler that receives a {@linkplain BlockCodeBuilder} to - * generate the body of the {@code else} + * @param opcode the operation code for a branch instruction that accepts + * one or two operands on the stack + * @param thenHandler handler that receives a {@linkplain BlockCodeBuilder} + * to generate the body of the {@code if} + * @param elseHandler handler that receives a {@linkplain BlockCodeBuilder} + * to generate the body of the {@code else} * @return this builder - * @throws IllegalArgumentException if the operation code is not for a branch instruction that accepts - * one or two operands + * @throws IllegalArgumentException if the operation code is not for a + * branch instruction that accepts one or two operands */ default CodeBuilder ifThenElse(Opcode opcode, Consumer thenHandler, @@ -286,23 +326,29 @@ default CodeBuilder ifThenElse(Opcode opcode, * A builder to add catch blocks. * * @see #trying - * + * @see ExceptionCatch * @since 24 */ sealed interface CatchBuilder permits CatchBuilderImpl { /** * Adds a catch block that catches an exception of the given type. *

    - * The caught exception will be on top of the operand stack when the catch block is entered. + * The caught exception will be on top of the operand stack when the + * catch block is entered. *

    - * If the type of exception is {@code null} then the catch block catches all exceptions. + * The {@link BlockCodeBuilder#breakLabel()} for the catch block corresponds + * to the break label of the {@code tryHandler} block in {@link #trying}. + *

    + * If the type of exception is {@code null} then the catch block catches + * all exceptions. * - * @param exceptionType the type of exception to catch. - * @param catchHandler handler that receives a {@linkplain CodeBuilder} to - * generate the body of the catch block. + * @param exceptionType the type of exception to catch, may be {@code null} + * @param catchHandler handler that receives a {@link BlockCodeBuilder} to + * generate the body of the catch block * @return this builder - * @throws IllegalArgumentException if an existing catch block catches an exception of the given type - * or {@code exceptionType} represents a primitive type + * @throws IllegalArgumentException if an existing catch block catches + * an exception of the given type or {@code exceptionType} + * represents a primitive type * @see #catchingMulti * @see #catchingAll */ @@ -311,15 +357,21 @@ sealed interface CatchBuilder permits CatchBuilderImpl { /** * Adds a catch block that catches exceptions of the given types. *

    - * The caught exception will be on top of the operand stack when the catch block is entered. + * The caught exception will be on top of the operand stack when the + * catch block is entered. + *

    + * The {@link BlockCodeBuilder#breakLabel()} for the catch block corresponds + * to the break label of the {@code tryHandler} block in {@link #trying}. *

    - * If the type of exception is {@code null} then the catch block catches all exceptions. + * If list of exception types is empty then the catch block catches all + * exceptions. * - * @param exceptionTypes the types of exception to catch. - * @param catchHandler handler that receives a {@linkplain CodeBuilder} to - * generate the body of the catch block. + * @param exceptionTypes the types of exception to catch + * @param catchHandler handler that receives a {@link BlockCodeBuilder} + * to generate the body of the catch block * @return this builder - * @throws IllegalArgumentException if an existing catch block catches one or more exceptions of the given types. + * @throws IllegalArgumentException if an existing catch block catches + * one or more exceptions of the given types * @see #catching * @see #catchingAll */ @@ -328,11 +380,16 @@ sealed interface CatchBuilder permits CatchBuilderImpl { /** * Adds a "catch" block that catches all exceptions. *

    - * The caught exception will be on top of the operand stack when the catch block is entered. + * The {@link BlockCodeBuilder#breakLabel()} for the catch block corresponds + * to the break label of the {@code tryHandler} block in {@link #trying}. + *

    + * The caught exception will be on top of the operand stack when the + * catch block is entered. * - * @param catchAllHandler handler that receives a {@linkplain CodeBuilder} to - * generate the body of the catch block - * @throws IllegalArgumentException if an existing catch block catches all exceptions. + * @param catchAllHandler handler that receives a {@link BlockCodeBuilder} + * to generate the body of the catch block + * @throws IllegalArgumentException if an existing catch block catches + * all exceptions * @see #catching * @see #catchingMulti */ @@ -340,16 +397,23 @@ sealed interface CatchBuilder permits CatchBuilderImpl { } /** - * Adds a "try-catch" block comprising one try block and zero or more catch blocks. - * Exceptions thrown by instructions in the try block may be caught by catch blocks. + * Adds a "try-catch" block comprising one try block and zero or more catch + * blocks. Exceptions thrown by instructions in the try block may be caught + * by catch blocks. + *

    + * The {@link BlockCodeBuilder#breakLabel()} for the try block and all + * catch blocks in the {@code catchesHandler} correspond to the cursor + * position immediately after this call in this builder. * - * @param tryHandler handler that receives a {@linkplain CodeBuilder} to + * @param tryHandler handler that receives a {@link BlockCodeBuilder} to * generate the body of the try block. - * @param catchesHandler a handler that receives a {@linkplain CatchBuilder} - * to generate bodies of catch blocks. + * @param catchesHandler a handler that receives a {@link CatchBuilder} + * to generate bodies of catch blocks * @return this builder - * @throws IllegalArgumentException if the try block is empty. + * @throws IllegalArgumentException if the try block is empty * @see CatchBuilder + * @see ExceptionCatch + * @see #exceptionCatch */ default CodeBuilder trying(Consumer tryHandler, Consumer catchesHandler) { @@ -375,93 +439,119 @@ default CodeBuilder trying(Consumer tryHandler, // Base convenience methods /** - * Generate an instruction to load a value from a local variable + * Generates an instruction to load a value from a local variable. + * * @param tk the load type * @param slot the local variable slot * @return this builder - * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID void} - * or {@code slot} is out of range + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID + * void} or {@code slot} is out of range + * @see LoadInstruction */ default CodeBuilder loadLocal(TypeKind tk, int slot) { return with(LoadInstruction.of(tk, slot)); } /** - * Generate an instruction to store a value to a local variable + * Generates an instruction to store a value to a local variable. + * * @param tk the store type * @param slot the local variable slot * @return this builder - * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID void} - * or {@code slot} is out of range + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID + * void} or {@code slot} is out of range + * @see StoreInstruction */ default CodeBuilder storeLocal(TypeKind tk, int slot) { return with(StoreInstruction.of(tk, slot)); } /** - * Generate a branch instruction - * @see Opcode.Kind#BRANCH + * Generates a branch instruction. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set, the + * opcode has {@linkplain Opcode#sizeIfFixed() size} 3, and {@code target} + * cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param op the branch opcode * @param target the branch target * @return this builder + * @throws IllegalArgumentException if {@code op} is not of {@link + * Opcode.Kind#BRANCH} + * @see BranchInstruction */ default CodeBuilder branch(Opcode op, Label target) { return with(BranchInstruction.of(op, target)); } /** - * Generate return instruction + * Generates a return instruction. + * * @param tk the return type * @return this builder + * @see ReturnInstruction */ default CodeBuilder return_(TypeKind tk) { return with(ReturnInstruction.of(tk)); } /** - * Generate an instruction to access a field - * @see Opcode.Kind#FIELD_ACCESS + * Generates an instruction to access a field. + * * @param opcode the field access opcode * @param ref the field reference * @return this builder + * @throws IllegalArgumentException if {@code opcode} is not of {@link + * Opcode.Kind#FIELD_ACCESS} + * @see FieldInstruction */ default CodeBuilder fieldAccess(Opcode opcode, FieldRefEntry ref) { return with(FieldInstruction.of(opcode, ref)); } /** - * Generate an instruction to access a field - * @see Opcode.Kind#FIELD_ACCESS + * Generates an instruction to access a field. + * * @param opcode the field access opcode * @param owner the class * @param name the field name * @param type the field type * @return this builder + * @throws IllegalArgumentException if {@code opcode} is not of {@link + * Opcode.Kind#FIELD_ACCESS}, or {@code owner} is primitive + * @see FieldInstruction */ default CodeBuilder fieldAccess(Opcode opcode, ClassDesc owner, String name, ClassDesc type) { return fieldAccess(opcode, constantPool().fieldRefEntry(owner, name, type)); } /** - * Generate an instruction to invoke a method or constructor - * @see Opcode.Kind#INVOKE + * Generates an instruction to invoke a method. + * * @param opcode the invoke opcode * @param ref the interface method or method reference * @return this builder + * @throws IllegalArgumentException if {@code opcode} is not of {@link + * Opcode.Kind#INVOKE} + * @see InvokeInstruction */ default CodeBuilder invoke(Opcode opcode, MemberRefEntry ref) { return with(InvokeInstruction.of(opcode, ref)); } /** - * Generate an instruction to invoke a method or constructor - * @see Opcode.Kind#INVOKE + * Generates an instruction to invoke a method. + * * @param opcode the invoke opcode * @param owner the class * @param name the method name * @param desc the method type - * @param isInterface the interface method invocation indication + * @param isInterface whether the owner class is an interface * @return this builder + * @throws IllegalArgumentException if {@code opcode} is not of {@link + * Opcode.Kind#INVOKE}, or {@code owner} is primitive + * @see InvokeInstruction */ default CodeBuilder invoke(Opcode opcode, ClassDesc owner, String name, MethodTypeDesc desc, boolean isInterface) { return invoke(opcode, @@ -470,9 +560,13 @@ default CodeBuilder invoke(Opcode opcode, ClassDesc owner, String name, MethodTy } /** - * Generate an instruction to load from an array + * Generates an instruction to load from an array. + * * @param tk the array element type * @return this builder + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID + * void} + * @see ArrayLoadInstruction */ default CodeBuilder arrayLoad(TypeKind tk) { Opcode opcode = BytecodeHelpers.arrayLoadOpcode(tk); @@ -480,9 +574,13 @@ default CodeBuilder arrayLoad(TypeKind tk) { } /** - * Generate an instruction to store into an array + * Generates an instruction to store into an array. + * * @param tk the array element type * @return this builder + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID + * void} + * @see ArrayStoreInstruction */ default CodeBuilder arrayStore(TypeKind tk) { Opcode opcode = BytecodeHelpers.arrayStoreOpcode(tk); @@ -490,12 +588,14 @@ default CodeBuilder arrayStore(TypeKind tk) { } /** - * Generate instruction(s) to convert {@code fromType} to {@code toType} + * Generates instruction(s) to convert {@code fromType} to {@code toType}. + * * @param fromType the source type * @param toType the target type * @return this builder - * @throws IllegalArgumentException for conversions of {@link TypeKind#VOID void} or - * {@link TypeKind#REFERENCE reference} + * @throws IllegalArgumentException for conversions of {@link TypeKind#VOID + * void} or {@link TypeKind#REFERENCE reference} + * @see ConvertInstruction */ default CodeBuilder conversion(TypeKind fromType, TypeKind toType) { var computationalFrom = fromType.asLoadable(); @@ -548,9 +648,11 @@ default CodeBuilder conversion(TypeKind fromType, TypeKind toType) { } /** - * Generate an instruction pushing a constant onto the operand stack - * @param value the constant value + * Generates an instruction pushing a constant onto the operand stack. + * + * @param value the constant value, may be {@code null} * @return this builder + * @see ConstantInstruction */ default CodeBuilder loadConstant(ConstantDesc value) { //avoid switch expressions here @@ -567,11 +669,13 @@ default CodeBuilder loadConstant(ConstantDesc value) { /** - * Generate an instruction pushing a constant int value onto the operand stack. - * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Integer.valueOf(value))}. + * Generates an instruction pushing a constant {@link TypeKind#INT int} + * value onto the operand stack. This is equivalent to {@link + * #loadConstant(ConstantDesc) loadConstant(Integer.valueOf(value))}. + * * @param value the int value * @return this builder - * @since 24 + * @see ConstantInstruction */ default CodeBuilder loadConstant(int value) { return switch (value) { @@ -589,11 +693,13 @@ default CodeBuilder loadConstant(int value) { } /** - * Generate an instruction pushing a constant long value onto the operand stack. - * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Long.valueOf(value))}. + * Generates an instruction pushing a constant {@link TypeKind#LONG long} + * value onto the operand stack. This is equivalent to {@link + * #loadConstant(ConstantDesc) loadConstant(Long.valueOf(value))}. + * * @param value the long value * @return this builder - * @since 24 + * @see ConstantInstruction */ default CodeBuilder loadConstant(long value) { return value == 0l ? lconst_0() @@ -602,11 +708,16 @@ default CodeBuilder loadConstant(long value) { } /** - * Generate an instruction pushing a constant float value onto the operand stack. - * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Float.valueOf(value))}. + * Generates an instruction pushing a constant {@link TypeKind#FLOAT float} + * value onto the operand stack. This is equivalent to {@link + * #loadConstant(ConstantDesc) loadConstant(Float.valueOf(value))}. + *

    + * All NaN values of the {@code float} may or may not be collapsed + * into a single {@linkplain Float#NaN "canonical" NaN value}. + * * @param value the float value * @return this builder - * @since 24 + * @see ConstantInstruction */ default CodeBuilder loadConstant(float value) { return Float.floatToRawIntBits(value) == 0 ? fconst_0() @@ -616,11 +727,16 @@ default CodeBuilder loadConstant(float value) { } /** - * Generate an instruction pushing a constant double value onto the operand stack. - * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Double.valueOf(value))}. + * Generates an instruction pushing a constant {@link TypeKind#DOUBLE double} + * value onto the operand stack. This is equivalent to {@link + * #loadConstant(ConstantDesc) loadConstant(Double.valueOf(value))}. + *

    + * All NaN values of the {@code double} may or may not be collapsed + * into a single {@linkplain Double#NaN "canonical" NaN value}. + * * @param value the double value * @return this builder - * @since 24 + * @see ConstantInstruction */ default CodeBuilder loadConstant(double value) { return Double.doubleToRawLongBits(value) == 0l ? dconst_0() @@ -629,8 +745,10 @@ default CodeBuilder loadConstant(double value) { } /** - * Generate a do nothing instruction + * Generates a do-nothing instruction. + * * @return this builder + * @see NopInstruction */ default CodeBuilder nop() { return with(NopInstruction.of()); @@ -639,8 +757,11 @@ default CodeBuilder nop() { // Base pseudo-instruction builder methods /** - * Create new label bound with current position + * Creates a new label bound at the current position. + * * @return this builder + * @see #newLabel() + * @see #labelBinding */ default Label newBoundLabel() { var label = newLabel(); @@ -649,54 +770,86 @@ default Label newBoundLabel() { } /** - * Bind label with current position + * Binds a label to the current position. + * + * @apiNote + * The label to bind does not have to be {@linkplain #newLabel() from this + * builder}; it can be from another parsed {@link CodeModel}. + * * @param label the label * @return this builder + * @see LabelTarget */ default CodeBuilder labelBinding(Label label) { return with((LabelImpl) label); } /** - * Declare a source line number of the current builder position + * Declares a source line number beginning at the current position. + *

    + * This call may be ignored according to {@link ClassFile.LineNumbersOption}. + * * @param line the line number * @return this builder + * @see LineNumber */ default CodeBuilder lineNumber(int line) { return with(LineNumber.of(line)); } /** - * Declare an exception table entry + * Declares an exception table entry. + *

    + * This call may be ignored if any of the argument labels is not {@linkplain + * #labelBinding bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} + * is set. + * * @param start the try block start * @param end the try block end * @param handler the exception handler start - * @param catchType the catch type or null to catch all exceptions and errors + * @param catchType the catch type, may be {@code null} to catch all exceptions and errors * @return this builder + * @see ExceptionCatch + * @see CodeBuilder#trying */ default CodeBuilder exceptionCatch(Label start, Label end, Label handler, ClassEntry catchType) { return with(ExceptionCatch.of(handler, start, end, Optional.ofNullable(catchType))); } /** - * Declare an exception table entry + * Declares an exception table entry. + *

    + * This call may be ignored if any of the argument labels is not {@linkplain + * #labelBinding bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} + * is set. + * * @param start the try block start * @param end the try block end * @param handler the exception handler start * @param catchType the optional catch type, empty to catch all exceptions and errors * @return this builder + * @see ExceptionCatch + * @see CodeBuilder#trying */ default CodeBuilder exceptionCatch(Label start, Label end, Label handler, Optional catchType) { return with(ExceptionCatch.of(handler, start, end, catchType)); } /** - * Declare an exception table entry + * Declares an exception table entry. + *

    + * This call may be ignored if any of the argument labels is not {@linkplain + * #labelBinding bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} + * is set. + * * @param start the try block start * @param end the try block end * @param handler the exception handler start * @param catchType the catch type * @return this builder + * @throws IllegalArgumentException if {@code catchType} is primitive + * @see ExceptionCatch + * @see CodeBuilder#trying */ default CodeBuilder exceptionCatch(Label start, Label end, Label handler, ClassDesc catchType) { requireNonNull(catchType); @@ -704,31 +857,49 @@ default CodeBuilder exceptionCatch(Label start, Label end, Label handler, ClassD } /** - * Declare an exception table entry catching all exceptions and errors + * Declares an exception table entry catching all exceptions and errors. + *

    + * This call may be ignored if any of the argument labels is not {@linkplain + * #labelBinding bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} + * is set. + * * @param start the try block start * @param end the try block end * @param handler the exception handler start * @return this builder + * @see ExceptionCatch + * @see CodeBuilder#trying */ default CodeBuilder exceptionCatchAll(Label start, Label end, Label handler) { return with(ExceptionCatch.of(handler, start, end)); } /** - * Declare a character range entry + * Declares a character range entry. + *

    + * This call may be ignored if {@link ClassFile.DebugElementsOption#DROP_DEBUG} + * is set, or if any of the argument labels is not {@linkplain #labelBinding + * bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} is set. + * * @param startScope the start scope of the character range * @param endScope the end scope of the character range * @param characterRangeStart the encoded start of the character range region (inclusive) * @param characterRangeEnd the encoded end of the character range region (exclusive) * @param flags the flags word, indicating the kind of range * @return this builder + * @see CharacterRange */ default CodeBuilder characterRange(Label startScope, Label endScope, int characterRangeStart, int characterRangeEnd, int flags) { return with(CharacterRange.of(startScope, endScope, characterRangeStart, characterRangeEnd, flags)); } /** - * Declare a local variable entry + * Declares a local variable entry. + *

    + * This call may be ignored if {@link ClassFile.DebugElementsOption#DROP_DEBUG} + * is set, or if any of the argument labels is not {@linkplain #labelBinding + * bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} is set. + * * @param slot the local variable slot * @param nameEntry the variable name * @param descriptorEntry the variable descriptor @@ -736,13 +907,19 @@ default CodeBuilder characterRange(Label startScope, Label endScope, int charact * @param endScope the end scope of the variable * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see LocalVariable */ default CodeBuilder localVariable(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope) { return with(LocalVariable.of(slot, nameEntry, descriptorEntry, startScope, endScope)); } /** - * Declare a local variable entry + * Declares a local variable entry. + *

    + * This call may be ignored if {@link ClassFile.DebugElementsOption#DROP_DEBUG} + * is set, or if any of the argument labels is not {@linkplain #labelBinding + * bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} is set. + * * @param slot the local variable slot * @param name the variable name * @param descriptor the variable descriptor @@ -750,6 +927,7 @@ default CodeBuilder localVariable(int slot, Utf8Entry nameEntry, Utf8Entry descr * @param endScope the end scope of the variable * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see LocalVariable */ default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) { return localVariable(slot, @@ -759,7 +937,17 @@ default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, L } /** - * Declare a local variable type entry + * Declares a local variable type entry. + *

    + * This call may be ignored if {@link ClassFile.DebugElementsOption#DROP_DEBUG} + * is set, or if any of the argument labels is not {@linkplain #labelBinding + * bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} is set. + * + * @apiNote + * When a local variable type entry is declared, a local variable entry with + * the descriptor derived from erasure (JLS {@jls 4.6}) of the signature + * should be declared as well. + * * @param slot the local variable slot * @param nameEntry the variable name * @param signatureEntry the variable signature @@ -767,13 +955,24 @@ default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, L * @param endScope the end scope of the variable * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see LocalVariableType */ default CodeBuilder localVariableType(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope) { return with(LocalVariableType.of(slot, nameEntry, signatureEntry, startScope, endScope)); } /** - * Declare a local variable type entry + * Declares a local variable type entry. + *

    + * This call may be ignored if {@link ClassFile.DebugElementsOption#DROP_DEBUG} + * is set, or if any of the argument labels is not {@linkplain #labelBinding + * bound} and {@link ClassFile.DeadLabelsOption#DROP_DEAD_LABELS} is set. + * + * @apiNote + * When a local variable type entry is declared, a local variable entry with + * the descriptor derived from erasure (JLS {@jls 4.6}) of the signature + * should be declared as well. + * * @param slot the local variable slot * @param name the variable name * @param signature the variable signature @@ -781,6 +980,7 @@ default CodeBuilder localVariableType(int slot, Utf8Entry nameEntry, Utf8Entry s * @param endScope the end scope of the variable * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see LocalVariableType */ default CodeBuilder localVariableType(int slot, String name, Signature signature, Label startScope, Label endScope) { return localVariableType(slot, @@ -792,971 +992,1491 @@ default CodeBuilder localVariableType(int slot, String name, Signature signature // Bytecode conveniences /** - * Generate an instruction pushing the null object reference onto the operand stack + * Generates an instruction pushing the null object {@link TypeKind#REFERENCE + * reference} onto the operand stack. + * * @return this builder + * @see Opcode#ACONST_NULL + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder aconst_null() { return with(ConstantInstruction.ofIntrinsic(Opcode.ACONST_NULL)); } /** - * Generate an instruction to load a reference from an array + * Generates an instruction to load from a {@link TypeKind#REFERENCE + * reference} array. + * * @return this builder + * @see Opcode#AALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder aaload() { return arrayLoad(TypeKind.REFERENCE); } /** - * Generate an instruction to store into a reference array + * Generates an instruction to store into a {@link TypeKind#REFERENCE + * reference} array. + * * @return this builder + * @see Opcode#AASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder aastore() { return arrayStore(TypeKind.REFERENCE); } /** - * Generate an instruction to load a reference from a local variable - * - *

    This may also generate {@code aload_} and - * {@code wide aload} instructions. + * Generates an instruction to load a {@link TypeKind#REFERENCE reference} + * from a local variable. + *

    + * This may also generate {@link Opcode#ALOAD_0 aload_<N>} and {@link + * Opcode#ALOAD_W wide aload} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#ALOAD + * @see #loadLocal + * @see LoadInstruction */ default CodeBuilder aload(int slot) { return loadLocal(TypeKind.REFERENCE, slot); } /** - * Generate an instruction to create a new array of reference + * Generates an instruction to create a new array of {@link TypeKind#REFERENCE + * reference}. + * * @param classEntry the component type * @return this builder + * @see Opcode#ANEWARRAY + * @see NewReferenceArrayInstruction */ default CodeBuilder anewarray(ClassEntry classEntry) { return with(NewReferenceArrayInstruction.of(classEntry)); } /** - * Generate an instruction to create a new array of reference + * Generates an instruction to create a new array of {@link TypeKind#REFERENCE + * reference}. + * * @param className the component type * @return this builder * @throws IllegalArgumentException if {@code className} represents a primitive type + * @see Opcode#ANEWARRAY + * @see NewReferenceArrayInstruction */ default CodeBuilder anewarray(ClassDesc className) { return anewarray(constantPool().classEntry(className)); } /** - * Generate an instruction to return a reference from the method + * Generates an instruction to return a {@link TypeKind#REFERENCE reference} + * from this method. + * * @return this builder + * @see Opcode#ARETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder areturn() { return return_(TypeKind.REFERENCE); } /** - * Generate an instruction to get length of an array + * Generates an instruction to get the length of an array. + * * @return this builder + * @see Opcode#ARRAYLENGTH + * @see OperatorInstruction */ default CodeBuilder arraylength() { return with(OperatorInstruction.of(Opcode.ARRAYLENGTH)); } /** - * Generate an instruction to store a reference into a local variable - * - *

    This may also generate {@code astore_} and - * {@code wide astore} instructions. + * Generates an instruction to store a {@link TypeKind#REFERENCE reference} + * into a local variable. Such an instruction can also store a {@link + * TypeKind##returnAddress returnAddress}. + *

    + * This may also generate {@link Opcode#ASTORE_0 astore_<N>} and + * {@link Opcode#ASTORE_W wide astore} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#ASTORE + * @see #storeLocal + * @see StoreInstruction */ default CodeBuilder astore(int slot) { return storeLocal(TypeKind.REFERENCE, slot); } /** - * Generate an instruction to throw an exception or error + * Generates an instruction to throw an exception or error. + * * @return this builder + * @see Opcode#ATHROW + * @see ThrowInstruction */ default CodeBuilder athrow() { return with(ThrowInstruction.of()); } /** - * Generate an instruction to load a byte from a array + * Generates an instruction to load from a {@link TypeKind#BYTE byte} or + * {@link TypeKind#BOOLEAN boolean} array. + * * @return this builder + * @see Opcode#BALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder baload() { return arrayLoad(TypeKind.BYTE); } /** - * Generate an instruction to store into a byte array + * Generates an instruction to store into a {@link TypeKind#BYTE byte} or + * {@link TypeKind#BOOLEAN boolean} array. + * * @return this builder + * @see Opcode#BASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder bastore() { return arrayStore(TypeKind.BYTE); } /** - * Generate an instruction pushing an int in the range of byte onto the operand stack. + * Generates an instruction pushing an {@link TypeKind#INT int} in the range + * of {@link TypeKind#BYTE byte} ({@code [-128, 127]}) onto the operand + * stack. + * * @param b the int in the range of byte * @return this builder * @throws IllegalArgumentException if {@code b} is out of range of byte + * @see Opcode#BIPUSH + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder bipush(int b) { return with(ConstantInstruction.ofArgument(Opcode.BIPUSH, b)); } /** - * Generate an instruction to load a char from an array + * Generates an instruction to load from a {@link TypeKind#CHAR char} array. + * * @return this builder + * @see Opcode#CALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder caload() { return arrayLoad(TypeKind.CHAR); } /** - * Generate an instruction to store into a char array + * Generates an instruction to store into a {@link TypeKind#CHAR char} array. + * * @return this builder + * @see Opcode#CASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder castore() { return arrayStore(TypeKind.CHAR); } /** - * Generate an instruction to check whether an object is of the given type + * Generates an instruction to check whether an object is of the given type, + * throwing a {@link ClassCastException} if the check fails. + * * @param type the object type * @return this builder + * @see Opcode#CHECKCAST + * @see TypeCheckInstruction */ default CodeBuilder checkcast(ClassEntry type) { return with(TypeCheckInstruction.of(Opcode.CHECKCAST, type)); } /** - * Generate an instruction to check whether an object is of the given type + * Generates an instruction to check whether an object is of the given type, + * throwing a {@link ClassCastException} if the check fails. + * * @param type the object type * @return this builder * @throws IllegalArgumentException if {@code type} represents a primitive type + * @see Opcode#CHECKCAST + * @see TypeCheckInstruction */ default CodeBuilder checkcast(ClassDesc type) { return checkcast(constantPool().classEntry(type)); } /** - * Generate an instruction to convert a double into a float + * Generates an instruction to convert a {@link TypeKind#DOUBLE double} into + * a {@link TypeKind#FLOAT float}. + * * @return this builder + * @see Opcode#D2F + * @see ConvertInstruction */ default CodeBuilder d2f() { return with(ConvertInstruction.of(Opcode.D2F)); } /** - * Generate an instruction to convert a double into an int + * Generates an instruction to convert a {@link TypeKind#DOUBLE double} into + * an {@link TypeKind#INT int}. + * * @return this builder + * @see Opcode#D2I + * @see ConvertInstruction */ default CodeBuilder d2i() { return with(ConvertInstruction.of(Opcode.D2I)); } /** - * Generate an instruction to convert a double into a long + * Generates an instruction to convert a {@link TypeKind#DOUBLE double} into + * a {@link TypeKind#LONG long}. + * * @return this builder + * @see Opcode#D2L + * @see ConvertInstruction */ default CodeBuilder d2l() { return with(ConvertInstruction.of(Opcode.D2L)); } /** - * Generate an instruction to add a double + * Generates an instruction to add two {@link TypeKind#DOUBLE doubles}. + * * @return this builder + * @see Opcode#DADD + * @see OperatorInstruction */ default CodeBuilder dadd() { return with(OperatorInstruction.of(Opcode.DADD)); } /** - * Generate an instruction to load a double from an array + * Generates an instruction to load from a {@link TypeKind#DOUBLE double} + * array. + * * @return this builder + * @see Opcode#DALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder daload() { return arrayLoad(TypeKind.DOUBLE); } /** - * Generate an instruction to store into a double array + * Generates an instruction to store into a {@link TypeKind#DOUBLE double} + * array. + * * @return this builder + * @see Opcode#DASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder dastore() { return arrayStore(TypeKind.DOUBLE); } /** - * Generate an instruction to add a double + * Generates an instruction to compare two {@link TypeKind#DOUBLE doubles}, + * producing {@code 1} if any operand is {@link Double#isNaN(double) NaN}. + * * @return this builder + * @see Opcode#DCMPG + * @see OperatorInstruction */ default CodeBuilder dcmpg() { return with(OperatorInstruction.of(Opcode.DCMPG)); } /** - * Generate an instruction to compare doubles + * Generates an instruction to compare two {@link TypeKind#DOUBLE doubles}, + * producing {@code -1} if any operand is {@link Double#isNaN(double) NaN}. + * * @return this builder + * @see Opcode#DCMPL + * @see OperatorInstruction */ default CodeBuilder dcmpl() { return with(OperatorInstruction.of(Opcode.DCMPL)); } /** - * Generate an instruction pushing double constant 0 onto the operand stack + * Generates an instruction pushing {@link TypeKind#DOUBLE double} constant + * 0 onto the operand stack. + * * @return this builder + * @see Opcode#DCONST_0 + * @see #loadConstant(double) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder dconst_0() { return with(ConstantInstruction.ofIntrinsic(Opcode.DCONST_0)); } /** - * Generate an instruction pushing double constant 1 onto the operand stack + * Generates an instruction pushing {@link TypeKind#DOUBLE double} constant + * 1 onto the operand stack. + * * @return this builder + * @see Opcode#DCONST_1 + * @see #loadConstant(double) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder dconst_1() { return with(ConstantInstruction.ofIntrinsic(Opcode.DCONST_1)); } /** - * Generate an instruction to divide doubles + * Generates an instruction to divide {@link TypeKind#DOUBLE doubles}. + * * @return this builder + * @see Opcode#DDIV + * @see OperatorInstruction */ default CodeBuilder ddiv() { return with(OperatorInstruction.of(Opcode.DDIV)); } /** - * Generate an instruction to load a double from a local variable - * - *

    This may also generate {@code dload_} and - * {@code wide dload} instructions. + * Generates an instruction to load a {@link TypeKind#DOUBLE double} from a + * local variable. + *

    + * This may also generate {@link Opcode#DLOAD_0 dload_<N>} and {@link + * Opcode#DLOAD_W wide dload} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#DLOAD + * @see #loadLocal(TypeKind, int) + * @see LoadInstruction */ default CodeBuilder dload(int slot) { return loadLocal(TypeKind.DOUBLE, slot); } /** - * Generate an instruction to multiply doubles + * Generates an instruction to multiply {@link TypeKind#DOUBLE doubles}. + * * @return this builder + * @see Opcode#DMUL + * @see OperatorInstruction */ default CodeBuilder dmul() { return with(OperatorInstruction.of(Opcode.DMUL)); } /** - * Generate an instruction to negate a double + * Generates an instruction to negate a {@link TypeKind#DOUBLE double}. + * * @return this builder + * @see Opcode#DNEG + * @see OperatorInstruction */ default CodeBuilder dneg() { return with(OperatorInstruction.of(Opcode.DNEG)); } /** - * Generate an instruction to calculate double remainder + * Generates an instruction to calculate {@link TypeKind#DOUBLE double} + * remainder. + * * @return this builder + * @see Opcode#DREM + * @see OperatorInstruction */ default CodeBuilder drem() { return with(OperatorInstruction.of(Opcode.DREM)); } /** - * Generate an instruction to return a double from the method + * Generates an instruction to return a {@link TypeKind#DOUBLE double} from + * this method. + * * @return this builder + * @see Opcode#DRETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder dreturn() { return return_(TypeKind.DOUBLE); } /** - * Generate an instruction to store a double into a local variable - * - *

    This may also generate {@code dstore_} and - * {@code wide dstore} instructions. + * Generates an instruction to store a {@link TypeKind#DOUBLE double} into a + * local variable. + *

    + * This may also generate {@link Opcode#DSTORE_0 dstore_<N>} and + * {@link Opcode#DSTORE_W wide dstore} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#DSTORE + * @see #storeLocal(TypeKind, int) + * @see StoreInstruction */ default CodeBuilder dstore(int slot) { return storeLocal(TypeKind.DOUBLE, slot); } /** - * Generate an instruction to subtract doubles + * Generates an instruction to subtract {@link TypeKind#DOUBLE doubles}. + * * @return this builder + * @see Opcode#DSUB + * @see OperatorInstruction */ default CodeBuilder dsub() { return with(OperatorInstruction.of(Opcode.DSUB)); } /** - * Generate an instruction to duplicate the top operand stack value + * Generates an instruction to duplicate the top operand stack value. + * * @return this builder + * @see Opcode#DUP + * @see StackInstruction */ default CodeBuilder dup() { return with(StackInstruction.of(Opcode.DUP)); } /** - * Generate an instruction to duplicate the top one or two operand stack value + * Generates an instruction to duplicate the top one or two operand stack + * value. + * * @return this builder + * @see Opcode#DUP2 + * @see StackInstruction */ default CodeBuilder dup2() { return with(StackInstruction.of(Opcode.DUP2)); } /** - * Generate an instruction to duplicate the top one or two operand stack values and insert two or three - * values down + * Generates an instruction to duplicate the top one or two operand stack + * values and insert two or three values down. + * * @return this builder + * @see Opcode#DUP2_X1 + * @see StackInstruction */ default CodeBuilder dup2_x1() { return with(StackInstruction.of(Opcode.DUP2_X1)); } /** - * Generate an instruction to duplicate the top one or two operand stack values and insert two, three, - * or four values down + * Generates an instruction to duplicate the top one or two operand stack + * values and insert two, three, or four values down. + * * @return this builder + * @see Opcode#DUP2_X2 + * @see StackInstruction */ default CodeBuilder dup2_x2() { return with(StackInstruction.of(Opcode.DUP2_X2)); } /** - * Generate an instruction to duplicate the top operand stack value and insert two values down + * Generates an instruction to duplicate the top operand stack value and + * insert two values down. + * * @return this builder + * @see Opcode#DUP_X1 + * @see StackInstruction */ default CodeBuilder dup_x1() { return with(StackInstruction.of(Opcode.DUP_X1)); } /** - * Generate an instruction to duplicate the top operand stack value and insert two or three values down + * Generates an instruction to duplicate the top operand stack value and + * insert two or three values down. + * * @return this builder + * @see Opcode#DUP_X2 + * @see StackInstruction */ default CodeBuilder dup_x2() { return with(StackInstruction.of(Opcode.DUP_X2)); } /** - * Generate an instruction to convert a float into a double + * Generates an instruction to convert a {@link TypeKind#FLOAT float} into a + * {@link TypeKind#DOUBLE double}. + * * @return this builder + * @see Opcode#F2D + * @see ConvertInstruction */ default CodeBuilder f2d() { return with(ConvertInstruction.of(Opcode.F2D)); } /** - * Generate an instruction to convert a float into an int + * Generates an instruction to convert a {@link TypeKind#FLOAT float} into + * an {@link TypeKind#INT int}. + * * @return this builder + * @see Opcode#F2I + * @see ConvertInstruction */ default CodeBuilder f2i() { return with(ConvertInstruction.of(Opcode.F2I)); } /** - * Generate an instruction to convert a float into a long + * Generates an instruction to convert a {@link TypeKind#FLOAT float} into a + * {@link TypeKind#LONG long}. + * * @return this builder + * @see Opcode#F2L + * @see ConvertInstruction */ default CodeBuilder f2l() { return with(ConvertInstruction.of(Opcode.F2L)); } /** - * Generate an instruction to add a float + * Generates an instruction to add two {@link TypeKind#FLOAT floats}. + * * @return this builder + * @see Opcode#FADD + * @see OperatorInstruction */ default CodeBuilder fadd() { return with(OperatorInstruction.of(Opcode.FADD)); } /** - * Generate an instruction to load a float from an array + * Generates an instruction to load from a {@link TypeKind#FLOAT float} + * array. + * * @return this builder + * @see Opcode#FALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder faload() { return arrayLoad(TypeKind.FLOAT); } /** - * Generate an instruction to store into a float array + * Generates an instruction to store into a {@link TypeKind#FLOAT float} + * array. + * * @return this builder + * @see Opcode#FASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder fastore() { return arrayStore(TypeKind.FLOAT); } /** - * Generate an instruction to compare floats + * Generates an instruction to compare {@link TypeKind#FLOAT floats}, + * producing {@code 1} if any operand is {@link Float#isNaN(float) NaN}. + * * @return this builder + * @see Opcode#FCMPG + * @see OperatorInstruction */ default CodeBuilder fcmpg() { return with(OperatorInstruction.of(Opcode.FCMPG)); } /** - * Generate an instruction to compare floats + * Generates an instruction to compare {@link TypeKind#FLOAT floats}, + * producing {@code -1} if any operand is {@link Float#isNaN(float) NaN}. + * * @return this builder + * @see Opcode#FCMPL + * @see OperatorInstruction */ default CodeBuilder fcmpl() { return with(OperatorInstruction.of(Opcode.FCMPL)); } /** - * Generate an instruction pushing float constant 0 onto the operand stack + * Generates an instruction pushing {@link TypeKind#FLOAT float} constant 0 + * onto the operand stack. + * * @return this builder + * @see Opcode#FCONST_0 + * @see #loadConstant(float) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder fconst_0() { return with(ConstantInstruction.ofIntrinsic(Opcode.FCONST_0)); } /** - * Generate an instruction pushing float constant 1 onto the operand stack + * Generates an instruction pushing {@link TypeKind#FLOAT float} constant 1 + * onto the operand stack. + * * @return this builder + * @see Opcode#FCONST_1 + * @see #loadConstant(float) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder fconst_1() { return with(ConstantInstruction.ofIntrinsic(Opcode.FCONST_1)); } /** - * Generate an instruction pushing float constant 2 onto the operand stack + * Generates an instruction pushing {@link TypeKind#FLOAT float} constant 2 + * onto the operand stack. + * * @return this builder + * @see Opcode#FCONST_2 + * @see #loadConstant(float) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder fconst_2() { return with(ConstantInstruction.ofIntrinsic(Opcode.FCONST_2)); } /** - * Generate an instruction to divide floats + * Generates an instruction to divide {@link TypeKind#FLOAT floats}. + * * @return this builder + * @see Opcode#FDIV + * @see OperatorInstruction */ default CodeBuilder fdiv() { return with(OperatorInstruction.of(Opcode.FDIV)); } /** - * Generate an instruction to load a float from a local variable - * - *

    This may also generate {@code fload_} and - * {@code wide fload} instructions. + * Generates an instruction to load a {@link TypeKind#FLOAT float} from a + * local variable. + *

    + * This may also generate {@link Opcode#FLOAD_0 fload_<N>} and {@link + * Opcode#FLOAD_W wide fload} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#FLOAD + * @see #loadLocal(TypeKind, int) + * @see LoadInstruction */ default CodeBuilder fload(int slot) { return loadLocal(TypeKind.FLOAT, slot); } /** - * Generate an instruction to multiply floats + * Generates an instruction to multiply {@link TypeKind#FLOAT floats}. + * * @return this builder + * @see Opcode#FMUL + * @see OperatorInstruction */ default CodeBuilder fmul() { return with(OperatorInstruction.of(Opcode.FMUL)); } /** - * Generate an instruction to negate a float + * Generates an instruction to negate a {@link TypeKind#FLOAT float}. + * * @return this builder + * @see Opcode#FNEG + * @see OperatorInstruction */ default CodeBuilder fneg() { return with(OperatorInstruction.of(Opcode.FNEG)); } /** - * Generate an instruction to calculate floats remainder + * Generates an instruction to calculate {@link TypeKind#FLOAT floats} + * remainder. + * * @return this builder + * @see Opcode#FREM + * @see OperatorInstruction */ default CodeBuilder frem() { return with(OperatorInstruction.of(Opcode.FREM)); } /** - * Generate an instruction to return a float from the method + * Generates an instruction to return a {@link TypeKind#FLOAT float} from + * this method. + * * @return this builder + * @see Opcode#FRETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder freturn() { return return_(TypeKind.FLOAT); } /** - * Generate an instruction to store a float into a local variable - * - *

    This may also generate {@code fstore_} and - * {@code wide fstore} instructions. + * Generates an instruction to store a {@link TypeKind#FLOAT float} into a + * local variable. + *

    + * This may also generate {@link Opcode#FSTORE_0 fstore_<N>} and + * {@link Opcode#FSTORE_W wide fstore} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#FSTORE + * @see #storeLocal(TypeKind, int) + * @see StoreInstruction */ default CodeBuilder fstore(int slot) { return storeLocal(TypeKind.FLOAT, slot); } /** - * Generate an instruction to subtract floats + * Generates an instruction to subtract {@link TypeKind#FLOAT floats}. + * * @return this builder + * @see Opcode#FSUB + * @see OperatorInstruction */ default CodeBuilder fsub() { return with(OperatorInstruction.of(Opcode.FSUB)); } /** - * Generate an instruction to fetch field from an object + * Generates an instruction to fetch field from an object. + * * @param ref the field reference * @return this builder + * @see Opcode#GETFIELD + * @see #fieldAccess(Opcode, FieldRefEntry) + * @see FieldInstruction */ default CodeBuilder getfield(FieldRefEntry ref) { return fieldAccess(Opcode.GETFIELD, ref); } /** - * Generate an instruction to fetch field from an object + * Generates an instruction to fetch field from an object. + * * @param owner the owner class * @param name the field name * @param type the field type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#GETFIELD + * @see #fieldAccess(Opcode, ClassDesc, String, ClassDesc) + * @see FieldInstruction */ default CodeBuilder getfield(ClassDesc owner, String name, ClassDesc type) { return fieldAccess(Opcode.GETFIELD, owner, name, type); } /** - * Generate an instruction to get static field from a class + * Generates an instruction to get static field from a class or interface. + * * @param ref the field reference * @return this builder + * @see Opcode#GETSTATIC + * @see #fieldAccess(Opcode, FieldRefEntry) + * @see FieldInstruction */ default CodeBuilder getstatic(FieldRefEntry ref) { return fieldAccess(Opcode.GETSTATIC, ref); } /** - * Generate an instruction to get static field from a class + * Generates an instruction to get static field from a class or interface. + * * @param owner the owner class * @param name the field name * @param type the field type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#GETSTATIC + * @see #fieldAccess(Opcode, ClassDesc, String, ClassDesc) + * @see FieldInstruction */ default CodeBuilder getstatic(ClassDesc owner, String name, ClassDesc type) { return fieldAccess(Opcode.GETSTATIC, owner, name, type); } /** - * Generate an instruction to branch always + * Generates an instruction to branch always. + *

    + * This may also generate {@link Opcode#GOTO_W goto_w} instructions if + * {@link ShortJumpsOption#FIX_SHORT_JUMPS} is set. * - *

    This may also generate {@code goto_w} instructions if the {@link - * ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS FIX_SHORT_JUMPS} option - * is set. - * - * @apiNote The instruction's name is {@code goto}, which coincides with a - * reserved keyword of the Java programming language, thus this method is - * named with an extra {@code _} suffix instead. + * @apiNote + * The instruction's name is {@code goto}, which coincides with a reserved + * keyword of the Java programming language, thus this method is named with + * an extra {@code _} suffix instead. * * @param target the branch target * @return this builder + * @see Opcode#GOTO + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder goto_(Label target) { return branch(Opcode.GOTO, target); } /** - * Generate an instruction to branch always with wide index + * Generates an instruction to branch always with wide index. + * * @param target the branch target * @return this builder + * @see Opcode#GOTO_W + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder goto_w(Label target) { return branch(Opcode.GOTO_W, target); } /** - * Generate an instruction to convert an int into a byte + * Generates an instruction to truncate an {@link TypeKind#INT int} into the + * range of {@link TypeKind#BYTE byte} and sign-extend it. + * * @return this builder + * @see Opcode#I2B + * @see ConvertInstruction */ default CodeBuilder i2b() { return with(ConvertInstruction.of(Opcode.I2B)); } /** - * Generate an instruction to convert an int into a char + * Generates an instruction to truncate an {@link TypeKind#INT int} into the + * range of {@link TypeKind#CHAR char} and zero-extend it. + * * @return this builder + * @see Opcode#I2C + * @see ConvertInstruction */ default CodeBuilder i2c() { return with(ConvertInstruction.of(Opcode.I2C)); } /** - * Generate an instruction to convert an int into a double + * Generates an instruction to convert an {@link TypeKind#INT int} into a + * {@link TypeKind#DOUBLE double}. + * * @return this builder + * @see Opcode#I2D + * @see ConvertInstruction */ default CodeBuilder i2d() { return with(ConvertInstruction.of(Opcode.I2D)); } /** - * Generate an instruction to convert an int into a float + * Generates an instruction to convert an {@link TypeKind#INT int} into a + * {@link TypeKind#FLOAT float}. + * * @return this builder + * @see Opcode#I2F + * @see ConvertInstruction */ default CodeBuilder i2f() { return with(ConvertInstruction.of(Opcode.I2F)); } /** - * Generate an instruction to convert an int into a long + * Generates an instruction to convert an {@link TypeKind#INT int} into a + * {@link TypeKind#LONG long}. + * * @return this builder + * @see Opcode#I2L + * @see ConvertInstruction */ default CodeBuilder i2l() { return with(ConvertInstruction.of(Opcode.I2L)); } /** - * Generate an instruction to convert an int into a short + * Generates an instruction to truncate an {@link TypeKind#INT int} into the + * range of {@link TypeKind#SHORT short} and sign-extend it. + * * @return this builder + * @see Opcode#I2S + * @see ConvertInstruction */ default CodeBuilder i2s() { return with(ConvertInstruction.of(Opcode.I2S)); } /** - * Generate an instruction to add an int + * Generates an instruction to add two {@link TypeKind#INT ints}. + * * @return this builder + * @see Opcode#IADD + * @see OperatorInstruction */ default CodeBuilder iadd() { return with(OperatorInstruction.of(Opcode.IADD)); } /** - * Generate an instruction to load a int from an array + * Generates an instruction to load from an {@link TypeKind#INT int} array. + * * @return this builder + * @see Opcode#IALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder iaload() { return arrayLoad(TypeKind.INT); } /** - * Generate an instruction to calculate boolean AND of ints + * Generates an instruction to calculate bitwise AND of {@link TypeKind#INT + * ints}, also used for {@link TypeKind#BOOLEAN boolean} AND. + * * @return this builder + * @see Opcode#IAND + * @see OperatorInstruction */ default CodeBuilder iand() { return with(OperatorInstruction.of(Opcode.IAND)); } /** - * Generate an instruction to store into an int array + * Generates an instruction to store into an {@link TypeKind#INT int} array. + * * @return this builder + * @see Opcode#IASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder iastore() { return arrayStore(TypeKind.INT); } /** - * Generate an instruction pushing int constant 0 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 0 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_0 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_0() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_0)); } /** - * Generate an instruction pushing int constant 1 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 1 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_1 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_1() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_1)); } /** - * Generate an instruction pushing int constant 2 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 2 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_2 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_2() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_2)); } /** - * Generate an instruction pushing int constant 3 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 3 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_3 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_3() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_3)); } /** - * Generate an instruction pushing int constant 4 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 4 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_4 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_4() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_4)); } /** - * Generate an instruction pushing int constant 5 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant 5 onto + * the operand stack. + * * @return this builder + * @see Opcode#ICONST_5 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_5() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_5)); } /** - * Generate an instruction pushing int constant -1 onto the operand stack + * Generates an instruction pushing {@link TypeKind#INT int} constant -1 + * onto the operand stack. + * * @return this builder + * @see Opcode#ICONST_M1 + * @see #loadConstant(int) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder iconst_m1() { return with(ConstantInstruction.ofIntrinsic(Opcode.ICONST_M1)); } /** - * Generate an instruction to divide ints + * Generates an instruction to divide {@link TypeKind#INT ints}. + * * @return this builder + * @see Opcode#IDIV + * @see OperatorInstruction */ default CodeBuilder idiv() { return with(OperatorInstruction.of(Opcode.IDIV)); } /** - * Generate an instruction to branch if reference comparison succeeds + * Generates an instruction to branch if {@link TypeKind#REFERENCE reference} + * comparison {@code operand1 == operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ACMPEQ + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_acmpeq(Label target) { return branch(Opcode.IF_ACMPEQ, target); } /** - * Generate an instruction to branch if reference comparison succeeds + * Generates an instruction to branch if {@link TypeKind#REFERENCE reference} + * comparison {@code operand1 != operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ACMPNE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_acmpne(Label target) { return branch(Opcode.IF_ACMPNE, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 == operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPEQ + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmpeq(Label target) { return branch(Opcode.IF_ICMPEQ, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 >= operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPGE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmpge(Label target) { return branch(Opcode.IF_ICMPGE, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 > operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPGT + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmpgt(Label target) { return branch(Opcode.IF_ICMPGT, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 <= operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPLE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmple(Label target) { return branch(Opcode.IF_ICMPLE, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 < operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPLT + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmplt(Label target) { return branch(Opcode.IF_ICMPLT, target); } /** - * Generate an instruction to branch if int comparison succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * {@code operand1 != operand2} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IF_ICMPNE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder if_icmpne(Label target) { return branch(Opcode.IF_ICMPNE, target); } /** - * Generate an instruction to branch if reference is not null + * Generates an instruction to branch if {@link TypeKind#REFERENCE reference} + * is not {@code null}. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFNONNULL + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifnonnull(Label target) { return branch(Opcode.IFNONNULL, target); } /** - * Generate an instruction to branch if reference is null + * Generates an instruction to branch if {@link TypeKind#REFERENCE reference} + * is {@code null}. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFNULL + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifnull(Label target) { return branch(Opcode.IFNULL, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code == 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFEQ + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifeq(Label target) { return branch(Opcode.IFEQ, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code >= 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFGE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifge(Label target) { return branch(Opcode.IFGE, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code > 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFGT + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifgt(Label target) { return branch(Opcode.IFGT, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code <= 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFLE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifle(Label target) { return branch(Opcode.IFLE, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code < 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFLT + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder iflt(Label target) { return branch(Opcode.IFLT, target); } /** - * Generate an instruction to branch if int comparison with zero succeeds + * Generates an instruction to branch if {@link TypeKind#INT int} comparison + * with zero {@code != 0} succeeds. + *

    + * This may generate multiple instructions to accomplish the same effect if + * {@link ClassFile.ShortJumpsOption#FIX_SHORT_JUMPS} is set and {@code + * target} cannot be encoded as a BCI offset in {@code [-32768, 32767]}. + * * @param target the branch target * @return this builder + * @see Opcode#IFNE + * @see #branch(Opcode, Label) + * @see BranchInstruction */ default CodeBuilder ifne(Label target) { return branch(Opcode.IFNE, target); } /** - * Generate an instruction to increment a local variable by a constant + * Generates an instruction to increment an {@link TypeKind#INT int} local + * variable by a constant. + *

    + * This may also generate {@link Opcode#IINC_W wide iinc} instructions if + * {@code slot} exceeds {@code 255} or {@code val} exceeds the range of + * {@link TypeKind#BYTE byte}. + * * @param slot the local variable slot * @param val the increment value * @return this builder * @throws IllegalArgumentException if {@code slot} or {@code val} is out of range + * @see Opcode#IINC + * @see IncrementInstruction */ default CodeBuilder iinc(int slot, int val) { return with(IncrementInstruction.of(slot, val)); } /** - * Generate an instruction to load an int from a local variable - * - *

    This may also generate {@code iload_} and - * {@code wide iload} instructions. + * Generates an instruction to load an {@link TypeKind#INT int} from a local + * variable. + *

    + * This may also generate {@link Opcode#ILOAD_0 iload_<N>} and {@link + * Opcode#ILOAD_W wide iload} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#ILOAD + * @see #loadLocal(TypeKind, int) + * @see LoadInstruction */ default CodeBuilder iload(int slot) { return loadLocal(TypeKind.INT, slot); } /** - * Generate an instruction to multiply ints + * Generates an instruction to multiply {@link TypeKind#INT ints}. + * * @return this builder + * @see Opcode#IMUL + * @see OperatorInstruction */ default CodeBuilder imul() { return with(OperatorInstruction.of(Opcode.IMUL)); } /** - * Generate an instruction to negate an int + * Generates an instruction to negate an {@link TypeKind#INT int}. + * * @return this builder + * @see Opcode#INEG + * @see OperatorInstruction */ default CodeBuilder ineg() { return with(OperatorInstruction.of(Opcode.INEG)); } /** - * Generate an instruction to determine if an object is of the given type + * Generates an instruction to determine if an object is of the given type, + * producing a {@link TypeKind#BOOLEAN boolean} result on the operand stack. * - * @apiNote The instruction's name is {@code instanceof}, which coincides with a + * @apiNote + * The instruction's name is {@code instanceof}, which coincides with a * reserved keyword of the Java programming language, thus this method is * named with camel case instead. * * @param target the target type * @return this builder + * @see Opcode#INSTANCEOF + * @see TypeCheckInstruction */ default CodeBuilder instanceOf(ClassEntry target) { return with(TypeCheckInstruction.of(Opcode.INSTANCEOF, target)); } /** - * Generate an instruction to determine if an object is of the given type + * Generates an instruction to determine if an object is of the given type, + * producing a {@link TypeKind#BOOLEAN boolean} result on the operand stack. * - * @apiNote The instruction's name is {@code instanceof}, which coincides with a + * @apiNote + * The instruction's name is {@code instanceof}, which coincides with a * reserved keyword of the Java programming language, thus this method is * named with camel case instead. * * @param target the target type * @return this builder * @throws IllegalArgumentException if {@code target} represents a primitive type + * @see Opcode#INSTANCEOF + * @see TypeCheckInstruction */ default CodeBuilder instanceOf(ClassDesc target) { return instanceOf(constantPool().classEntry(target)); } /** - * Generate an instruction to invoke a dynamically-computed call site + * Generates an instruction to invoke a dynamically-computed call site. + * * @param ref the dynamic call site * @return this builder + * @see Opcode#INVOKEDYNAMIC + * @see InvokeDynamicInstruction */ default CodeBuilder invokedynamic(InvokeDynamicEntry ref) { return with(InvokeDynamicInstruction.of(ref)); } /** - * Generate an instruction to invoke a dynamically-computed call site + * Generates an instruction to invoke a dynamically-computed call site. + * * @param ref the dynamic call site * @return this builder + * @see Opcode#INVOKEDYNAMIC + * @see InvokeDynamicInstruction */ default CodeBuilder invokedynamic(DynamicCallSiteDesc ref) { MethodHandleEntry bsMethod = handleDescToHandleInfo(constantPool(), (DirectMethodHandleDesc) ref.bootstrapMethod()); @@ -1771,649 +2491,920 @@ default CodeBuilder invokedynamic(DynamicCallSiteDesc ref) { } /** - * Generate an instruction to invoke an interface method + * Generates an instruction to invoke an interface method. + * * @param ref the interface method reference * @return this builder + * @see Opcode#INVOKEINTERFACE + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokeinterface(InterfaceMethodRefEntry ref) { return invoke(Opcode.INVOKEINTERFACE, ref); } /** - * Generate an instruction to invoke an interface method - * @param owner the owner class + * Generates an instruction to invoke an interface method. + * + * @param owner the owner interface * @param name the method name * @param type the method type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKEINTERFACE + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokeinterface(ClassDesc owner, String name, MethodTypeDesc type) { return invoke(Opcode.INVOKEINTERFACE, constantPool().interfaceMethodRefEntry(owner, name, type)); } /** - * Generate an instruction to invoke an instance method; direct invocation of instance initialization - * methods and methods of the current class and its supertypes + * Generates an instruction to invoke an instance method in an interface; + * direct invocation of methods of the current class and its supertypes. + * * @param ref the interface method reference * @return this builder + * @see Opcode#INVOKESPECIAL + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokespecial(InterfaceMethodRefEntry ref) { return invoke(Opcode.INVOKESPECIAL, ref); } /** - * Generate an instruction to invoke an instance method; direct invocation of instance initialization - * methods and methods of the current class and its supertypes + * Generates an instruction to invoke an instance method in a class; direct + * invocation of instance initialization methods and methods of the current + * class and its supertypes. + * * @param ref the method reference * @return this builder + * @see Opcode#INVOKESPECIAL + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokespecial(MethodRefEntry ref) { return invoke(Opcode.INVOKESPECIAL, ref); } /** - * Generate an instruction to invoke an instance method; direct invocation of instance initialization - * methods and methods of the current class and its supertypes - * @param owner the owner class + * Generates an instruction to invoke an instance method in a class; direct + * invocation of instance initialization methods and methods of the current + * class and its supertypes. + * + * @param owner the owner class, must not be an interface * @param name the method name * @param type the method type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKESPECIAL + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type) { return invoke(Opcode.INVOKESPECIAL, owner, name, type, false); } /** - * Generate an instruction to invoke an instance method; direct invocation of instance initialization - * methods and methods of the current class and its supertypes - * @param owner the owner class + * Generates an instruction to invoke an instance method; direct invocation + * of instance initialization methods and methods of the current class and + * its supertypes. + * + * @param owner the owner class or interface * @param name the method name * @param type the method type - * @param isInterface the interface method invocation indication + * @param isInterface whether the owner is an interface * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKESPECIAL + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { return invoke(Opcode.INVOKESPECIAL, owner, name, type, isInterface); } /** - * Generate an instruction to invoke a class (static) method + * Generates an instruction to invoke a class (static) method of an interface. + * * @param ref the interface method reference * @return this builder + * @see Opcode#INVOKESTATIC + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokestatic(InterfaceMethodRefEntry ref) { return invoke(Opcode.INVOKESTATIC, ref); } /** - * Generate an instruction to invoke a class (static) method + * Generates an instruction to invoke a class (static) method of a class. + * * @param ref the method reference * @return this builder + * @see Opcode#INVOKESTATIC + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokestatic(MethodRefEntry ref) { return invoke(Opcode.INVOKESTATIC, ref); } /** - * Generate an instruction to invoke a class (static) method - * @param owner the owner class + * Generates an instruction to invoke a class (static) method of a class. + * + * @param owner the owner class, must not be an interface * @param name the method name * @param type the method type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKESTATIC + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type) { return invoke(Opcode.INVOKESTATIC, owner, name, type, false); } /** - * Generate an instruction to invoke a class (static) method - * @param owner the owner class + * Generates an instruction to invoke a class (static) method. + * + * @param owner the owner class or interface * @param name the method name * @param type the method type - * @param isInterface the interface method invocation indication + * @param isInterface whether the owner is an interface * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKESTATIC + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { return invoke(Opcode.INVOKESTATIC, owner, name, type, isInterface); } /** - * Generate an instruction to invoke an instance method; dispatch based on class + * Generates an instruction to invoke an instance method; dispatch based on class. + * * @param ref the method reference * @return this builder + * @see Opcode#INVOKEVIRTUAL + * @see #invoke(Opcode, MemberRefEntry) + * @see InvokeInstruction */ default CodeBuilder invokevirtual(MethodRefEntry ref) { return invoke(Opcode.INVOKEVIRTUAL, ref); } /** - * Generate an instruction to invoke an instance method; dispatch based on class - * @param owner the owner class + * Generates an instruction to invoke an instance method; dispatch based on class. + * + * @param owner the owner class, must not be an interface * @param name the method name * @param type the method type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#INVOKEVIRTUAL + * @see #invoke(Opcode, ClassDesc, String, MethodTypeDesc, boolean) + * @see InvokeInstruction */ default CodeBuilder invokevirtual(ClassDesc owner, String name, MethodTypeDesc type) { return invoke(Opcode.INVOKEVIRTUAL, owner, name, type, false); } /** - * Generate an instruction to calculate boolean OR of ints + * Generates an instruction to calculate bitwise OR of {@link TypeKind#INT + * ints}, also used for {@link TypeKind#BOOLEAN boolean} OR. + * * @return this builder + * @see Opcode#IOR + * @see OperatorInstruction */ default CodeBuilder ior() { return with(OperatorInstruction.of(Opcode.IOR)); } /** - * Generate an instruction to calculate ints remainder + * Generates an instruction to calculate {@link TypeKind#INT ints} remainder. + * * @return this builder + * @see Opcode#IREM + * @see OperatorInstruction */ default CodeBuilder irem() { return with(OperatorInstruction.of(Opcode.IREM)); } /** - * Generate an instruction to return an int from the method + * Generates an instruction to return an {@link TypeKind#INT int} from this + * method. + * * @return this builder + * @see Opcode#IRETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder ireturn() { return return_(TypeKind.INT); } /** - * Generate an instruction to shift an int left + * Generates an instruction to shift an {@link TypeKind#INT int} left. + * * @return this builder + * @see Opcode#ISHL + * @see OperatorInstruction */ default CodeBuilder ishl() { return with(OperatorInstruction.of(Opcode.ISHL)); } /** - * Generate an instruction to shift an int right + * Generates an instruction to shift an {@link TypeKind#INT int} right. + * This carries the sign bit to the vacated most significant bits, as + * opposed to {@link #iushr()} that fills vacated most significant bits with + * {@code 0}. + * * @return this builder + * @see Opcode#ISHR + * @see OperatorInstruction */ default CodeBuilder ishr() { return with(OperatorInstruction.of(Opcode.ISHR)); } /** - * Generate an instruction to store an int into a local variable - * - *

    This may also generate {@code istore_} and - * {@code wide istore} instructions. + * Generates an instruction to store an {@link TypeKind#INT int} into a + * local variable. + *

    + * This may also generate {@link Opcode#ISTORE_0 istore_<N>} and + * {@link Opcode#ISTORE_W wide istore} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#ISTORE + * @see #storeLocal(TypeKind, int) + * @see StoreInstruction */ default CodeBuilder istore(int slot) { return storeLocal(TypeKind.INT, slot); } /** - * Generate an instruction to subtract ints + * Generates an instruction to subtract {@link TypeKind#INT ints}. + * * @return this builder + * @see Opcode#ISUB + * @see OperatorInstruction */ default CodeBuilder isub() { return with(OperatorInstruction.of(Opcode.ISUB)); } /** - * Generate an instruction to logical shift an int right + * Generates an instruction to logical shift an {@link TypeKind#INT int} + * right. This fills vacated most significant bits with {@code 0}, as + * opposed to {@link #ishr()} that carries the sign bit to the vacated most + * significant bits. + * * @return this builder + * @see Opcode#IUSHR + * @see OperatorInstruction */ default CodeBuilder iushr() { return with(OperatorInstruction.of(Opcode.IUSHR)); } /** - * Generate an instruction to calculate boolean XOR of ints + * Generates an instruction to calculate bitwise XOR of {@link TypeKind#INT + * ints}. This can also be used for {@link TypeKind#BOOLEAN boolean} XOR. + * * @return this builder + * @see Opcode#IXOR + * @see OperatorInstruction */ default CodeBuilder ixor() { return with(OperatorInstruction.of(Opcode.IXOR)); } /** - * Generate an instruction to access a jump table by key match and jump + * Generates an instruction to access a jump table by key match and jump. + * * @param defaultTarget the default jump target * @param cases the switch cases * @return this builder + * @see Opcode#LOOKUPSWITCH + * @see LookupSwitchInstruction */ default CodeBuilder lookupswitch(Label defaultTarget, List cases) { return with(LookupSwitchInstruction.of(defaultTarget, cases)); } /** - * Generate an instruction to convert a long into a double + * Generates an instruction to convert a {@link TypeKind#LONG long} into a + * {@link TypeKind#DOUBLE double}. + * * @return this builder + * @see Opcode#L2D + * @see OperatorInstruction */ default CodeBuilder l2d() { return with(ConvertInstruction.of(Opcode.L2D)); } /** - * Generate an instruction to convert a long into a float + * Generates an instruction to convert a {@link TypeKind#LONG long} into a + * {@link TypeKind#FLOAT float}. + * * @return this builder + * @see Opcode#L2F + * @see OperatorInstruction */ default CodeBuilder l2f() { return with(ConvertInstruction.of(Opcode.L2F)); } /** - * Generate an instruction to convert a long into an int + * Generates an instruction to convert a {@link TypeKind#LONG long} into an + * {@link TypeKind#INT int}. + * * @return this builder + * @see Opcode#L2I + * @see OperatorInstruction */ default CodeBuilder l2i() { return with(ConvertInstruction.of(Opcode.L2I)); } /** - * Generate an instruction to add a long + * Generates an instruction to add two {@link TypeKind#LONG longs}. + * * @return this builder + * @see Opcode#LADD + * @see OperatorInstruction */ default CodeBuilder ladd() { return with(OperatorInstruction.of(Opcode.LADD)); } /** - * Generate an instruction to load a long from an array + * Generates an instruction to load from a {@link TypeKind#LONG long} array. + * * @return this builder + * @see Opcode#LALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder laload() { return arrayLoad(TypeKind.LONG); } /** - * Generate an instruction to calculate boolean AND of longs + * Generates an instruction to calculate bitwise AND of {@link TypeKind#LONG + * longs}. + * * @return this builder + * @see Opcode#LAND + * @see OperatorInstruction */ default CodeBuilder land() { return with(OperatorInstruction.of(Opcode.LAND)); } /** - * Generate an instruction to store into a long array + * Generates an instruction to store into a {@link TypeKind#LONG long} array. + * * @return this builder + * @see Opcode#LASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder lastore() { return arrayStore(TypeKind.LONG); } /** - * Generate an instruction to compare longs + * Generates an instruction to compare {@link TypeKind#LONG longs}. + * * @return this builder + * @see Opcode#LCMP + * @see OperatorInstruction */ default CodeBuilder lcmp() { return with(OperatorInstruction.of(Opcode.LCMP)); } /** - * Generate an instruction pushing long constant 0 onto the operand stack + * Generates an instruction pushing {@link TypeKind#LONG long} constant 0 + * onto the operand stack. + * * @return this builder + * @see Opcode#LCONST_0 + * @see #loadConstant(long) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder lconst_0() { return with(ConstantInstruction.ofIntrinsic(Opcode.LCONST_0)); } /** - * Generate an instruction pushing long constant 1 onto the operand stack + * Generates an instruction pushing {@link TypeKind#LONG long} constant 1 + * onto the operand stack. + * * @return this builder + * @see Opcode#LCONST_1 + * @see #loadConstant(long) + * @see ConstantInstruction.IntrinsicConstantInstruction */ default CodeBuilder lconst_1() { return with(ConstantInstruction.ofIntrinsic(Opcode.LCONST_1)); } /** - * Generate an instruction pushing an item from the run-time constant pool onto the operand stack - * - *

    This may also generate {@code ldc_w} and {@code ldc2_w} instructions. + * Generates an instruction pushing an item from the run-time constant pool + * onto the operand stack. + *

    + * This may also generate {@link Opcode#LDC_W ldc_w} and {@link Opcode#LDC2_W + * ldc2_w} instructions. * - * @apiNote {@link #loadConstant(ConstantDesc) loadConstant} generates more optimal instructions - * and should be used for general constants if an {@code ldc} instruction is not strictly required. + * @apiNote + * {@link #loadConstant(ConstantDesc) loadConstant} generates more optimal + * instructions and should be used for general constants if an {@code ldc} + * instruction is not strictly required. * * @param value the constant value * @return this builder + * @see Opcode#LDC + * @see #loadConstant(ConstantDesc) + * @see ConstantInstruction.LoadConstantInstruction */ default CodeBuilder ldc(ConstantDesc value) { return ldc(BytecodeHelpers.constantEntry(constantPool(), value)); } /** - * Generate an instruction pushing an item from the run-time constant pool onto the operand stack - * - *

    This may also generate {@code ldc_w} and {@code ldc2_w} instructions. + * Generates an instruction pushing an item from the run-time constant pool + * onto the operand stack. + *

    + * This may also generate {@link Opcode#LDC_W ldc_w} and {@link Opcode#LDC2_W + * ldc2_w} instructions. * * @param entry the constant value * @return this builder + * @see Opcode#LDC + * @see #loadConstant(ConstantDesc) + * @see ConstantInstruction.LoadConstantInstruction */ default CodeBuilder ldc(LoadableConstantEntry entry) { return with(ConstantInstruction.ofLoad(BytecodeHelpers.ldcOpcode(entry), entry)); } /** - * Generate an instruction to divide longs + * Generates an instruction to divide {@link TypeKind#LONG longs}. + * * @return this builder + * @see Opcode#LDIV + * @see OperatorInstruction */ default CodeBuilder ldiv() { return with(OperatorInstruction.of(Opcode.LDIV)); } /** - * Generate an instruction to load a long from a local variable - * - *

    This may also generate {@code lload_} and - * {@code wide lload} instructions. + * Generates an instruction to load a {@link TypeKind#LONG long} from a + * local variable. + *

    + * This may also generate {@link Opcode#LLOAD_0 lload_<N>} and {@link + * Opcode#LLOAD_W wide lload} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#LLOAD + * @see #loadLocal(TypeKind, int) + * @see LoadInstruction */ default CodeBuilder lload(int slot) { return loadLocal(TypeKind.LONG, slot); } /** - * Generate an instruction to multiply longs + * Generates an instruction to multiply {@link TypeKind#LONG longs}. + * * @return this builder + * @see Opcode#LMUL + * @see OperatorInstruction */ default CodeBuilder lmul() { return with(OperatorInstruction.of(Opcode.LMUL)); } /** - * Generate an instruction to negate a long + * Generates an instruction to negate a {@link TypeKind#LONG long}. + * * @return this builder + * @see Opcode#LNEG + * @see OperatorInstruction */ default CodeBuilder lneg() { return with(OperatorInstruction.of(Opcode.LNEG)); } /** - * Generate an instruction to calculate boolean OR of longs + * Generates an instruction to calculate bitwise OR of {@link TypeKind#LONG + * longs}. + * * @return this builder + * @see Opcode#LOR + * @see OperatorInstruction */ default CodeBuilder lor() { return with(OperatorInstruction.of(Opcode.LOR)); } /** - * Generate an instruction to calculate longs remainder + * Generates an instruction to calculate {@link TypeKind#LONG longs} + * remainder. + * * @return this builder + * @see Opcode#LREM + * @see OperatorInstruction */ default CodeBuilder lrem() { return with(OperatorInstruction.of(Opcode.LREM)); } /** - * Generate an instruction to return a long from the method + * Generates an instruction to return a {@link TypeKind#LONG long} from this + * method. + * * @return this builder + * @see Opcode#LRETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder lreturn() { return return_(TypeKind.LONG); } /** - * Generate an instruction to shift a long left + * Generates an instruction to shift a {@link TypeKind#LONG long} left. + * * @return this builder + * @see Opcode#LSHL + * @see OperatorInstruction */ default CodeBuilder lshl() { return with(OperatorInstruction.of(Opcode.LSHL)); } /** - * Generate an instruction to shift a long right + * Generates an instruction to shift a {@link TypeKind#LONG long} right. + * This carries the sign bit to the vacated most significant bits, as + * opposed to {@link #lushr()} that fills vacated most significant bits with + * {@code 0}. + * * @return this builder + * @see Opcode#LSHR + * @see OperatorInstruction */ default CodeBuilder lshr() { return with(OperatorInstruction.of(Opcode.LSHR)); } /** - * Generate an instruction to store a long into a local variable - * - *

    This may also generate {@code lstore_} and - * {@code wide lstore} instructions. + * Generates an instruction to store a {@link TypeKind#LONG long} into a + * local variable. + *

    + * This may also generate {@link Opcode#LSTORE_0 lstore_<N>} and + * {@link Opcode#LSTORE_W wide lstore} instructions. * * @param slot the local variable slot * @return this builder * @throws IllegalArgumentException if {@code slot} is out of range + * @see Opcode#LSTORE + * @see #storeLocal(TypeKind, int) + * @see StoreInstruction */ default CodeBuilder lstore(int slot) { return storeLocal(TypeKind.LONG, slot); } /** - * Generate an instruction to subtract longs + * Generates an instruction to subtract {@link TypeKind#LONG longs}. + * * @return this builder + * @see Opcode#LSUB + * @see OperatorInstruction */ default CodeBuilder lsub() { return with(OperatorInstruction.of(Opcode.LSUB)); } /** - * Generate an instruction to logical shift a long left + * Generates an instruction to logical shift a {@link TypeKind#LONG long} + * right. This fills vacated most significant bits with {@code 0}, as + * opposed to {@link #lshr()} that carries the sign bit to the vacated most + * significant bits. + * * @return this builder + * @see Opcode#LUSHR + * @see OperatorInstruction */ default CodeBuilder lushr() { return with(OperatorInstruction.of(Opcode.LUSHR)); } /** - * Generate an instruction to calculate boolean XOR of longs + * Generates an instruction to calculate bitwise XOR of {@link TypeKind#LONG + * longs}. + * * @return this builder + * @see Opcode#LXOR + * @see OperatorInstruction */ default CodeBuilder lxor() { return with(OperatorInstruction.of(Opcode.LXOR)); } /** - * Generate an instruction to enter monitor for an object + * Generates an instruction to enter monitor for an object. + * * @return this builder + * @see Opcode#MONITORENTER + * @see MonitorInstruction */ default CodeBuilder monitorenter() { return with(MonitorInstruction.of(Opcode.MONITORENTER)); } /** - * Generate an instruction to exit monitor for an object + * Generates an instruction to exit monitor for an object. + * * @return this builder + * @see Opcode#MONITOREXIT + * @see MonitorInstruction */ default CodeBuilder monitorexit() { return with(MonitorInstruction.of(Opcode.MONITOREXIT)); } /** - * Generate an instruction to create a new multidimensional array + * Generates an instruction to create a new multidimensional array. + * * @param array the array type * @param dims the number of dimensions * @return this builder * @throws IllegalArgumentException if {@code dims} is out of range + * @see Opcode#MULTIANEWARRAY + * @see NewMultiArrayInstruction */ default CodeBuilder multianewarray(ClassEntry array, int dims) { return with(NewMultiArrayInstruction.of(array, dims)); } /** - * Generate an instruction to create a new multidimensional array + * Generates an instruction to create a new multidimensional array. + * * @param array the array type * @param dims the number of dimensions * @return this builder * @throws IllegalArgumentException if {@code array} represents a primitive type - * or if {@code dims} is out of range + * or if {@code dims} is out of range + * @see Opcode#MULTIANEWARRAY + * @see NewMultiArrayInstruction */ default CodeBuilder multianewarray(ClassDesc array, int dims) { return multianewarray(constantPool().classEntry(array), dims); } /** - * Generate an instruction to create a new object + * Generates an instruction to create a new object. * - * @apiNote The instruction's name is {@code new}, which coincides with a - * reserved keyword of the Java programming language, thus this method is - * named with an extra {@code _} suffix instead. + * @apiNote + * The instruction's name is {@code new}, which coincides with a reserved + * keyword of the Java programming language, thus this method is named with + * an extra {@code _} suffix instead. * * @param clazz the new class type * @return this builder + * @see Opcode#NEW + * @see NewObjectInstruction */ default CodeBuilder new_(ClassEntry clazz) { return with(NewObjectInstruction.of(clazz)); } /** - * Generate an instruction to create a new object + * Generates an instruction to create a new object. * - * @apiNote The instruction's name is {@code new}, which coincides with a - * reserved keyword of the Java programming language, thus this method is - * named with an extra {@code _} suffix instead. + * @apiNote + * The instruction's name is {@code new}, which coincides with a reserved + * keyword of the Java programming language, thus this method is named with + * an extra {@code _} suffix instead. * * @param clazz the new class type * @return this builder * @throws IllegalArgumentException if {@code clazz} represents a primitive type + * @see Opcode#NEW + * @see NewObjectInstruction */ default CodeBuilder new_(ClassDesc clazz) { return new_(constantPool().classEntry(clazz)); } /** - * Generate an instruction to create a new array of a primitive type + * Generates an instruction to create a new array of a primitive type. + * * @param typeKind the primitive array type * @return this builder * @throws IllegalArgumentException when the {@code typeKind} is not a legal * primitive array component type + * @see Opcode#NEWARRAY + * @see NewPrimitiveArrayInstruction */ default CodeBuilder newarray(TypeKind typeKind) { return with(NewPrimitiveArrayInstruction.of(typeKind)); } /** - * Generate an instruction to pop the top operand stack value + * Generates an instruction to pop the top operand stack value. + * * @return this builder + * @see Opcode#POP + * @see StackInstruction */ default CodeBuilder pop() { return with(StackInstruction.of(Opcode.POP)); } /** - * Generate an instruction to pop the top one or two operand stack values + * Generates an instruction to pop the top one or two operand stack values. + * * @return this builder + * @see Opcode#POP2 + * @see StackInstruction */ default CodeBuilder pop2() { return with(StackInstruction.of(Opcode.POP2)); } /** - * Generate an instruction to set field in an object + * Generates an instruction to set field in an object. + * * @param ref the field reference * @return this builder + * @see Opcode#PUTFIELD + * @see #fieldAccess(Opcode, FieldRefEntry) + * @see FieldInstruction */ default CodeBuilder putfield(FieldRefEntry ref) { return fieldAccess(Opcode.PUTFIELD, ref); } /** - * Generate an instruction to set field in an object + * Generates an instruction to set field in an object. + * * @param owner the owner class * @param name the field name * @param type the field type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#PUTFIELD + * @see #fieldAccess(Opcode, ClassDesc, String, ClassDesc) + * @see FieldInstruction */ default CodeBuilder putfield(ClassDesc owner, String name, ClassDesc type) { return fieldAccess(Opcode.PUTFIELD, owner, name, type); } /** - * Generate an instruction to set static field in a class + * Generates an instruction to set static field in a class. + * * @param ref the field reference * @return this builder + * @see Opcode#PUTSTATIC + * @see #fieldAccess(Opcode, FieldRefEntry) + * @see FieldInstruction */ default CodeBuilder putstatic(FieldRefEntry ref) { return fieldAccess(Opcode.PUTSTATIC, ref); } /** - * Generate an instruction to set static field in a class - * @param owner the owner class + * Generates an instruction to set static field in a class. + * + * @param owner the owner class or interface * @param name the field name * @param type the field type * @return this builder * @throws IllegalArgumentException if {@code owner} represents a primitive type + * @see Opcode#PUTSTATIC + * @see #fieldAccess(Opcode, ClassDesc, String, ClassDesc) + * @see FieldInstruction */ default CodeBuilder putstatic(ClassDesc owner, String name, ClassDesc type) { return fieldAccess(Opcode.PUTSTATIC, owner, name, type); } /** - * Generate an instruction to return void from the method + * Generates an instruction to return {@link TypeKind#VOID void} from this + * method. * - * @apiNote The instruction's name is {@code return}, which coincides with a - * reserved keyword of the Java programming language, thus this method is - * named with an extra {@code _} suffix instead. + * @apiNote + * The instruction's name is {@code return}, which coincides with a reserved + * keyword of the Java programming language, thus this method is named with + * an extra {@code _} suffix instead. * * @return this builder + * @see Opcode#RETURN + * @see #return_(TypeKind) + * @see ReturnInstruction */ default CodeBuilder return_() { return return_(TypeKind.VOID); } /** - * Generate an instruction to load a short from an array + * Generates an instruction to load from a {@link TypeKind#SHORT short} + * array. + * * @return this builder + * @see Opcode#SALOAD + * @see #arrayLoad(TypeKind) + * @see ArrayLoadInstruction */ default CodeBuilder saload() { return arrayLoad(TypeKind.SHORT); } /** - * Generate an instruction to store into a short array + * Generates an instruction to store into a {@link TypeKind#SHORT short} + * array. + * * @return this builder + * @see Opcode#SASTORE + * @see #arrayStore(TypeKind) + * @see ArrayStoreInstruction */ default CodeBuilder sastore() { return arrayStore(TypeKind.SHORT); } /** - * Generate an instruction pushing an int in the range of short onto the operand stack. + * Generates an instruction pushing an {@link TypeKind#INT int} in the range + * of {@link TypeKind#SHORT short}, {@code [-32768, 32767]}, onto the + * operand stack. + * * @param s the int in the range of short * @return this builder * @throws IllegalArgumentException if {@code s} is out of range of short + * @see Opcode#SIPUSH + * @see #loadConstant(int) + * @see ConstantInstruction.ArgumentConstantInstruction */ default CodeBuilder sipush(int s) { return with(ConstantInstruction.ofArgument(Opcode.SIPUSH, s)); } /** - * Generate an instruction to swap the top two operand stack values + * Generates an instruction to swap the top two operand stack values. + * * @return this builder + * @see Opcode#SWAP + * @see StackInstruction */ default CodeBuilder swap() { return with(StackInstruction.of(Opcode.SWAP)); } /** - * Generate an instruction to access a jump table by index and jump - * @param low the low key value - * @param high the high key value + * Generates an instruction to access a jump table by index and jump. + * + * @param low the minimum key, inclusive + * @param high the maximum key, inclusive * @param defaultTarget the default jump target * @param cases the switch cases * @return this builder + * @see Opcode#TABLESWITCH + * @see TableSwitchInstruction */ default CodeBuilder tableswitch(int low, int high, Label defaultTarget, List cases) { return with(TableSwitchInstruction.of(low, high, defaultTarget, cases)); } /** - * Generate an instruction to access a jump table by index and jump + * Generates an instruction to access a jump table by index and jump. + * Computes the minimum and maximum keys from the {@code cases}. + * * @param defaultTarget the default jump target * @param cases the switch cases * @return this builder + * @see Opcode#TABLESWITCH + * @see #tableswitch(int, int, Label, List) + * @see TableSwitchInstruction */ default CodeBuilder tableswitch(Label defaultTarget, List cases) { int low = Integer.MAX_VALUE; diff --git a/src/java.base/share/classes/java/lang/classfile/CodeElement.java b/src/java.base/share/classes/java/lang/classfile/CodeElement.java index 63669d41014bd..9ca5138334403 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeElement.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,13 +29,20 @@ import java.lang.classfile.attribute.StackMapTableAttribute; /** - * A marker interface for elements that can appear when traversing - * a {@link CodeModel} or be presented to a {@link CodeBuilder}. Code elements - * are either an {@link Instruction}, which models an instruction in the body - * of a method, or a {@link PseudoInstruction}, which models metadata from - * the code attribute, such as line number metadata, local variable metadata, - * exception metadata, label target metadata, etc. + * Marker interface for a member element of a {@link CodeModel}. Such an + * element can appear when traversing a {@link CodeModel} unless otherwise + * specified, be supplied to a {@link CodeBuilder}, and be processed by a + * {@link CodeTransform}. + *

    + * Code elements can be categorized into {@link Instruction}, {@link + * PseudoInstruction}, and {@link Attribute}. Unlike in other {@link + * CompoundElement}, the order of elements for all {@link Instruction}s and some + * {@link PseudoInstruction}s is significant. * + * @see ClassFileElement##membership Membership Elements + * @see ClassElement + * @see MethodElement + * @see FieldElement * @sealedGraph * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/CodeModel.java b/src/java.base/share/classes/java/lang/classfile/CodeModel.java index 644f766056418..614b4cfda84cd 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeModel.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,17 +25,44 @@ package java.lang.classfile; +import java.lang.classfile.ClassFile.DeadLabelsOption; +import java.lang.classfile.ClassFile.DebugElementsOption; +import java.lang.classfile.ClassFile.LineNumbersOption; +import java.lang.classfile.attribute.BootstrapMethodsAttribute; import java.lang.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.instruction.ExceptionCatch; import java.util.List; import java.util.Optional; +import java.util.function.Consumer; import jdk.internal.classfile.impl.BufferedCodeBuilder; /** - * Models the body of a method (the {@code Code} attribute). The instructions - * of the method body are accessed via a streaming view. + * Models the body of a method (the {@code Code} attribute). A {@code Code} + * attribute is viewed as a {@linkplain CompoundElement composition} of {@link + * CodeElement}s, which is the only way to access {@link Instruction}s; the + * order of elements of a code model is significant. + *

    + * A {@code CodeModel} is obtained from {@link MethodModel#code()}, or in the + * traversal of the member elements of a method. + *

    + * {@link MethodBuilder#withCode} is the main way to build code models. {@link + * MethodBuilder#transformCode} and {@link CodeBuilder#transforming} allow + * creating new {@code Code} attributes by selectively processing the original + * code elements and directing the results to a code builder. + *

    + * A {@code Code} attribute holds attributes, but they are usually not member + * elements, but are decomposed to {@link PseudoInstruction}, accessible + * according to {@link DeadLabelsOption}, {@link DebugElementsOption}, and + * {@link LineNumbersOption}. {@link StackMapTableAttribute} can only be + * accessed via {@linkplain AttributedElement explicit attribute reading}, as it + * is considered a derived property from the code body. * + * @see MethodModel#code() + * @see CodeTransform + * @see CodeAttribute + * @jvms 4.7.3 The {@code Code} Attribute * @since 24 */ public sealed interface CodeModel diff --git a/src/java.base/share/classes/java/lang/classfile/CodeTransform.java b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java index b76c02bf5fb53..404656308531d 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,10 +32,22 @@ import static java.util.Objects.requireNonNull; /** - * A transformation on streams of {@link CodeElement}. - * - * @see ClassFileTransform + * A transformation on streams of {@link CodeElement}. The stream can come + * from a {@link CodeModel}, or a handler to a {@link CodeBuilder} as in + * {@link CodeBuilder#transforming}. + *

    + * Refer to {@link ClassFileTransform} for general guidance and caution around + * the use of transforms for structures in the {@code class} file format. + *

    + * A code transform can be lifted to a method or a class transform via {@link + * MethodTransform#transformingCode(CodeTransform)} and {@link + * ClassTransform#transformingMethodBodies(CodeTransform)}, transforming only + * the {@link CodeModel} within those structures and passing all other elements + * to the builders. * + * @see CodeModel + * @see MethodBuilder#transformCode + * @see CodeBuilder#transforming * @since 24 */ @FunctionalInterface @@ -43,7 +55,7 @@ public non-sealed interface CodeTransform extends ClassFileTransform { /** - * A code transform that sends all elements to the builder. + * A code transform that passes all elements to the builder. */ CodeTransform ACCEPT_ALL = new CodeTransform() { @Override @@ -53,7 +65,7 @@ public void accept(CodeBuilder builder, CodeElement element) { }; /** - * Create a stateful code transform from a {@link Supplier}. The supplier + * Creates a stateful code transform from a {@link Supplier}. The supplier * will be invoked for each transformation. * * @param supplier a {@link Supplier} that produces a fresh transform object @@ -65,7 +77,7 @@ static CodeTransform ofStateful(Supplier supplier) { } /** - * Create a code transform that passes each element through to the builder, + * Creates a code transform that passes each element through to the builder, * and calls the specified function when transformation is complete. * * @param finisher the function to call when transformation is complete diff --git a/src/java.base/share/classes/java/lang/classfile/CompoundElement.java b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java index d9f9fe1e5f939..1b06a26030206 100644 --- a/src/java.base/share/classes/java/lang/classfile/CompoundElement.java +++ b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,14 +37,26 @@ import jdk.internal.classfile.components.ClassPrinter; /** - * A {@link ClassFileElement} that has complex structure defined in terms of - * other classfile elements, such as a method, field, method body, or entire - * class. When encountering a {@linkplain CompoundElement}, clients have the - * option to treat the element as a single entity (e.g., an entire method) - * or to traverse the contents of that element with the methods in this class - * (e.g., {@link #forEach(Consumer)}, etc.) - * @param the element type + * A {@code class} file structure that can be viewed as a composition of its + * member structures. {@code CompoundElement} allows users to traverse these + * member elements with {@link #forEach(Consumer)} or {@link #elementStream()}, + * or buffer the elements obtained from the traversal through {@link + * #iterator()} or {@link #elementList()}. + *

    + * Unless otherwise specified, all member elements of compatible type will be + * presented during the traversal if they exist in this element. Some member + * elements specify that they may appear at most once in this element; if such + * elements are presented multiple times, the latest occurrence is authentic and + * all previous occurrences should be ignored. + *

    + * {@code CompoundElement}s can be constructed by {@link ClassFileBuilder}s. + * {@link ClassFileBuilder#transform(CompoundElement, ClassFileTransform)} + * provides an easy way to create a new structure by selectively processing + * the original member structures and directing the results to the builder. * + * @param the member element type + * @see ClassFileElement##membership Membership Elements + * @see ClassFileBuilder * @sealedGraph * @since 24 */ @@ -52,15 +64,16 @@ public sealed interface CompoundElement extends ClassFileElement, Iterable permits ClassModel, CodeModel, FieldModel, MethodModel, jdk.internal.classfile.impl.AbstractUnboundModel { /** - * Invoke the provided handler with each element contained in this - * compound element + * Invokes the provided handler with each member element in this compound + * element. + * * @param consumer the handler */ @Override void forEach(Consumer consumer); /** - * {@return an {@link Iterator} describing all the elements contained in this + * {@return an {@link Iterator} describing all member elements in this * compound element} */ @Override @@ -69,8 +82,8 @@ default Iterator iterator() { } /** - * {@return a {@link Stream} containing all the elements contained in this - * compound element} + * {@return a {@link Stream} containing all member elements in this compound + * element} */ default Stream elementStream() { return StreamSupport.stream(Spliterators.spliteratorUnknownSize( @@ -80,8 +93,8 @@ default Stream elementStream() { } /** - * {@return an {@link List} containing all the elements contained in this - * compound element} + * {@return a {@link List} containing all member elements in this compound + * element} */ default List elementList() { List list = new ArrayList<>(); @@ -95,9 +108,11 @@ public void accept(E e) { } /** - * {@return a text representation of the compound element and its contents for debugging purposes} + * {@return a text representation of the compound element and its contents + * for debugging purposes} * - * The format, structure and exact contents of the returned string are not specified and may change at any time in the future. + * The format, structure and exact contents of the returned string are not + * specified and may change at any time in the future. */ default String toDebugString() { StringBuilder text = new StringBuilder(); diff --git a/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java b/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java index c473e09cab722..477aa6984a238 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ package java.lang.classfile; -import java.lang.classfile.constantpool.Utf8Entry; +import java.lang.constant.ClassDesc; import java.lang.reflect.AccessFlag; import java.util.function.Consumer; @@ -34,14 +34,17 @@ import jdk.internal.classfile.impl.TerminalFieldBuilder; /** - * A builder for fields. Builders are not created directly; they are passed - * to handlers by methods such as {@link ClassBuilder#withField(Utf8Entry, Utf8Entry, Consumer)} - * or to field transforms. The elements of a field can be specified - * abstractly (by passing a {@link FieldElement} to {@link #with(ClassFileElement)} - * or concretely by calling the various {@code withXxx} methods. + * A builder for fields. The main way to obtain a field builder is via {@link + * ClassBuilder#withField(String, ClassDesc, Consumer)}. The {@linkplain + * ClassBuilder#withField(String, ClassDesc, int) access flag overload} is + * useful if no attribute needs to be configured, skipping the handler. + *

    + * Refer to {@link ClassFileBuilder} for general guidance and caution around + * the use of builders for structures in the {@code class} file format. * + * @see ClassBuilder#withField(String, ClassDesc, Consumer) + * @see FieldModel * @see FieldTransform - * * @since 24 */ public sealed interface FieldBuilder @@ -50,8 +53,12 @@ public sealed interface FieldBuilder /** * Sets the field access flags. + * * @param flags the access flags, as a bit mask * @return this builder + * @see AccessFlags + * @see AccessFlag.Location#FIELD + * @see ClassBuilder#withField(String, ClassDesc, int) */ default FieldBuilder withFlags(int flags) { return with(new AccessFlagsImpl(AccessFlag.Location.FIELD, flags)); @@ -59,8 +66,12 @@ default FieldBuilder withFlags(int flags) { /** * Sets the field access flags. + * * @param flags the access flags, as a bit mask * @return this builder + * @see AccessFlags + * @see AccessFlag.Location#FIELD + * @see ClassBuilder#withField(String, ClassDesc, int) */ default FieldBuilder withFlags(AccessFlag... flags) { return with(new AccessFlagsImpl(AccessFlag.Location.FIELD, flags)); diff --git a/src/java.base/share/classes/java/lang/classfile/FieldElement.java b/src/java.base/share/classes/java/lang/classfile/FieldElement.java index a2c1b22751efe..a1c9905b6ddb3 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldElement.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,18 @@ import java.lang.classfile.attribute.*; /** - * A marker interface for elements that can appear when traversing - * a {@link FieldModel} or be presented to a {@link FieldBuilder}. + * Marker interface for a member element of a {@link FieldModel}. Such an + * element can appear when traversing a {@link FieldModel} unless otherwise + * specified, be supplied to a {@link FieldBuilder}, and be processed by a + * {@link FieldTransform}. + *

    + * {@link AccessFlags} is the only member element of a field that appear exactly + * once during the traversal of a {@link FieldModel}. * + * @see ClassFileElement##membership Membership Elements + * @see ClassElement + * @see MethodElement + * @see CodeElement * @sealedGraph * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/FieldModel.java b/src/java.base/share/classes/java/lang/classfile/FieldModel.java index 89fa1e192b04f..21c3d903b68cd 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldModel.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,24 +27,43 @@ import java.lang.classfile.constantpool.Utf8Entry; import java.lang.constant.ClassDesc; +import java.lang.reflect.AccessFlag; import java.util.Optional; +import java.util.function.Consumer; import jdk.internal.classfile.impl.BufferedFieldBuilder; import jdk.internal.classfile.impl.FieldImpl; import jdk.internal.classfile.impl.Util; /** - * Models a field. The contents of the field can be traversed via - * a streaming view, or via random access (e.g., - * {@link #flags()}), or by freely mixing the two. + * Models a field. A field can be viewed as a {@linkplain CompoundElement + * composition} of {@link FieldElement}s, or by random access via accessor + * methods if only specific parts of the field is needed. + *

    + * Fields can be obtained from {@link ClassModel#fields()}, or in the traversal + * of member elements of a class. + *

    + * {@link ClassBuilder#withField(String, ClassDesc, Consumer)} is the main way + * to construct fields. {@link ClassBuilder#transformField} allows creating a + * new field by selectively processing the original field elements and directing + * the results to a field builder. + *

    + * All field attributes are accessible as member elements. * + * @see ClassModel#fields() + * @see FieldTransform + * @jvms 4.5 Fields * @since 24 */ public sealed interface FieldModel extends CompoundElement, AttributedElement, ClassElement permits BufferedFieldBuilder.Model, FieldImpl { - /** {@return the access flags} */ + /** + * {@return the access flags} + * + * @see AccessFlag.Location#FIELD + */ AccessFlags flags(); /** {@return the class model this field is a member of, if known} */ @@ -53,10 +72,10 @@ public sealed interface FieldModel /** {@return the name of this field} */ Utf8Entry fieldName(); - /** {@return the field descriptor of this field} */ + /** {@return the field descriptor string of this field} */ Utf8Entry fieldType(); - /** {@return the field descriptor of this field, as a symbolic descriptor} */ + /** {@return the field type, as a symbolic descriptor} */ default ClassDesc fieldTypeSymbol() { return Util.fieldTypeSymbol(fieldType()); } diff --git a/src/java.base/share/classes/java/lang/classfile/FieldTransform.java b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java index 90313ae48f061..ef55861a328e1 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +34,17 @@ /** * A transformation on streams of {@link FieldElement}. + *

    + * Refer to {@link ClassFileTransform} for general guidance and caution around + * the use of transforms for structures in the {@code class} file format. + *

    + * A field transform can be lifted to a class transform via {@link + * ClassTransform#transformingFields(FieldTransform)}, transforming only + * the {@link FieldModel} among the class members and passing all other elements + * to the builders. * - * @see ClassFileTransform - * + * @see FieldModel + * @see ClassBuilder#transformField * @since 24 */ @FunctionalInterface @@ -44,7 +52,7 @@ public non-sealed interface FieldTransform extends ClassFileTransform { /** - * A field transform that sends all elements to the builder. + * A field transform that passes all elements to the builder. */ FieldTransform ACCEPT_ALL = new FieldTransform() { @Override @@ -54,7 +62,7 @@ public void accept(FieldBuilder builder, FieldElement element) { }; /** - * Create a stateful field transform from a {@link Supplier}. The supplier + * Creates a stateful field transform from a {@link Supplier}. The supplier * will be invoked for each transformation. * * @param supplier a {@link Supplier} that produces a fresh transform object @@ -66,7 +74,7 @@ static FieldTransform ofStateful(Supplier supplier) { } /** - * Create a field transform that passes each element through to the builder, + * Creates a field transform that passes each element through to the builder, * and calls the specified function when transformation is complete. * * @param finisher the function to call when transformation is complete @@ -88,7 +96,7 @@ public void atEnd(FieldBuilder builder) { } /** - * Create a field transform that passes each element through to the builder, + * Creates a field transform that passes each element through to the builder, * except for those that the supplied {@link Predicate} is true for. * * @param filter the predicate that determines which elements to drop diff --git a/src/java.base/share/classes/java/lang/classfile/Instruction.java b/src/java.base/share/classes/java/lang/classfile/Instruction.java index 199aa6447a11a..12bf513e96aa6 100644 --- a/src/java.base/share/classes/java/lang/classfile/Instruction.java +++ b/src/java.base/share/classes/java/lang/classfile/Instruction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,12 +32,15 @@ /** * Models an executable instruction in the {@code code} array of the {@link - * CodeAttribute Code} attribute of a method. + * CodeAttribute Code} attribute of a method. The order of instructions in + * a {@link CodeModel} is significant. *

    * The {@link #opcode() opcode} identifies the operation of an instruction. * Each {@linkplain Opcode#kind() kind} of opcode has its own modeling interface * for instructions. * + * @see Opcode + * @jvms 6.5 Instructions * @sealedGraph * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/Interfaces.java b/src/java.base/share/classes/java/lang/classfile/Interfaces.java index 2c0e5b2e54b9c..bd89c494f24c2 100644 --- a/src/java.base/share/classes/java/lang/classfile/Interfaces.java +++ b/src/java.base/share/classes/java/lang/classfile/Interfaces.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,22 @@ import jdk.internal.classfile.impl.Util; /** - * Models the interfaces of a class. Delivered as a {@link - * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}. + * Models the interfaces (JVMS {@jvms 4.1}) of a class. An {@code Interfaces} + * appears at most once in a {@link ClassModel}: if it does not appear, the + * class has no interfaces, which is equivalent to an {@code Interfaces} whose + * {@link #interfaces()} returns an empty list. A {@link ClassBuilder} sets + * the interfaces to an empty list if the interfaces is not supplied. * + * @see ClassModel#interfaces() + * @see ClassBuilder#withInterfaces + * @jvms 4.1 The {@code ClassFile} Structure * @since 24 */ public sealed interface Interfaces extends ClassElement permits InterfacesImpl { - /** {@return the interfaces of this class} */ + /** {@return the interfaces of this class, may be empty} */ List interfaces(); /** @@ -64,6 +70,7 @@ static Interfaces of(ClassEntry... interfaces) { /** * {@return an {@linkplain Interfaces} element} * @param interfaces the interfaces + * @throws IllegalArgumentException if any of {@code interfaces} is primitive */ static Interfaces ofSymbols(List interfaces) { return of(Util.entryList(interfaces)); @@ -72,6 +79,7 @@ static Interfaces ofSymbols(List interfaces) { /** * {@return an {@linkplain Interfaces} element} * @param interfaces the interfaces + * @throws IllegalArgumentException if any of {@code interfaces} is primitive */ static Interfaces ofSymbols(ClassDesc... interfaces) { return ofSymbols(Arrays.asList(interfaces)); diff --git a/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java b/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java index 747cbe2e10770..ff777246fdeb1 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ package java.lang.classfile; -import java.lang.classfile.constantpool.Utf8Entry; +import java.lang.constant.MethodTypeDesc; import java.lang.reflect.AccessFlag; import java.util.function.Consumer; @@ -34,14 +34,18 @@ import jdk.internal.classfile.impl.TerminalMethodBuilder; /** - * A builder for methods. Builders are not created directly; they are passed - * to handlers by methods such as {@link ClassBuilder#withMethod(Utf8Entry, Utf8Entry, int, Consumer)} - * or to method transforms. The elements of a method can be specified - * abstractly (by passing a {@link MethodElement} to {@link #with(ClassFileElement)} - * or concretely by calling the various {@code withXxx} methods. + * A builder for methods. The main way to obtain a method builder is via {@link + * ClassBuilder#withMethod(String, MethodTypeDesc, int, Consumer)}. {@link + * ClassBuilder#withMethodBody(String, MethodTypeDesc, int, Consumer)} is + * useful if no attribute on the method except {@link CodeModel Code} needs to + * be configured, skipping the method handler. + *

    + * Refer to {@link ClassFileBuilder} for general guidance and caution around + * the use of builders for structures in the {@code class} file format. * + * @see MethodModel * @see MethodTransform - * + * @jvms 4.6 Methods * @since 24 */ public sealed interface MethodBuilder @@ -49,18 +53,30 @@ public sealed interface MethodBuilder permits ChainedMethodBuilder, TerminalMethodBuilder { /** - * Sets the method access flags. + * Sets the method access flags. The {@link AccessFlag#STATIC} flag cannot + * be modified after the builder is created. + * * @param flags the access flags, as a bit mask * @return this builder + * @throws IllegalArgumentException if the {@link ClassFile#ACC_STATIC + * ACC_STATIC} flag is modified + * @see AccessFlags + * @see AccessFlag.Location#METHOD */ default MethodBuilder withFlags(int flags) { return with(new AccessFlagsImpl(AccessFlag.Location.METHOD, flags)); } /** - * Sets the method access flags. + * Sets the method access flags. The {@link AccessFlag#STATIC} flag cannot + * be modified after the builder is created. + * * @param flags the access flags, as a bit mask * @return this builder + * @throws IllegalArgumentException if the {@link ClassFile#ACC_STATIC + * ACC_STATIC} flag is modified + * @see AccessFlags + * @see AccessFlag.Location#METHOD */ default MethodBuilder withFlags(AccessFlag... flags) { return with(new AccessFlagsImpl(AccessFlag.Location.METHOD, flags)); @@ -68,24 +84,26 @@ default MethodBuilder withFlags(AccessFlag... flags) { /** * Build the method body for this method. + * * @param code a handler receiving a {@link CodeBuilder} * @return this builder + * @see CodeModel */ MethodBuilder withCode(Consumer code); /** * Build the method body for this method by transforming the body of another * method. - * - * @implNote - *

    This method behaves as if: + *

    + * This method behaves as if: * {@snippet lang=java : - * withCode(b -> b.transformCode(code, transform)); + * withCode(cob -> cob.transform(code, transform)); * } * * @param code the method body to be transformed * @param transform the transform to apply to the method body * @return this builder + * @see CodeTransform */ MethodBuilder transformCode(CodeModel code, CodeTransform transform); } diff --git a/src/java.base/share/classes/java/lang/classfile/MethodElement.java b/src/java.base/share/classes/java/lang/classfile/MethodElement.java index 77254a6a82c43..8905f1fbcc3ab 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodElement.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,18 @@ import java.lang.classfile.attribute.*; /** - * A marker interface for elements that can appear when traversing - * a {@link MethodModel} or be presented to a {@link MethodBuilder}. + * Marker interface for a member element of a {@link MethodModel}. Such an + * element can appear when traversing a {@link MethodModel} unless otherwise + * specified, be supplied to a {@link MethodBuilder}, and be processed by a + * {@link MethodTransform}. + *

    + * {@link AccessFlags} is the only member element of a method that appear + * exactly once during the traversal of a {@link MethodModel}. * + * @see ClassFileElement##membership Membership Elements + * @see ClassElement + * @see FieldElement + * @see CodeElement * @sealedGraph * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/MethodModel.java b/src/java.base/share/classes/java/lang/classfile/MethodModel.java index d88051a5eb3f6..758223debe5c7 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodModel.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,24 +27,43 @@ import java.lang.classfile.constantpool.Utf8Entry; import java.lang.constant.MethodTypeDesc; +import java.lang.reflect.AccessFlag; import java.util.Optional; +import java.util.function.Consumer; import jdk.internal.classfile.impl.BufferedMethodBuilder; import jdk.internal.classfile.impl.MethodImpl; import jdk.internal.classfile.impl.Util; /** - * Models a method. The contents of the method can be traversed via - * a streaming view, or via random access (e.g., - * {@link #flags()}), or by freely mixing the two. + * Models a method. A method can be viewed as a {@linkplain CompoundElement + * composition} of {@link MethodElement}s, or by random access via accessor + * methods if only specific parts of the method is needed. + *

    + * Methods can be obtained from {@link ClassModel#methods()}, or in the + * traversal of member elements of a class. + *

    + * {@link ClassBuilder#withMethod(String, MethodTypeDesc, int, Consumer)} is the + * main way to construct methods. {@link ClassBuilder#transformMethod} allows + * creating a new method by selectively processing the original method elements + * and directing the results to a method builder. + *

    + * All method attributes are accessible as member elements. * + * @see ClassModel#methods() + * @see MethodTransform + * @jvms 4.6 Methods * @since 24 */ public sealed interface MethodModel extends CompoundElement, AttributedElement, ClassElement permits BufferedMethodBuilder.Model, MethodImpl { - /** {@return the access flags} */ + /** + * {@return the access flags} + * + * @see AccessFlag.Location#METHOD + */ AccessFlags flags(); /** {@return the class model this method is a member of, if known} */ @@ -53,10 +72,10 @@ public sealed interface MethodModel /** {@return the name of this method} */ Utf8Entry methodName(); - /** {@return the method descriptor of this method} */ + /** {@return the method descriptor string of this method} */ Utf8Entry methodType(); - /** {@return the method descriptor of this method, as a symbolic descriptor} */ + /** {@return the method type, as a symbolic descriptor} */ default MethodTypeDesc methodTypeSymbol() { return Util.methodTypeSymbol(methodType()); } diff --git a/src/java.base/share/classes/java/lang/classfile/MethodTransform.java b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java index 865fadbae873b..d7d9a8445aa55 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,9 +34,17 @@ /** * A transformation on streams of {@link MethodElement}. + *

    + * Refer to {@link ClassFileTransform} for general guidance and caution around + * the use of transforms for structures in the {@code class} file format. + *

    + * A method transform can be lifted to a class transform via {@link + * ClassTransform#transformingMethods(MethodTransform)}, transforming only + * the {@link MethodModel} among the class members and passing all other + * elements to the builders. * - * @see ClassFileTransform - * + * @see MethodModel + * @see ClassBuilder#transformMethod * @since 24 */ @FunctionalInterface @@ -44,7 +52,7 @@ public non-sealed interface MethodTransform extends ClassFileTransform { /** - * A method transform that sends all elements to the builder. + * A method transform that passes all elements to the builder. */ MethodTransform ACCEPT_ALL = new MethodTransform() { @Override @@ -54,7 +62,7 @@ public void accept(MethodBuilder builder, MethodElement element) { }; /** - * Create a stateful method transform from a {@link Supplier}. The supplier + * Creates a stateful method transform from a {@link Supplier}. The supplier * will be invoked for each transformation. * * @param supplier a {@link Supplier} that produces a fresh transform object @@ -67,7 +75,7 @@ static MethodTransform ofStateful(Supplier supplier) { } /** - * Create a method transform that passes each element through to the builder, + * Creates a method transform that passes each element through to the builder, * and calls the specified function when transformation is complete. * * @param finisher the function to call when transformation is complete @@ -89,7 +97,7 @@ public void atEnd(MethodBuilder builder) { } /** - * Create a method transform that passes each element through to the builder, + * Creates a method transform that passes each element through to the builder, * except for those that the supplied {@link Predicate} is true for. * * @param filter the predicate that determines which elements to drop @@ -104,8 +112,9 @@ static MethodTransform dropping(Predicate filter) { } /** - * Create a method transform that transforms {@link CodeModel} elements - * with the supplied code transform. + * Creates a method transform that transforms {@link CodeModel} elements + * with the supplied code transform, passing every other element through to + * the builder. * * @param xform the method transform * @return the class transform diff --git a/src/java.base/share/classes/java/lang/classfile/Opcode.java b/src/java.base/share/classes/java/lang/classfile/Opcode.java index a3b0a37076336..99ea4696f60eb 100644 --- a/src/java.base/share/classes/java/lang/classfile/Opcode.java +++ b/src/java.base/share/classes/java/lang/classfile/Opcode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ * instead of wide pseudo-opcodes. * * @see Instruction - * + * @jvms 6.5 Instructions * @since 24 */ public enum Opcode { @@ -1143,7 +1143,7 @@ public enum Opcode { LXOR(RawBytecodeHelper.LXOR, 1, Kind.OPERATOR), /** - * Increment local variable by constant. + * Increment {@link TypeKind#INT int} local variable by constant. * * @jvms 6.5.iinc iinc * @see Kind#INCREMENT diff --git a/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java b/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java index 456bce04c8021..6d2e76b5cb853 100644 --- a/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,13 +35,16 @@ import jdk.internal.classfile.impl.AbstractPseudoInstruction; /** - * Models metadata about a {@link CodeAttribute}, such as entries in the - * exception table, line number table, local variable table, or the mapping - * between instructions and labels. Pseudo-instructions are delivered as part - * of the element stream of a {@link CodeModel}. Delivery of some - * pseudo-instructions can be disabled by modifying the value of classfile - * options (e.g., {@link ClassFile.DebugElementsOption}). + * Models metadata about a {@link CodeModel}, derived from the {@link + * CodeAttribute Code} attribute itself or its attributes. + *

    + * Order is significant for some pseudo-instructions relative to {@link + * Instruction}s, such as {@link LabelTarget} or {@link LineNumber}. Some + * pseudo-instructions can be omitted in reading and writing according to + * certain {@link ClassFile.Option}s. These are specified in the corresponding + * modeling interfaces. * + * @sealedGraph * @since 24 */ public sealed interface PseudoInstruction diff --git a/src/java.base/share/classes/java/lang/classfile/Superclass.java b/src/java.base/share/classes/java/lang/classfile/Superclass.java index fe30fe8a8e3f7..34d11dc605f6e 100644 --- a/src/java.base/share/classes/java/lang/classfile/Superclass.java +++ b/src/java.base/share/classes/java/lang/classfile/Superclass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,24 @@ package java.lang.classfile; import java.lang.classfile.constantpool.ClassEntry; +import java.lang.constant.ClassDesc; import jdk.internal.classfile.impl.SuperclassImpl; /** - * Models the superclass of a class. Delivered as a {@link - * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}. + * Models the superclass (JVMS {@jvms 4.1}) of a class. A {@code Superclass} + * appears at most once in a {@link ClassModel}: it must be absent for + * {@linkplain ClassModel#isModuleInfo() module descriptors} or the {@link + * Object} class, and must be present otherwise. A {@link ClassBuilder} sets + * the {@link Object} class as the superclass if the superclass is not supplied + * and the class to build is required to have a superclass. + *

    + * All {@linkplain ClassFile#ACC_INTERFACE interfaces} have {@link Object} as + * their superclass. * + * @see ClassModel#superclass() + * @see ClassBuilder#withSuperclass + * @jvms 4.1 The {@code ClassFile} Structure * @since 24 */ public sealed interface Superclass @@ -43,6 +54,7 @@ public sealed interface Superclass /** * {@return a {@linkplain Superclass} element} + * * @param superclassEntry the superclass */ static Superclass of(ClassEntry superclassEntry) { diff --git a/src/java.base/share/classes/java/lang/classfile/TypeKind.java b/src/java.base/share/classes/java/lang/classfile/TypeKind.java index e3fc11858f564..d912c5c37acf1 100644 --- a/src/java.base/share/classes/java/lang/classfile/TypeKind.java +++ b/src/java.base/share/classes/java/lang/classfile/TypeKind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,11 +108,16 @@ public enum TypeKind { */ LONG(2, 11), /** - * The primitive type {@code float}. + * The primitive type {@code float}. All NaN values of {@code float} may or + * may not be collapsed into a single {@linkplain Float#NaN "canonical" NaN + * value} in loading and storing. */ FLOAT(1, 6), /** - * The primitive type {@code double}. It is of {@linkplain #slotSize() category} 2. + * The primitive type {@code double}. It is of {@linkplain #slotSize() + * category} 2. All NaN values of {@code double} may or may not be + * collapsed into a single {@linkplain Double#NaN "canonical" NaN value} + * in loading and storing. */ DOUBLE(2, 7), // End primitive types diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/CodeAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/CodeAttribute.java index 4a06fe2d61019..743014704f901 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/CodeAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/CodeAttribute.java @@ -49,6 +49,7 @@ * being built. * * @see Attributes#code() + * @see CodeModel * @jvms 4.7.3 The {@code Code} Attribute * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java index 1394ee592edae..960d3755c4cde 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java @@ -68,7 +68,8 @@ public sealed interface InnerClassInfo /** * {@return a bit mask of flags denoting access permissions and properties - * of the inner class} + * of the inner class} It is in the range of unsigned short, {@code [0, + * 0xFFFF]}. * * @see Class#getModifiers() * @see AccessFlag.Location#INNER_CLASS diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/MethodParameterInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/MethodParameterInfo.java index 0366ec07e2506..636c671f25ad9 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/MethodParameterInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/MethodParameterInfo.java @@ -53,7 +53,8 @@ public sealed interface MethodParameterInfo Optional name(); /** - * {@return the access flags, as a bit mask} + * {@return the access flags, as a bit mask} It is in the range of unsigned + * short, {@code [0, 0xFFFF]}. * * @see Parameter#getModifiers() * @see AccessFlag.Location#METHOD_PARAMETER diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleAttribute.java index 231796c1b818a..ad564913d84f5 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleAttribute.java @@ -81,7 +81,8 @@ public sealed interface ModuleAttribute ModuleEntry moduleName(); /** - * {@return the module flags of the module, as a bit mask} + * {@return the module flags of the module, as a bit mask} It is in the + * range of unsigned short, {@code [0, 0xFFFF]}. * * @see ModuleDescriptor#modifiers() * @see AccessFlag.Location#MODULE diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleExportInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleExportInfo.java index 2071561a1e55e..e498b8bc036e8 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleExportInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleExportInfo.java @@ -58,6 +58,7 @@ public sealed interface ModuleExportInfo /** * {@return the flags associated with this export declaration, as a bit mask} + * It is in the range of unsigned short, {@code [0, 0xFFFF]}. * * @see ModuleDescriptor.Exports#modifiers() * @see AccessFlag.Location#MODULE_EXPORTS diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java index 16c0cf8a057b5..d183a0b498582 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java @@ -64,6 +64,7 @@ public sealed interface ModuleOpenInfo /** * {@return the flags associated with this open declaration, as a bit mask} + * It is in the range of unsigned short, {@code [0, 0xFFFF]}. * * @see ModuleDescriptor.Opens#modifiers() * @see AccessFlag.Location#MODULE_OPENS diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleRequireInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleRequireInfo.java index edffe9416295a..4954455409053 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleRequireInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleRequireInfo.java @@ -55,6 +55,7 @@ public sealed interface ModuleRequireInfo /** * {@return the flags associated with this require declaration, as a bit mask} + * It is in the range of unsigned short, {@code [0, 0xFFFF]}. * * @see ModuleDescriptor.Requires#modifiers() * @see AccessFlag.Location#MODULE_REQUIRES diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleResolutionAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleResolutionAttribute.java index 75e9ca485ff5b..039700f024a23 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleResolutionAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleResolutionAttribute.java @@ -78,7 +78,8 @@ public sealed interface ModuleResolutionAttribute permits BoundAttribute.BoundModuleResolutionAttribute, UnboundAttribute.UnboundModuleResolutionAttribute { /** - * {@return the module resolution flags} + * {@return the module resolution flags} It is in the range of unsigned + * short, {@code [0, 0xFFFF]}. *

    * The value of the resolution_flags item is a mask of flags used to denote * properties of module resolution. The flags are as follows: diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java index 260fc982dab07..b7145eeb59cb5 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java @@ -467,6 +467,9 @@ default ConstantDynamicEntry constantDynamicEntry(DynamicConstantDesc dcd) { /** * {@return a {@link FloatEntry} describing the provided value} + *

    + * All NaN values of the {@code float} may or may not be collapsed into a + * single {@linkplain Float#NaN "canonical" NaN value}. * * @param value the value * @see FloatEntry#floatValue() FloatEntry::floatValue @@ -483,6 +486,9 @@ default ConstantDynamicEntry constantDynamicEntry(DynamicConstantDesc dcd) { /** * {@return a {@link DoubleEntry} describing the provided value} + *

    + * All NaN values of the {@code double} may or may not be collapsed into a + * single {@linkplain Double#NaN "canonical" NaN value}. * * @param value the value * @see DoubleEntry#doubleValue() DoubleEntry::doubleValue diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/ExceptionCatch.java b/src/java.base/share/classes/java/lang/classfile/instruction/ExceptionCatch.java index 2a86c4bd09c2c..e924ca718e77d 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/ExceptionCatch.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/ExceptionCatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,6 +54,7 @@ * } * * @see CodeBuilder#exceptionCatch CodeBuilder::exceptionCatch + * @see CodeAttribute#exceptionHandlers() * @jvms 4.7.3 The {@code Code} Attribute * @since 24 */ diff --git a/src/java.base/share/classes/java/lang/classfile/package-info.java b/src/java.base/share/classes/java/lang/classfile/package-info.java index 2d6a8959a2de5..b5d79ff6e7e71 100644 --- a/src/java.base/share/classes/java/lang/classfile/package-info.java +++ b/src/java.base/share/classes/java/lang/classfile/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * 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,14 +25,16 @@ /** *

    Provides classfile parsing, generation, and transformation library.

    - * The {@code java.lang.classfile} package contains classes for reading, writing, and - * modifying Java class files, as specified in Chapter {@jvms 4} of the - * Java Virtual Machine Specification. + * The {@code java.lang.classfile} package contains API models for reading, + * writing, and modifying Java class files, as specified in Chapter {@jvms 4} of + * the Java Virtual Machine Specification. This package, {@link + * java.lang.classfile.attribute}, {@link java.lang.classfile.constantpool}, + * and {@link java.lang.classfile.instruction} form the Class-File API. * *

    Reading classfiles

    - * The main class for reading classfiles is {@link java.lang.classfile.ClassModel}; we - * convert bytes into a {@link java.lang.classfile.ClassModel} with {@link - * java.lang.classfile.ClassFile#parse(byte[])}: + * The main class for reading classfiles is {@link ClassModel}; we + * convert bytes into a {@link ClassModel} with {@link + * ClassFile#parse(byte[])}: * * {@snippet lang=java : * ClassModel cm = ClassFile.of().parse(bytes); @@ -41,29 +43,32 @@ * There are several additional overloads of {@code parse} that let you specify * various processing options. *

    - * A {@link java.lang.classfile.ClassModel} is an immutable description of a class + * A {@link ClassModel} is an immutable description of a class * file. It provides accessor methods to get at class metadata (e.g., {@link - * java.lang.classfile.ClassModel#thisClass()}, {@link java.lang.classfile.ClassModel#flags()}), - * as well as subordinate classfile entities ({@link java.lang.classfile.ClassModel#fields()}, - * {@link java.lang.classfile.ClassModel#attributes()}). A {@link - * java.lang.classfile.ClassModel} is inflated lazily; most parts of the classfile are - * not parsed until they are actually needed. + * ClassModel#thisClass()}, {@link ClassModel#flags()}), + * as well as subordinate classfile entities ({@link ClassModel#fields()}, + * {@link ClassModel#attributes()}). A {@link + * ClassModel} is inflated lazily; most parts of the classfile are + * not parsed until they are actually needed. Due to the laziness, these models + * may not be thread safe. Additionally, invocations to accessor methods on + * models may lead to {@link IllegalArgumentException} due to malformed {@code + * class} file format, as parsing happens lazily. *

    * We can enumerate the names of the fields and methods in a class by: * {@snippet lang="java" class="PackageSnippets" region="enumerateFieldsMethods1"} *

    - * When we enumerate the methods, we get a {@link java.lang.classfile.MethodModel} for each method; like a + * When we enumerate the methods, we get a {@link MethodModel} for each method; like a * {@code ClassModel}, it gives us access to method metadata and * the ability to descend into subordinate entities such as the bytecodes of the * method body. In this way, a {@code ClassModel} is the root of a * tree, with children for fields, methods, and attributes, and {@code MethodModel} in * turn has its own children (attributes, {@code CodeModel}, etc.) *

    - * Methods like {@link java.lang.classfile.ClassModel#methods} allows us to traverse the class structure + * Methods like {@link ClassModel#methods} allows us to traverse the class structure * explicitly, going straight to the parts we are interested in. This is useful * for certain kinds of analysis, but if we wanted to process the whole * classfile, we may want something more organized. A {@link - * java.lang.classfile.ClassModel} also provides us with a view of the classfile as a + * ClassModel} also provides us with a view of the classfile as a * series of class elements, which may include methods, fields, attributes, * and more, and which can be distinguished with pattern matching. We could * rewrite the above example as: @@ -87,24 +92,24 @@ * models and elements. Models represent complex structures, * such as classes, methods, fields, record elements, or the code body of a * method. Models can be explored either via random-access navigation (such as - * the {@link java.lang.classfile.ClassModel#methods()} accessor) or as a linear + * the {@link ClassModel#methods()} accessor) or as a linear * sequence of elements. (Elements can in turn also be models; a {@link - * java.lang.classfile.FieldModel} is also an element of a class.) For each model type - * (e.g., {@link java.lang.classfile.MethodModel}), there is a corresponding element - * type ({@link java.lang.classfile.MethodElement}). Models and elements are immutable + * FieldModel} is also an element of a class.) For each model type + * (e.g., {@link MethodModel}), there is a corresponding element + * type ({@link MethodElement}). Models and elements are immutable * and are inflated lazily so creating a model does not necessarily require * processing its entire content. * *

    The constant pool

    * Much of the interesting content in a classfile lives in the constant - * pool. {@link java.lang.classfile.ClassModel} provides a lazily-inflated, - * read-only view of the constant pool via {@link java.lang.classfile.ClassModel#constantPool()}. + * pool. {@link ClassModel} provides a lazily-inflated, + * read-only view of the constant pool via {@link ClassModel#constantPool()}. * Descriptions of classfile content is often exposed in the form of various - * subtypes of {@link java.lang.classfile.constantpool.PoolEntry}, such as {@link - * java.lang.classfile.constantpool.ClassEntry} or {@link java.lang.classfile.constantpool.Utf8Entry}. + * subtypes of {@link PoolEntry}, such as {@link + * ClassEntry} or {@link Utf8Entry}. *

    * Constant pool entries are also exposed through models and elements; in the - * above traversal example, the {@link java.lang.classfile.instruction.InvokeInstruction} + * above traversal example, the {@link InvokeInstruction} * element exposed a method for {@code owner} that corresponds to a {@code * Constant_Class_info} entry in the constant pool. * @@ -112,9 +117,9 @@ * Much of the contents of a classfile is stored in attributes; attributes are * found on classes, methods, fields, record components, and on the {@code Code} * attribute. Most attributes are surfaced as elements; for example, {@link - * java.lang.classfile.attribute.SignatureAttribute} is a {@link - * java.lang.classfile.ClassElement}, {@link java.lang.classfile.MethodElement}, and {@link - * java.lang.classfile.FieldElement} since it can appear in all of those places, and is + * SignatureAttribute} is a {@link + * ClassElement}, {@link MethodElement}, and {@link + * FieldElement} since it can appear in all of those places, and is * included when iterating the elements of the corresponding model. *

    * Some attributes are not surfaced as elements; these are attributes that are @@ -125,77 +130,84 @@ * treated as part of the structure they are coupled to (the entries of the * {@code BootstrapMethods} attribute are treated as part of the constant pool; * line numbers and local variable metadata are modeled as elements of {@link - * java.lang.classfile.CodeModel}.) + * CodeModel}.) *

    * The {@code Code} attribute, in addition to being modeled as a {@link - * java.lang.classfile.MethodElement}, is also a model in its own right ({@link - * java.lang.classfile.CodeModel}) due to its complex structure. + * MethodElement}, is also a model in its own right ({@link + * CodeModel}) due to its complex structure. *

    * Each standard attribute has an interface (in {@code java.lang.classfile.attribute}) * which exposes the contents of the attribute and provides factories to * construct the attribute. For example, the {@code Signature} attribute is - * defined by the {@link java.lang.classfile.attribute.SignatureAttribute} class, and - * provides accessors for {@link java.lang.classfile.attribute.SignatureAttribute#signature()} - * as well as factories taking {@link java.lang.classfile.constantpool.Utf8Entry} or - * {@link java.lang.String}. + * defined by the {@link SignatureAttribute} class, and + * provides accessors for {@link SignatureAttribute#signature()} + * as well as factories taking {@link Utf8Entry} or + * {@link String}. * *

    Custom attributes

    * Attributes are converted between their classfile form and their corresponding - * object form via an {@link java.lang.classfile.AttributeMapper}. An {@code + * object form via an {@link AttributeMapper}. An {@code * AttributeMapper} provides the - * {@link java.lang.classfile.AttributeMapper#readAttribute(AttributedElement, + * {@link AttributeMapper#readAttribute(AttributedElement, * ClassReader, int)} method for mapping from the classfile format * to an attribute instance, and the - * {@link java.lang.classfile.AttributeMapper#writeAttribute(java.lang.classfile.BufWriter, - * java.lang.classfile.Attribute)} method for mapping back to the classfile format. It also + * {@link AttributeMapper#writeAttribute(BufWriter, + * Attribute)} method for mapping back to the classfile format. It also * contains metadata including the attribute name, the set of classfile entities * where the attribute is applicable, and whether multiple attributes of the * same kind are allowed on a single entity. *

    - * There are built-in attribute mappers (in {@link java.lang.classfile.Attributes}) for + * There are built-in attribute mappers (in {@link Attributes}) for * each of the attribute types defined in section {@jvms 4.7} of The Java Virtual * Machine Specification, as well as several common nonstandard attributes used by the * JDK such as {@code CharacterRangeTable}. *

    * Unrecognized attributes are delivered as elements of type {@link - * java.lang.classfile.attribute.UnknownAttribute}, which provide access only to the + * UnknownAttribute}, which provide access only to the * {@code byte[]} contents of the attribute. *

    * For nonstandard attributes, user-provided attribute mappers can be specified * through the use of the {@link - * java.lang.classfile.ClassFile.AttributeMapperOption#of(java.util.function.Function)}} + * ClassFile.AttributeMapperOption#of(Function)}} * classfile option. Implementations of custom attributes should extend {@link - * java.lang.classfile.CustomAttribute}. + * CustomAttribute}. * - *

    Options

    + *

    Options

    *

    - * {@link java.lang.classfile.ClassFile#of(java.lang.classfile.ClassFile.Option[])} - * accepts a list of options. {@link java.lang.classfile.ClassFile.Option} is a base interface + * {@link ClassFile#of(ClassFile.Option[])} + * accepts a list of options. {@link ClassFile.Option} is a base interface * for some statically enumerated options, as well as factories for more complex options, * including: *

      - *
    • {@link java.lang.classfile.ClassFile.AttributeMapperOption#of(java.util.function.Function)} + *
    • {@link ClassFile.AttributeMapperOption#of(Function)} * -- specify format of custom attributes
    • - *
    • {@link java.lang.classfile.ClassFile.AttributesProcessingOption} + *
    • {@link ClassFile.AttributesProcessingOption} * -- unrecognized or problematic original attributes (default is {@code PASS_ALL_ATTRIBUTES})
    • - *
    • {@link java.lang.classfile.ClassFile.ClassHierarchyResolverOption#of(java.lang.classfile.ClassHierarchyResolver)} + *
    • {@link ClassFile.ClassHierarchyResolverOption#of(ClassHierarchyResolver)} * -- specify a custom class hierarchy resolver used by stack map generation
    • - *
    • {@link java.lang.classfile.ClassFile.ConstantPoolSharingOption}} + *
    • {@link ClassFile.ConstantPoolSharingOption}} * -- share constant pool when transforming (default is {@code SHARED_POOL})
    • - *
    • {@link java.lang.classfile.ClassFile.DeadCodeOption}} + *
    • {@link ClassFile.DeadCodeOption}} * -- patch out unreachable code (default is {@code PATCH_DEAD_CODE})
    • - *
    • {@link java.lang.classfile.ClassFile.DeadLabelsOption}} + *
    • {@link ClassFile.DeadLabelsOption}} * -- filter unresolved labels (default is {@code FAIL_ON_DEAD_LABELS})
    • - *
    • {@link java.lang.classfile.ClassFile.DebugElementsOption} + *
    • {@link ClassFile.DebugElementsOption} * -- processing of debug information, such as local variable metadata (default is {@code PASS_DEBUG})
    • - *
    • {@link java.lang.classfile.ClassFile.LineNumbersOption} + *
    • {@link ClassFile.LineNumbersOption} * -- processing of line numbers (default is {@code PASS_LINE_NUMBERS})
    • - *
    • {@link java.lang.classfile.ClassFile.ShortJumpsOption} + *
    • {@link ClassFile.ShortJumpsOption} * -- automatically rewrite short jumps to long when necessary (default is {@code FIX_SHORT_JUMPS})
    • - *
    • {@link java.lang.classfile.ClassFile.StackMapsOption} + *
    • {@link ClassFile.StackMapsOption} * -- generate stackmaps (default is {@code STACK_MAPS_WHEN_REQUIRED})
    • *
    *

    + * {@link ClassFile.AttributeMapperOption} and {@link ClassFile.ClassHierarchyResolverOption} + * are critical to the correctness of {@code class} file parsing and generation. + * The attribute mapper is required to parse custom attributes. A correct + * resolver is required to generate {@code class} files that refer to classes + * not available to the system class loader in its bytecode, or in corner cases, + * when generation wishes to avoid loading system classes, such as in agents. + *

    * Most options allow you to request that certain parts of the classfile be * skipped during traversal, such as debug information or unrecognized * attributes. Some options allow you to suppress generation of portions of the @@ -207,8 +219,8 @@ *

    Writing classfiles

    * ClassFile generation is accomplished through builders. For each * entity type that has a model, there is also a corresponding builder type; - * classes are built through {@link java.lang.classfile.ClassBuilder}, methods through - * {@link java.lang.classfile.MethodBuilder}, etc. + * classes are built through {@link ClassBuilder}, methods through + * {@link MethodBuilder}, etc. *

    * Rather than creating builders directly, builders are provided as an argument * to a user-provided lambda. To generate the familiar "hello world" program, @@ -226,34 +238,34 @@ * Builders often support multiple ways of expressing the same entity at * different levels of abstraction. For example, the {@code invokevirtual} * instruction invoking {@code println} could have been generated with {@link - * java.lang.classfile.CodeBuilder#invokevirtual(java.lang.constant.ClassDesc, - * java.lang.String, java.lang.constant.MethodTypeDesc) CodeBuilder.invokevirtual}, {@link - * java.lang.classfile.CodeBuilder#invoke(java.lang.classfile.Opcode, - * java.lang.constant.ClassDesc, java.lang.String, java.lang.constant.MethodTypeDesc, - * boolean) CodeBuilder.invokeInstruction}, or {@link - * java.lang.classfile.CodeBuilder#with(java.lang.classfile.ClassFileElement) + * CodeBuilder#invokevirtual(ClassDesc, + * String, MethodTypeDesc) CodeBuilder.invokevirtual}, {@link + * CodeBuilder#invoke(Opcode, + * ClassDesc, String, MethodTypeDesc, + * boolean) CodeBuilder.invoke}, or {@link + * CodeBuilder#with(ClassFileElement) * CodeBuilder.with}. *

    * The convenience method {@code CodeBuilder.invokevirtual} behaves as if it calls - * the convenience method {@code CodeBuilder.invokeInstruction}, which in turn behaves + * the convenience method {@code CodeBuilder.invoke}, which in turn behaves * as if it calls method {@code CodeBuilder.with}. This composing of method calls on the * builder enables the composing of transforms (as described later). *

    * Unless otherwise noted, passing a {@code null} argument to a constructor * or method of any Class-File API class or interface will cause a {@link - * java.lang.NullPointerException NullPointerException} to be thrown. Additionally, + * NullPointerException} to be thrown. Additionally, * invoking a method with an array or collection containing a {@code null} element * will cause a {@code NullPointerException}, unless otherwise specified.

    * *

    Symbolic information

    * To describe symbolic information for classes and types, the API uses the - * nominal descriptor abstractions from {@code java.lang.constant} such as {@link - * java.lang.constant.ClassDesc} and {@link java.lang.constant.MethodTypeDesc}, + * nominal descriptor abstractions from {@link java.lang.constant} such as {@link + * ClassDesc} and {@link MethodTypeDesc}, * which is less error-prone than using raw strings. *

    * If a constant pool entry has a nominal representation then it provides a * method returning the corresponding nominal descriptor type e.g. - * method {@link java.lang.classfile.constantpool.ClassEntry#asSymbol} returns + * method {@link ClassEntry#asSymbol} returns * {@code ClassDesc}. *

    * Where appropriate builders provide two methods for building an element with @@ -266,13 +278,14 @@ * methods accepts the provided information without implicit validation. * However, fatal inconsistencies (like for example invalid code sequence or * unresolved labels) affects internal tools and may cause exceptions later in - * the classfile building process. + * the classfile building process. These fatal exceptions are thrown as + * {@link IllegalArgumentException}. *

    * Using nominal descriptors assures the right serial form is applied by the * ClassFile API library based on the actual context. Also these nominal * descriptors are validated during their construction, so it is not possible to * create them with invalid content by mistake. Following example pass class - * name to the {@link java.lang.constant.ClassDesc#of} method for validation + * name to the {@link ClassDesc#of} method for validation * and the library performs automatic conversion to the right internal form of * the class name when serialized in the constant pool as a class entry. * {@snippet lang=java : @@ -290,7 +303,7 @@ * } *

    * More complex verification of a classfile can be achieved by invocation of - * {@link java.lang.classfile.ClassFile#verify}. + * {@link ClassFile#verify}. * *

    Transforming classfiles

    * ClassFile Processing APIs are most frequently used to combine reading and @@ -301,9 +314,9 @@ * to the builder. *

    * If we wanted to strip out methods whose names starts with "debug", we could - * get an existing {@link java.lang.classfile.ClassModel}, build a new classfile that - * provides a {@link java.lang.classfile.ClassBuilder}, iterate the elements of the - * original {@link java.lang.classfile.ClassModel}, and pass through all of them to + * get an existing {@link ClassModel}, build a new classfile that + * provides a {@link ClassBuilder}, iterate the elements of the + * original {@link ClassModel}, and pass through all of them to * the builder except the methods we want to drop: * {@snippet lang="java" class="PackageSnippets" region="stripDebugMethods1"} *

    @@ -335,7 +348,7 @@ * operations can be more easily combined. Suppose we want to redirect * invocations of static methods on {@code Foo} to the corresponding method on * {@code Bar} instead. We could express this as a transformation on {@link - * java.lang.classfile.CodeElement}: + * CodeElement}: * {@snippet lang="java" class="PackageSnippets" region="fooToBarTransform"} *

    * We can then lift this transformation on code elements into a @@ -376,7 +389,7 @@ * {@snippet lang="java" class="PackageSnippets" region="instrumentCallsTransform"} *

    * Then we can compose {@code fooToBar} and {@code instrumentCalls} with {@link - * java.lang.classfile.CodeTransform#andThen(java.lang.classfile.CodeTransform)}: + * CodeTransform#andThen(CodeTransform)}: * * {@snippet lang=java : * var cc = ClassFile.of(); @@ -399,7 +412,7 @@ * attributes that are not transformed can be processed by bulk-copying their * bytes, rather than parsing them and regenerating their contents.) If * constant pool sharing is not desired it can be suppressed - * with the {@link java.lang.classfile.ClassFile.ConstantPoolSharingOption} option. + * with the {@link ClassFile.ConstantPoolSharingOption} option. * Such suppression may be beneficial when transformation removes many elements, * resulting in many unreferenced constant pool entries. * @@ -429,14 +442,14 @@ * corresponding interface to describe that element, and factory methods to * create that element. Some element kinds also have convenience methods on the * corresponding builder (e.g., {@link - * java.lang.classfile.CodeBuilder#invokevirtual(java.lang.constant.ClassDesc, - * java.lang.String, java.lang.constant.MethodTypeDesc)}). + * CodeBuilder#invokevirtual(ClassDesc, + * String, MethodTypeDesc)}). *

    * Most symbolic information in elements is represented by constant pool entries * (for example, the owner of a field is represented by a {@link - * java.lang.classfile.constantpool.ClassEntry}.) Factories and builders also - * accept nominal descriptors from {@code java.lang.constant} (e.g., {@link - * java.lang.constant.ClassDesc}.) + * ClassEntry}.) Factories and builders also + * accept nominal descriptors from {@link java.lang.constant} (e.g., {@link + * ClassDesc}.) * *

    Data model

    * We define each kind of element by its name, an optional arity indicator (zero @@ -485,7 +498,7 @@ * * Fields and methods are models with their own elements. The elements of fields * and methods are fairly simple; most of the complexity of methods lives in the - * {@link java.lang.classfile.CodeModel} (which models the {@code Code} attribute + * {@link CodeModel} (which models the {@code Code} attribute * along with the code-related attributes: stack map table, local variable table, * line number table, etc.) * @@ -502,7 +515,7 @@ * | ExceptionsAttribute?(List exceptions) * } * - * {@link java.lang.classfile.CodeModel} is unique in that its elements are ordered. + * {@link CodeModel} is unique in that its elements are ordered. * Elements of {@code Code} include ordinary bytecodes, as well as a number of pseudo-instructions * representing branch targets, line number metadata, local variable metadata, and * catch blocks. @@ -549,3 +562,13 @@ * @since 24 */ package java.lang.classfile; + +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.UnknownAttribute; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.PoolEntry; +import java.lang.classfile.constantpool.Utf8Entry; +import java.lang.classfile.instruction.InvokeInstruction; +import java.lang.constant.ClassDesc; +import java.lang.constant.MethodTypeDesc; +import java.util.function.Function; diff --git a/src/java.base/share/classes/java/lang/classfile/snippet-files/PackageSnippets.java b/src/java.base/share/classes/java/lang/classfile/snippet-files/PackageSnippets.java index 7a58da7f6cebc..df901b1a6ccd2 100644 --- a/src/java.base/share/classes/java/lang/classfile/snippet-files/PackageSnippets.java +++ b/src/java.base/share/classes/java/lang/classfile/snippet-files/PackageSnippets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.lang.classfile.snippets; import java.lang.classfile.*; +import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.instruction.*; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDescs; @@ -185,10 +186,14 @@ void fooToBarTransform() { // @start region="fooToBarTransform" CodeTransform fooToBar = (b, e) -> { if (e instanceof InvokeInstruction i - && i.owner().asInternalName().equals("Foo") - && i.opcode() == Opcode.INVOKESTATIC) - b.invoke(i.opcode(), CD_Bar, i.name().stringValue(), i.typeSymbol(), i.isInterface()); - else b.with(e); + && i.owner().name().equalsString("Foo") + && i.opcode() == Opcode.INVOKESTATIC) { + // remove the old element i by doing nothing to the builder + // add a new invokestatic instruction to the builder + b.invokestatic(CD_Bar, i.name().stringValue(), i.typeSymbol(), i.isInterface()); + } else { + b.with(e); // leaves the element in place + } }; // @end } @@ -324,4 +329,12 @@ void resolverExample() { ClassHierarchyResolver resolver = ClassHierarchyResolver.ofClassLoading(lookup).cached(); // @end } + + void manualReuseStackMaps(CodeBuilder cob, MethodModel method) { + // @start region="manual-reuse-stack-maps" + CodeAttribute code = method.findAttribute(Attributes.code()).orElseThrow(); + // Note that StackMapTable may be absent, representing code with no branching + code.findAttribute(Attributes.stackMapTable()).ifPresent(cob); + // @end + } } From ad01dfb670215a35d4151c7129c9086888e1f9e8 Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Mon, 27 Jan 2025 14:57:49 +0000 Subject: [PATCH 246/263] 8346920: Serial: Support allocation in old generation when heap is almost full Reviewed-by: tschatzl, gli, sjohanss --- src/hotspot/share/gc/serial/serialHeap.cpp | 21 +++++++++++++++++---- src/hotspot/share/gc/serial/serialHeap.hpp | 7 +++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 7575ed4d34fe4..2408a41a87b05 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -95,6 +95,7 @@ SerialHeap::SerialHeap() : _gc_policy_counters(new GCPolicyCounters("Copy:MSC", 2, 2)), _young_manager(nullptr), _old_manager(nullptr), + _is_heap_almost_full(false), _eden_pool(nullptr), _survivor_pool(nullptr), _old_pool(nullptr) { @@ -282,13 +283,12 @@ size_t SerialHeap::max_capacity() const { // Return true if any of the following is true: // . the allocation won't fit into the current young gen heap // . gc locker is occupied (jni critical section) -// . heap memory is tight -- the most recent previous collection -// was a full collection because a partial collection (would -// have) failed and is likely to fail again +// . heap memory is tight bool SerialHeap::should_try_older_generation_allocation(size_t word_size) const { size_t young_capacity = _young_gen->capacity_before_gc(); return (word_size > heap_word_size(young_capacity)) - || GCLocker::is_active_and_needs_gc(); + || GCLocker::is_active_and_needs_gc() + || _is_heap_almost_full; } HeapWord* SerialHeap::expand_heap_and_allocate(size_t size, bool is_tlab) { @@ -951,5 +951,18 @@ void SerialHeap::gc_epilogue(bool full) { _young_gen->gc_epilogue(full); _old_gen->gc_epilogue(); + if (_is_heap_almost_full) { + // Reset the emergency state if eden is empty after a young/full gc + if (_young_gen->eden()->is_empty()) { + _is_heap_almost_full = false; + } + } else { + if (full && !_young_gen->eden()->is_empty()) { + // Usually eden should be empty after a full GC, so heap is probably too + // full now; entering emergency state. + _is_heap_almost_full = true; + } + } + MetaspaceCounters::update_performance_counters(); }; diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index e8be8d5ed9765..28ab7905bbc79 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -95,6 +95,13 @@ class SerialHeap : public CollectedHeap { GCMemoryManager* _young_manager; GCMemoryManager* _old_manager; + // Indicate whether heap is almost or approaching full. + // Usually, there is some memory headroom for application/gc to run properly. + // However, in extreme cases, e.g. young-gen is non-empty after a full gc, we + // will attempt some uncommon measures, e.g. alllocating small objs in + // old-gen. + bool _is_heap_almost_full; + // Helper functions for allocation HeapWord* attempt_allocation(size_t size, bool is_tlab, From 03106eb2d37903f3367b54c615a77e9df219e9cd Mon Sep 17 00:00:00 2001 From: Gennadiy Krivoshein Date: Mon, 27 Jan 2025 18:05:19 +0000 Subject: [PATCH 247/263] 8344119: CUPSPrinter does not respect PostScript printer definition specification in case of reading ImageableArea values from PPD files Reviewed-by: prr, psadhukhan --- .../unix/native/common/awt/CUPSfuncs.c | 8 +- .../print/CUPSPrinterImageableAreaTest.java | 338 ++++++++++++++++++ 2 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 test/jdk/javax/print/CUPSPrinterImageableAreaTest.java diff --git a/src/java.desktop/unix/native/common/awt/CUPSfuncs.c b/src/java.desktop/unix/native/common/awt/CUPSfuncs.c index 7594bd2c62aaf..7c60d82406757 100644 --- a/src/java.desktop/unix/native/common/awt/CUPSfuncs.c +++ b/src/java.desktop/unix/native/common/awt/CUPSfuncs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -574,10 +574,10 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env, // paper width and height dims[i*6] = size->width; dims[(i*6)+1] = size->length; - // paper printable area + // paper printable area. x and y coordinates of the lower left corner, width and height dims[(i*6)+2] = size->left; - dims[(i*6)+3] = size->top; - dims[(i*6)+4] = size->right; + dims[(i*6)+3] = size->top - size->bottom; + dims[(i*6)+4] = size->right - size->left; dims[(i*6)+5] = size->bottom; } } diff --git a/test/jdk/javax/print/CUPSPrinterImageableAreaTest.java b/test/jdk/javax/print/CUPSPrinterImageableAreaTest.java new file mode 100644 index 0000000000000..b07cc39c6ff2e --- /dev/null +++ b/test/jdk/javax/print/CUPSPrinterImageableAreaTest.java @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, BELLSOFT. All rights reserved. + * 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.BasicStroke; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Graphics; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.util.ArrayList; +import java.util.List; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.Size2DSyntax; +import javax.print.attribute.standard.Media; +import javax.print.attribute.standard.MediaPrintableArea; +import javax.print.attribute.standard.MediaSize; +import javax.print.attribute.standard.MediaSizeName; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.plaf.basic.BasicComboBoxRenderer; + +/* + * @test + * @bug 8344119 + * @key printer + * @requires (os.family == "linux" | os.family == "mac") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary CUPSPrinter imageable area + * @run main/manual CUPSPrinterImageableAreaTest + */ + +public class CUPSPrinterImageableAreaTest { + + private static final List ALLOWED_MEDIA_LIST = List.of(MediaSizeName.ISO_A4, MediaSizeName.NA_LETTER); + private static final double DPI = 72.0; + private static final double MM_PER_INCH = 2.54; + private static final String INSTRUCTIONS = """ + +
    + The test checks that the media margins fetched from the printer's PPD file are correct.
    + Press the 'Print sample' button to print a test page.
    + Required paper size and expected margins will be shown on the print dialog. + A passing test will print the page with a black rectangle along the printable area. + Ensure that all sides of the rectangle are printed.
    + Click 'Pass' button, or click 'Fail' button if the test failed. +
    + + """; + private static final String PAPER_INSTRUCTIONS_FORMAT = """ + + Required paper size:
    • %s
    + Expected margins:
    • left: %.1f
    • +
    • bottom: %.1f
    • +
    • right: %.1f
    • +
    • top: %.1f
    • +
    + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .testUI(createTestUI()) + .columns(55) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + final TestServiceData[] testServiceList = getTestServiceList(); + if (testServiceList.length == 0) { + throw new RuntimeException("Print services support borderless print only"); + } + + final JFrame frame = new JFrame("CUPS Printer imageable area test"); + JPanel pnlRoot = new JPanel(); + JLabel lblPrintServices = new JLabel("Select a print service for the test"); + JComboBox cbPrintServices = new JComboBox<>(); + JPanel pnlInstruction = new JPanel(); + JLabel lblInstruction = new JLabel(); + JButton btnPrint = new JButton("Print sample"); + + lblPrintServices.setLabelFor(cbPrintServices); + lblPrintServices.setAlignmentX(SwingConstants.LEFT); + + lblInstruction.setPreferredSize(new Dimension(250, 150)); + pnlInstruction.setBackground(Color.white); + pnlInstruction.add(lblInstruction); + + cbPrintServices.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedIndex = cbPrintServices.getSelectedIndex(); + if (selectedIndex < 0) { + lblInstruction.setText(""); + btnPrint.setEnabled(false); + return; + } + + TestServiceData testServiceData = testServiceList[selectedIndex]; + PageFormat pageFormat = testServiceData.pageFormat; + // margins: left, bottom, right, top + double[] margins = new double[]{ + pageFormat.getImageableX(), + pageFormat.getHeight() - pageFormat.getImageableHeight() - pageFormat.getImageableY(), + pageFormat.getWidth() - pageFormat.getImageableWidth() - pageFormat.getImageableX(), + pageFormat.getImageableY() + }; + String printServiceInstructions = PAPER_INSTRUCTIONS_FORMAT.formatted( + testServiceData.mediaSizeName.toString(), inchesToMM(margins[0]), + inchesToMM(margins[1]), inchesToMM(margins[2]), inchesToMM(margins[3])); + lblInstruction.setText(printServiceInstructions); + btnPrint.setEnabled(true); + } + }); + + DefaultComboBoxModel model = new DefaultComboBoxModel<>(); + for(TestServiceData tsd : testServiceList) { + model.addElement(tsd.printService.getName()); + } + cbPrintServices.setModel(model); + cbPrintServices.setSelectedIndex(-1); + PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService(); + if (defaultPrintService != null && model.getIndexOf(defaultPrintService.getName()) >= 0) { + cbPrintServices.setSelectedItem(defaultPrintService.getName()); + } else { + cbPrintServices.setSelectedIndex(0); + } + + btnPrint.setPreferredSize(new Dimension(200, 80)); + btnPrint.addActionListener((e) -> { + int selectedIndex = cbPrintServices.getSelectedIndex(); + if (selectedIndex < 0) { + return; + } + btnPrint.setEnabled(false); + cbPrintServices.setEnabled(false); + TestServiceData testServiceData = testServiceList[selectedIndex]; + PrinterJob job = PrinterJob.getPrinterJob(); + try { + job.setPrintService(testServiceData.printService); + job.setPrintable(new RectPrintable(), testServiceData.pageFormat); + job.print(); + } catch (PrinterException ex) { + throw new RuntimeException(ex); + } + }); + + LayoutManager layout = new GridBagLayout(); + pnlRoot.setLayout(layout); + + addGridBagComponent(pnlRoot, lblPrintServices, 0); + addGridBagComponent(pnlRoot, cbPrintServices, 1); + addGridBagComponent(pnlRoot, pnlInstruction, 2); + addGridBagComponent(pnlRoot, btnPrint, 3); + + frame.add(pnlRoot); + frame.pack(); + frame.setResizable(false); + return frame; + } + + private static TestServiceData[] getTestServiceList() { + PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); + if (printServices == null || printServices.length == 0) { + throw new RuntimeException("Print services not found"); + } + + List testServiceList = new ArrayList<>(); + for (PrintService ps : printServices) { + try { + MediaSizeName msn = getTestMediaSizeName(ps); + PageFormat pf = createTestPageFormat(msn, ps); + testServiceList.add(new TestServiceData(ps, msn, pf)); + } catch (Exception ignore) { //in case if can't create required PageFormat + } + } + return testServiceList.toArray(TestServiceData[]::new); + } + + private static MediaSizeName getTestMediaSizeName(PrintService printService) { + //Use printer's default media or one of the alloed medias + Media testMedia = (Media) printService.getDefaultAttributeValue(Media.class); + if (testMedia == null) { + Media[] medias = (Media[]) printService + .getSupportedAttributeValues(Media.class, null, null); + if (medias == null || medias.length == 0) { + throw new RuntimeException("Medias not found"); + } + for (Media media : medias) { + if (ALLOWED_MEDIA_LIST.contains(media)) { + testMedia = media; + break; + } + } + } + if (!(testMedia instanceof MediaSizeName)) { + throw new RuntimeException("Test media not found"); + } + return (MediaSizeName) testMedia; + } + + private static PageFormat createTestPageFormat(MediaSizeName testMedia, PrintService printService) { + MediaSize ms = MediaSize.getMediaSizeForName(testMedia); + if (ms == null) { + throw new RuntimeException("Media size not defined"); + } + + MediaPrintableArea mpa = getMaximumMediaPrintableArea(testMedia, ms, printService); + if (mpa == null) { + throw new RuntimeException("Media printable area not defined"); + } + + PageFormat pageFormat = new PageFormat(); + pageFormat.setOrientation(PageFormat.PORTRAIT); + Paper paper = new Paper(); + paper.setSize(ms.getX(MediaSize.INCH) * DPI, ms.getY(MediaSize.INCH) * DPI); + paper.setImageableArea(mpa.getX(MediaPrintableArea.INCH) * DPI, + mpa.getY(MediaPrintableArea.INCH) * DPI, + mpa.getWidth(MediaPrintableArea.INCH) * DPI, + mpa.getHeight(MediaPrintableArea.INCH) * DPI); + pageFormat.setPaper(paper); + return pageFormat; + } + + private static MediaPrintableArea getMaximumMediaPrintableArea(MediaSizeName msn, MediaSize ms, + PrintService printService) { + final float paperSizeX = ms.getX(Size2DSyntax.MM); + final float paperSizeY = ms.getY(Size2DSyntax.MM); + final float sizeDev = 0.2f; + + PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); + attrs.add(msn); + MediaPrintableArea[] mpas = (MediaPrintableArea[]) printService + .getSupportedAttributeValues(MediaPrintableArea.class, null, attrs); + if (mpas == null || mpas.length == 0) { + throw new RuntimeException("Printable area not found"); + } + + MediaPrintableArea mpa = null; + for (MediaPrintableArea area : mpas) { + float mpaSize = area.getWidth(MediaPrintableArea.MM) * area.getHeight(MediaPrintableArea.MM); + //do not use borderless printable area + if (sizeDev >= Math.abs(paperSizeX - area.getWidth(MediaPrintableArea.MM)) && + sizeDev >= Math.abs(paperSizeY - area.getHeight(MediaPrintableArea.MM))) { + continue; + } + if (mpa == null) { + mpa = area; + } else if (mpaSize > (area.getWidth(MediaPrintableArea.MM) * area.getHeight(MediaPrintableArea.MM))) { + mpa = area; + } + } + return mpa; + } + + private static double inchesToMM(double inches) { + return inches / MM_PER_INCH; + } + + private static void addGridBagComponent(JPanel p, Component c, int y) { + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.insets = new Insets(4, 4, 4, 4); + constraints.gridx = 0; + constraints.gridy = y; + p.add(c, constraints); + } + + private static class RectPrintable implements Printable { + + @Override + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { + if (pageIndex == 0) { + Graphics2D g = (Graphics2D) graphics; + g.setStroke(new BasicStroke(3)); + g.drawRect((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY(), + (int) pageFormat.getImageableWidth(), (int) pageFormat.getImageableHeight()); + return PAGE_EXISTS; + } + return NO_SUCH_PAGE; + } + } + + private static class TestServiceData { + + final PrintService printService; + final MediaSizeName mediaSizeName; + final PageFormat pageFormat; + + private TestServiceData(PrintService printService, MediaSizeName mediaSizeName, PageFormat pageFormat) { + this.printService = printService; + this.mediaSizeName = mediaSizeName; + this.pageFormat = pageFormat; + } + } +} From aba60a927494d114904e27930040755855bbb348 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 27 Jan 2025 18:09:17 +0000 Subject: [PATCH 248/263] 8189441: Define algorithm names for keys derived from KeyAgreement Reviewed-by: mullan --- .../sun/crypto/provider/DHKeyAgreement.java | 25 +++--- .../classes/javax/crypto/KeyAgreement.java | 24 ++++-- .../classes/javax/crypto/KeyAgreementSpi.java | 24 ++++-- .../sun/security/ec/ECDHKeyAgreement.java | 11 +-- .../sun/security/ec/XDHKeyAgreement.java | 8 +- .../classes/sun/security/util/KeyUtil.java | 5 ++ .../security/pkcs11/P11ECDHKeyAgreement.java | 10 ++- .../sun/security/pkcs11/P11KeyAgreement.java | 20 +++-- .../java/security/KeyAgreement/Generic.java | 79 +++++++++++++++++++ .../security/pkcs11/nss/p11-nss-sensitive.txt | 2 + 10 files changed, 162 insertions(+), 46 deletions(-) create mode 100644 test/jdk/java/security/KeyAgreement/Generic.java diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java b/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java index e13eec429057c..2d9ad93d2fa29 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -379,11 +379,10 @@ protected SecretKey engineGenerateSecret(String algorithm) throw new NoSuchAlgorithmException("null algorithm"); } - if (!algorithm.equalsIgnoreCase("TlsPremasterSecret") && - !AllowKDF.VALUE) { - - throw new NoSuchAlgorithmException("Unsupported secret key " - + "algorithm: " + algorithm); + if (!KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm) && + !AllowKDF.VALUE) { + throw new NoSuchAlgorithmException( + "Unsupported secret key algorithm: " + algorithm); } byte[] secret = engineGenerateSecret(); @@ -419,13 +418,17 @@ protected SecretKey engineGenerateSecret(String algorithm) throw new InvalidKeyException("Key material is too short"); } return skey; - } else if (algorithm.equals("TlsPremasterSecret")) { - // remove leading zero bytes per RFC 5246 Section 8.1.2 - return new SecretKeySpec( + } else if (KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm)) { + if (algorithm.equalsIgnoreCase("TlsPremasterSecret")) { + // remove leading zero bytes per RFC 5246 Section 8.1.2 + return new SecretKeySpec( KeyUtil.trimZeroes(secret), "TlsPremasterSecret"); + } else { + return new SecretKeySpec(secret, algorithm); + } } else { - throw new NoSuchAlgorithmException("Unsupported secret key " - + "algorithm: "+ algorithm); + throw new NoSuchAlgorithmException( + "Unsupported secret key algorithm: " + algorithm); } } } diff --git a/src/java.base/share/classes/javax/crypto/KeyAgreement.java b/src/java.base/share/classes/javax/crypto/KeyAgreement.java index e3a68e88d03d4..4b3a3fd1cf7b8 100644 --- a/src/java.base/share/classes/javax/crypto/KeyAgreement.java +++ b/src/java.base/share/classes/javax/crypto/KeyAgreement.java @@ -666,18 +666,30 @@ public final int generateSecret(byte[] sharedSecret, int offset) * {@code generateSecret} to change the private information used in * subsequent operations. * - * @param algorithm the requested secret-key algorithm - * - * @return the shared secret key + * @param algorithm the requested secret key algorithm. This is different + * from the {@code KeyAgreement} algorithm provided to the + * {@code getInstance} method. See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). + * + * @return the shared secret key. The length of the key material + * may be adjusted to be compatible with the specified algorithm, + * regardless of whether the key is extractable. If {@code algorithm} + * is specified as "Generic" and it is supported by the implementation, + * the full shared secret is returned. * * @exception IllegalStateException if this key agreement has not been * initialized or if {@code doPhase} has not been called to supply the * keys for all parties in the agreement - * @exception NoSuchAlgorithmException if the specified secret-key - * algorithm is not available - * @exception InvalidKeyException if the shared secret-key material cannot + * @exception NoSuchAlgorithmException if the specified secret key + * algorithm is not supported + * @exception InvalidKeyException if the shared secret key material cannot * be used to generate a secret key of the specified algorithm (e.g., * the key material is too short) + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public final SecretKey generateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, diff --git a/src/java.base/share/classes/javax/crypto/KeyAgreementSpi.java b/src/java.base/share/classes/javax/crypto/KeyAgreementSpi.java index a4c242e46cca5..84d68a39725cf 100644 --- a/src/java.base/share/classes/javax/crypto/KeyAgreementSpi.java +++ b/src/java.base/share/classes/javax/crypto/KeyAgreementSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -205,18 +205,30 @@ protected abstract int engineGenerateSecret(byte[] sharedSecret, * {@code generateSecret} to change the private information used in * subsequent operations. * - * @param algorithm the requested secret key algorithm - * - * @return the shared secret key + * @param algorithm the requested secret key algorithm. This is different + * from the {@code KeyAgreement} algorithm provided to the + * {@code getInstance} method. See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). + * + * @return the shared secret key. The length of the key material + * may be adjusted to be compatible with the specified algorithm, + * regardless of whether the key is extractable. If {@code algorithm} + * is specified as "Generic" and it is supported by the implementation, + * the full shared secret is returned. * * @exception IllegalStateException if this key agreement has not been * initialized or if {@code doPhase} has not been called to supply the * keys for all parties in the agreement - * @exception NoSuchAlgorithmException if the requested secret key - * algorithm is not available + * @exception NoSuchAlgorithmException if the specified secret key + * algorithm is not supported * @exception InvalidKeyException if the shared secret key material cannot * be used to generate a secret key of the requested algorithm type (e.g., * the key material is too short) + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected abstract SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, diff --git a/src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java b/src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java index be3bdfdd63990..8f6bdb8d80ae1 100644 --- a/src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java +++ b/src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import sun.security.util.ArrayUtil; import sun.security.util.CurveDB; import sun.security.util.ECUtil; +import sun.security.util.KeyUtil; import sun.security.util.NamedCurve; import sun.security.util.math.IntegerFieldModuloP; import sun.security.util.math.IntegerMontgomeryFieldModuloP; @@ -254,11 +255,11 @@ protected SecretKey engineGenerateSecret(String algorithm) if (algorithm == null) { throw new NoSuchAlgorithmException("Algorithm must not be null"); } - if (!(algorithm.equals("TlsPremasterSecret"))) { - throw new NoSuchAlgorithmException - ("Only supported for algorithm TlsPremasterSecret"); + if (!KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm)) { + throw new NoSuchAlgorithmException( + "Unsupported secret key algorithm: " + algorithm); } - return new SecretKeySpec(engineGenerateSecret(), "TlsPremasterSecret"); + return new SecretKeySpec(engineGenerateSecret(), algorithm); } private static diff --git a/src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java b/src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java index e2a625a55d9b2..01dce4c53e905 100644 --- a/src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java +++ b/src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package sun.security.ec; +import sun.security.util.KeyUtil; + import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -207,9 +209,9 @@ protected SecretKey engineGenerateSecret(String algorithm) throw new NoSuchAlgorithmException("Algorithm must not be null"); } - if (!(algorithm.equals("TlsPremasterSecret"))) { + if (!KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm)) { throw new NoSuchAlgorithmException( - "Only supported for algorithm TlsPremasterSecret"); + "Unsupported secret key algorithm: " + algorithm); } return new SecretKeySpec(engineGenerateSecret(), algorithm); } diff --git a/src/java.base/share/classes/sun/security/util/KeyUtil.java b/src/java.base/share/classes/sun/security/util/KeyUtil.java index 6eb5acfade3fd..224167653f789 100644 --- a/src/java.base/share/classes/sun/security/util/KeyUtil.java +++ b/src/java.base/share/classes/sun/security/util/KeyUtil.java @@ -424,5 +424,10 @@ public static String hashAlgFromHSS(PublicKey publicKey) throw new NoSuchAlgorithmException("Cannot decode public key", e); } } + + public static boolean isSupportedKeyAgreementOutputAlgorithm(String alg) { + return alg.equalsIgnoreCase("TlsPremasterSecret") + || alg.equalsIgnoreCase("Generic"); + } } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11ECDHKeyAgreement.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11ECDHKeyAgreement.java index 53728219d8bb2..ec5e03cc15a67 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11ECDHKeyAgreement.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11ECDHKeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ import static sun.security.pkcs11.TemplateManager.*; import sun.security.pkcs11.wrapper.*; +import sun.security.util.KeyUtil; + import static sun.security.pkcs11.wrapper.PKCS11Constants.*; /** @@ -168,9 +170,9 @@ protected SecretKey engineGenerateSecret(String algorithm) if (algorithm == null) { throw new NoSuchAlgorithmException("Algorithm must not be null"); } - if (!algorithm.equals("TlsPremasterSecret")) { - throw new NoSuchAlgorithmException - ("Only supported for algorithm TlsPremasterSecret"); + if (!KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm)) { + throw new NoSuchAlgorithmException( + "Unsupported secret key algorithm: " + algorithm); } return nativeGenerateSecret(algorithm); } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyAgreement.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyAgreement.java index 6c010a4a5130e..183135ce7e126 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyAgreement.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -268,20 +268,19 @@ protected SecretKey engineGenerateSecret(String algorithm) throw new NoSuchAlgorithmException("Algorithm must not be null"); } - if (algorithm.equals("TlsPremasterSecret")) { + if (KeyUtil.isSupportedKeyAgreementOutputAlgorithm(algorithm)) { // For now, only perform native derivation for TlsPremasterSecret - // as that is required for FIPS compliance. + // and Generic algorithms. TlsPremasterSecret is required for + // FIPS compliance and Generic is required for input to KDF. // For other algorithms, there are unresolved issues regarding // how this should work in JCE plus a Solaris truncation bug. // (bug not yet filed). return nativeGenerateSecret(algorithm); } - if (!algorithm.equalsIgnoreCase("TlsPremasterSecret") && - !AllowKDF.VALUE) { - - throw new NoSuchAlgorithmException("Unsupported secret key " - + "algorithm: " + algorithm); + if (!AllowKDF.VALUE) { + throw new NoSuchAlgorithmException( + "Unsupported secret key algorithm: " + algorithm); } byte[] secret = engineGenerateSecret(); @@ -295,8 +294,6 @@ protected SecretKey engineGenerateSecret(String algorithm) keyLen = 24; } else if (algorithm.equalsIgnoreCase("Blowfish")) { keyLen = Math.min(56, secret.length); - } else if (algorithm.equalsIgnoreCase("TlsPremasterSecret")) { - keyLen = secret.length; } else { throw new NoSuchAlgorithmException ("Unknown algorithm " + algorithm); @@ -340,7 +337,8 @@ private SecretKey nativeGenerateSecret(String algorithm) int keyLen = (int)lenAttributes[0].getLong(); SecretKey key = P11Key.secretKey (session, keyID, algorithm, keyLen << 3, attributes); - if ("RAW".equals(key.getFormat())) { + if ("RAW".equals(key.getFormat()) + && algorithm.equalsIgnoreCase("TlsPremasterSecret")) { // Workaround for Solaris bug 6318543. // Strip leading zeroes ourselves if possible (key not sensitive). // This should be removed once the Solaris fix is available diff --git a/test/jdk/java/security/KeyAgreement/Generic.java b/test/jdk/java/security/KeyAgreement/Generic.java new file mode 100644 index 0000000000000..dcf212dbffe7c --- /dev/null +++ b/test/jdk/java/security/KeyAgreement/Generic.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 8189441 + * @library /test/lib /test/jdk/sun/security/pkcs11 + * @summary make sure Generic is accepted by all KeyAgreement implementations + * @run main Generic builtin + * @run main/othervm Generic nss + * @run main/othervm -DCUSTOM_P11_CONFIG_NAME=p11-nss-sensitive.txt Generic nss + */ +import jdk.test.lib.Asserts; + +import javax.crypto.KeyAgreement; +import java.security.KeyPairGenerator; +import java.security.Provider; +import java.security.Security; +import java.util.List; + +public class Generic { + + public static void main(String[] args) throws Exception { + if (args[0].equals("nss")) { + test(PKCS11Test.getSunPKCS11(PKCS11Test.getNssConfig())); + } else { + for (var p : Security.getProviders()) { + test(p); + } + } + } + + static void test(Provider p) throws Exception { + for (var s : p.getServices()) { + if (s.getType().equalsIgnoreCase("KeyAgreement")) { + try { + System.out.println(s.getProvider().getName() + "." + s.getAlgorithm()); + var g = KeyPairGenerator.getInstance(ka2kpg(s.getAlgorithm()), p); + var kp1 = g.generateKeyPair(); + var kp2 = g.generateKeyPair(); + var ka = KeyAgreement.getInstance(s.getAlgorithm(), s.getProvider()); + for (var alg : List.of("TlsPremasterSecret", "Generic")) { + ka.init(kp1.getPrivate()); + ka.doPhase(kp2.getPublic(), true); + Asserts.assertEquals( + ka.generateSecret(alg).getAlgorithm(), alg); + } + } catch (Exception e) { + throw e; + } + } + } + } + + // Find key algorithm from KeyAgreement algorithm + private static String ka2kpg(String ka) { + return ka.equals("ECDH") ? "EC" : ka; + } +} diff --git a/test/jdk/sun/security/pkcs11/nss/p11-nss-sensitive.txt b/test/jdk/sun/security/pkcs11/nss/p11-nss-sensitive.txt index 4579dd593982d..df891c7097a0f 100644 --- a/test/jdk/sun/security/pkcs11/nss/p11-nss-sensitive.txt +++ b/test/jdk/sun/security/pkcs11/nss/p11-nss-sensitive.txt @@ -49,10 +49,12 @@ attributes(*,CKO_PRIVATE_KEY,CKK_DH) = { # Make all private keys sensitive attributes(*,CKO_PRIVATE_KEY,*) = { CKA_SENSITIVE = true + CKA_EXTRACTABLE = false } # Make all secret keys sensitive attributes(*,CKO_SECRET_KEY,*) = { CKA_SENSITIVE = true + CKA_EXTRACTABLE = false } From 039e73fcdb765cb73ecb9929187dd9630de131b4 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 27 Jan 2025 18:21:51 +0000 Subject: [PATCH 249/263] 8346736: Java Security Standard Algorithm Names spec should include key algorithm names Reviewed-by: mullan, hchao --- .../share/classes/java/security/Key.java | 9 ++++----- .../java/security/spec/EncodedKeySpec.java | 9 +++++---- .../security/spec/PKCS8EncodedKeySpec.java | 9 +++++---- .../security/spec/X509EncodedKeySpec.java | 9 +++++---- .../share/classes/javax/crypto/KDF.java | 7 ++++++- .../share/classes/javax/crypto/KDFSpi.java | 11 +++++++--- .../share/classes/javax/crypto/KEM.java | 18 +++++++++++++++-- .../share/classes/javax/crypto/KEMSpi.java | 20 ++++++++++++++++--- .../javax/crypto/spec/SecretKeySpec.java | 16 ++++++++------- 9 files changed, 75 insertions(+), 33 deletions(-) diff --git a/src/java.base/share/classes/java/security/Key.java b/src/java.base/share/classes/java/security/Key.java index 190a3db299978..ed6ec42d3622d 100644 --- a/src/java.base/share/classes/java/security/Key.java +++ b/src/java.base/share/classes/java/security/Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -120,10 +120,9 @@ public interface Key extends java.io.Serializable { /** * Returns the standard algorithm name for this key. For - * example, "DSA" would indicate that this key is a DSA key. - * See the key related sections (KeyFactory, KeyGenerator, - * KeyPairGenerator, and SecretKeyFactory) in the + * example, "RSA" would indicate that this key is an RSA key. + * See the Key Algorithms section in the + * * Java Security Standard Algorithm Names Specification * for information about standard key algorithm names. * diff --git a/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java index 7ddc9bf8e03ae..e9838efdaf17a 100644 --- a/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java @@ -74,16 +74,17 @@ public EncodedKeySpec(byte[] encodedKey) { * * @param encodedKey the encoded key. The contents of the * array are copied to protect against subsequent modification. - * @param algorithm the algorithm name of the encoded key - * See the KeyFactory section in the + * @param algorithm the algorithm name of the encoded key. + * See the AsymmetricKey Algorithms section in the + * * Java Security Standard Algorithm Names Specification - * for information about standard algorithm names. + * for information about standard asymmetric key algorithm names. * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 9 */ protected EncodedKeySpec(byte[] encodedKey, String algorithm) { diff --git a/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java index 799de3599560c..af7f135d7c43f 100644 --- a/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java @@ -83,16 +83,17 @@ public PKCS8EncodedKeySpec(byte[] encodedKey) { * @param encodedKey the key, which is assumed to be * encoded according to the PKCS #8 standard. The contents of * the array are copied to protect against subsequent modification. - * @param algorithm the algorithm name of the encoded private key - * See the KeyFactory section in the + * @param algorithm the algorithm name of the encoded private key. + * See the AsymmetricKey Algorithms section in the + * * Java Security Standard Algorithm Names Specification - * for information about standard algorithm names. + * for information about standard asymmetric key algorithm names. * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 9 */ public PKCS8EncodedKeySpec(byte[] encodedKey, String algorithm) { diff --git a/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java b/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java index e9801f6f7f30d..a405104cd074e 100644 --- a/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java @@ -73,16 +73,17 @@ public X509EncodedKeySpec(byte[] encodedKey) { * @param encodedKey the key, which is assumed to be * encoded according to the X.509 standard. The contents of the * array are copied to protect against subsequent modification. - * @param algorithm the algorithm name of the encoded public key - * See the KeyFactory section in the + * @param algorithm the algorithm name of the encoded public key. + * See the AsymmetricKey Algorithms section in the + * * Java Security Standard Algorithm Names Specification - * for information about standard algorithm names. + * for information about standard asymmetric key algorithm names. * @spec security/standard-names.html Java Security Standard Algorithm Names * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 9 */ public X509EncodedKeySpec(byte[] encodedKey, String algorithm) { diff --git a/src/java.base/share/classes/javax/crypto/KDF.java b/src/java.base/share/classes/javax/crypto/KDF.java index 9859bd4778725..5c9c7e71ce4a8 100644 --- a/src/java.base/share/classes/javax/crypto/KDF.java +++ b/src/java.base/share/classes/javax/crypto/KDF.java @@ -483,7 +483,11 @@ private static KDF handleException(NoSuchAlgorithmException e) * Derives a key, returned as a {@code SecretKey} object. * * @param alg - * the algorithm of the resultant {@code SecretKey} object + * the algorithm of the resultant {@code SecretKey} object. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. * @param derivationSpec * the object describing the inputs to the derivation function * @@ -500,6 +504,7 @@ private static KDF handleException(NoSuchAlgorithmException e) * * @see Delayed Provider * Selection + * @spec security/standard-names.html Java Security Standard Algorithm Names * */ public SecretKey deriveKey(String alg, diff --git a/src/java.base/share/classes/javax/crypto/KDFSpi.java b/src/java.base/share/classes/javax/crypto/KDFSpi.java index dcd2029c0c06f..e2625a1930d64 100644 --- a/src/java.base/share/classes/javax/crypto/KDFSpi.java +++ b/src/java.base/share/classes/javax/crypto/KDFSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,11 @@ protected KDFSpi(KDFParameters kdfParameters) * result of {@code deriveData}. * * @param alg - * the algorithm of the resultant {@code SecretKey} object + * the algorithm of the resultant {@code SecretKey} object. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. * @param derivationSpec * derivation parameters * @@ -129,6 +133,7 @@ protected KDFSpi(KDFParameters kdfParameters) * if {@code alg} is empty or invalid * @throws NullPointerException * if {@code alg} or {@code derivationSpec} is null + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected abstract SecretKey engineDeriveKey(String alg, AlgorithmParameterSpec derivationSpec) @@ -154,4 +159,4 @@ protected abstract byte[] engineDeriveData( AlgorithmParameterSpec derivationSpec) throws InvalidAlgorithmParameterException; -} \ No newline at end of file +} diff --git a/src/java.base/share/classes/javax/crypto/KEM.java b/src/java.base/share/classes/javax/crypto/KEM.java index 287efc75371b7..927b36ba25ca0 100644 --- a/src/java.base/share/classes/javax/crypto/KEM.java +++ b/src/java.base/share/classes/javax/crypto/KEM.java @@ -222,7 +222,13 @@ public Encapsulated encapsulate() { * to be returned, inclusive * @param to the final index of the shared secret byte array * to be returned, exclusive - * @param algorithm the algorithm name for the secret key that is returned + * @param algorithm the algorithm name for the secret key that is returned. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). * @return a {@link Encapsulated} object containing a portion of * the shared secret, key encapsulation message, and optional * parameters. The portion of the shared secret is a @@ -237,6 +243,7 @@ public Encapsulated encapsulate() { * @throws UnsupportedOperationException if the combination of * {@code from}, {@code to}, and {@code algorithm} * is not supported by the encapsulator + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public Encapsulated encapsulate(int from, int to, String algorithm) { return e.engineEncapsulate(from, to, algorithm); @@ -345,7 +352,13 @@ public SecretKey decapsulate(byte[] encapsulation) throws DecapsulateException { * to be returned, inclusive * @param to the final index of the shared secret byte array * to be returned, exclusive - * @param algorithm the algorithm name for the secret key that is returned + * @param algorithm the algorithm name for the secret key that is returned. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). * @return a portion of the shared secret as a {@code SecretKey} * containing the bytes of the secret ranging from {@code from} * to {@code to}, exclusive, and an algorithm name as specified. @@ -361,6 +374,7 @@ public SecretKey decapsulate(byte[] encapsulation) throws DecapsulateException { * @throws UnsupportedOperationException if the combination of * {@code from}, {@code to}, and {@code algorithm} * is not supported by the decapsulator + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public SecretKey decapsulate(byte[] encapsulation, int from, int to, String algorithm) diff --git a/src/java.base/share/classes/javax/crypto/KEMSpi.java b/src/java.base/share/classes/javax/crypto/KEMSpi.java index 61d13aeb02417..6f6eefedbb94d 100644 --- a/src/java.base/share/classes/javax/crypto/KEMSpi.java +++ b/src/java.base/share/classes/javax/crypto/KEMSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -129,7 +129,13 @@ interface EncapsulatorSpi { * to be returned, inclusive * @param to the final index of the shared secret byte array * to be returned, exclusive - * @param algorithm the algorithm name for the secret key that is returned + * @param algorithm the algorithm name for the secret key that is returned. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). * @return an {@link KEM.Encapsulated} object containing a portion of * the shared secret as a key with the specified algorithm, * key encapsulation message, and optional parameters. @@ -141,6 +147,7 @@ interface EncapsulatorSpi { * is not supported by the encapsulator * @see KEM.Encapsulated * @see KEM.Encapsulator#encapsulate(int, int, String) + * @spec security/standard-names.html Java Security Standard Algorithm Names */ KEM.Encapsulated engineEncapsulate(int from, int to, String algorithm); @@ -188,7 +195,13 @@ interface DecapsulatorSpi { * to be returned, inclusive * @param to the final index of the shared secret byte array * to be returned, exclusive - * @param algorithm the algorithm name for the secret key that is returned + * @param algorithm the algorithm name for the secret key that is returned. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. + * Specify "Generic" if the output will be used as the input keying + * material of a key derivation function (KDF). * @return a portion of the shared secret as a {@code SecretKey} with * the specified algorithm * @throws DecapsulateException if an error occurs during the @@ -201,6 +214,7 @@ interface DecapsulatorSpi { * {@code from}, {@code to}, and {@code algorithm} * is not supported by the decapsulator * @see KEM.Decapsulator#decapsulate(byte[], int, int, String) + * @spec security/standard-names.html Java Security Standard Algorithm Names */ SecretKey engineDecapsulate(byte[] encapsulation, int from, int to, String algorithm) throws DecapsulateException; diff --git a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java index d36510a21a82f..be185cb34ad11 100644 --- a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,9 +93,10 @@ public class SecretKeySpec implements KeySpec, SecretKey { * the array are copied to protect against subsequent modification. * @param algorithm the name of the secret-key algorithm to be associated * with the given key material. - * See the - * Java Security Standard Algorithm Names document - * for information about standard algorithm names. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. * @exception IllegalArgumentException if algorithm * is null or key is null or empty. * @@ -137,9 +138,10 @@ public SecretKeySpec(byte[] key, String algorithm) { * @param len the length of the key material. * @param algorithm the name of the secret-key algorithm to be associated * with the given key material. - * See the - * Java Security Standard Algorithm Names document - * for information about standard algorithm names. + * See the SecretKey Algorithms section in the + * + * Java Security Standard Algorithm Names Specification + * for information about standard secret key algorithm names. * @exception IllegalArgumentException if algorithm * is null or key is null, empty, or too short, * i.e. {@code key.length-offset Date: Mon, 27 Jan 2025 19:40:26 +0000 Subject: [PATCH 250/263] 8287788: Implement a better allocator for downcalls Reviewed-by: jvernee --- .../internal/foreign/SlicingAllocator.java | 18 +- .../jdk/internal/foreign/abi/BufferStack.java | 122 ++++++++++++++ .../jdk/internal/foreign/abi/SharedUtils.java | 24 +-- test/jdk/java/foreign/TestBufferStack.java | 157 ++++++++++++++++++ test/jdk/java/foreign/libTestBufferStack.c | 39 +++++ .../lang/foreign/CallOverheadByValue.java | 96 +++++++++++ .../lang/foreign/libCallOverheadByValue.c | 38 +++++ 7 files changed, 474 insertions(+), 20 deletions(-) create mode 100644 src/java.base/share/classes/jdk/internal/foreign/abi/BufferStack.java create mode 100644 test/jdk/java/foreign/TestBufferStack.java create mode 100644 test/jdk/java/foreign/libTestBufferStack.c create mode 100644 test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadByValue.java create mode 100644 test/micro/org/openjdk/bench/java/lang/foreign/libCallOverheadByValue.c diff --git a/src/java.base/share/classes/jdk/internal/foreign/SlicingAllocator.java b/src/java.base/share/classes/jdk/internal/foreign/SlicingAllocator.java index db7d476053e54..6b1a071c2af07 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SlicingAllocator.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SlicingAllocator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,22 @@ public SlicingAllocator(MemorySegment segment) { this.segment = segment; } + public long currentOffset() { + return sp; + } + + public void resetTo(long offset) { + if (offset < 0 || offset > sp) + throw new IllegalArgumentException(String.format("offset %d should be in [0, %d] ", offset, sp)); + this.sp = offset; + } + + public boolean canAllocate(long byteSize, long byteAlignment) { + long min = segment.address(); + long start = Utils.alignUp(min + sp, byteAlignment) - min; + return start + byteSize <= segment.byteSize(); + } + MemorySegment trySlice(long byteSize, long byteAlignment) { long min = segment.address(); long start = Utils.alignUp(min + sp, byteAlignment) - min; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/BufferStack.java b/src/java.base/share/classes/jdk/internal/foreign/abi/BufferStack.java new file mode 100644 index 0000000000000..150d54856026a --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/BufferStack.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.foreign.abi; + +import jdk.internal.foreign.SlicingAllocator; +import jdk.internal.misc.CarrierThreadLocal; +import jdk.internal.vm.annotation.ForceInline; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.util.concurrent.locks.ReentrantLock; + +public class BufferStack { + private final long size; + + public BufferStack(long size) { + this.size = size; + } + + private final ThreadLocal tl = new CarrierThreadLocal<>() { + @Override + protected PerThread initialValue() { + return new PerThread(size); + } + }; + + @ForceInline + public Arena pushFrame(long size, long byteAlignment) { + return tl.get().pushFrame(size, byteAlignment); + } + + private static final class PerThread { + private final ReentrantLock lock = new ReentrantLock(); + private final SlicingAllocator stack; + + public PerThread(long size) { + this.stack = new SlicingAllocator(Arena.ofAuto().allocate(size)); + } + + @ForceInline + public Arena pushFrame(long size, long byteAlignment) { + boolean needsLock = Thread.currentThread().isVirtual() && !lock.isHeldByCurrentThread(); + if (needsLock && !lock.tryLock()) { + // Rare: another virtual thread on the same carrier competed for acquisition. + return Arena.ofConfined(); + } + if (!stack.canAllocate(size, byteAlignment)) { + if (needsLock) lock.unlock(); + return Arena.ofConfined(); + } + + return new Frame(needsLock, size, byteAlignment); + } + + private class Frame implements Arena { + private final boolean locked; + private final long parentOffset; + private final long topOfStack; + private final Arena scope = Arena.ofConfined(); + private final SegmentAllocator frame; + + @SuppressWarnings("restricted") + public Frame(boolean locked, long byteSize, long byteAlignment) { + this.locked = locked; + + parentOffset = stack.currentOffset(); + MemorySegment frameSegment = stack.allocate(byteSize, byteAlignment); + topOfStack = stack.currentOffset(); + frame = new SlicingAllocator(frameSegment.reinterpret(scope, null)); + } + + private void assertOrder() { + if (topOfStack != stack.currentOffset()) + throw new IllegalStateException("Out of order access: frame not top-of-stack"); + } + + @Override + @SuppressWarnings("restricted") + public MemorySegment allocate(long byteSize, long byteAlignment) { + return frame.allocate(byteSize, byteAlignment); + } + + @Override + public MemorySegment.Scope scope() { + return scope.scope(); + } + + @Override + public void close() { + assertOrder(); + scope.close(); + stack.resetTo(parentOffset); + if (locked) { + lock.unlock(); + } + } + } + } +} \ No newline at end of file diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java index 9078920f677f6..feaa9fdb436e7 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java @@ -382,26 +382,12 @@ static long pickChunkOffset(long chunkOffset, long byteWidth, int chunkWidth) { : chunkOffset; } - public static Arena newBoundedArena(long size) { - return new Arena() { - final Arena arena = Arena.ofConfined(); - final SegmentAllocator slicingAllocator = SegmentAllocator.slicingAllocator(arena.allocate(size)); - - @Override - public Scope scope() { - return arena.scope(); - } + private static final int LINKER_STACK_SIZE = Integer.getInteger("jdk.internal.foreign.LINKER_STACK_SIZE", 256); + private static final BufferStack LINKER_STACK = new BufferStack(LINKER_STACK_SIZE); - @Override - public void close() { - arena.close(); - } - - @Override - public MemorySegment allocate(long byteSize, long byteAlignment) { - return slicingAllocator.allocate(byteSize, byteAlignment); - } - }; + @ForceInline + public static Arena newBoundedArena(long size) { + return LINKER_STACK.pushFrame(size, 8); } public static Arena newEmptyArena() { diff --git a/test/jdk/java/foreign/TestBufferStack.java b/test/jdk/java/foreign/TestBufferStack.java new file mode 100644 index 0000000000000..bf1ada8854c5b --- /dev/null +++ b/test/jdk/java/foreign/TestBufferStack.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 + * @modules java.base/jdk.internal.foreign.abi + * @build NativeTestHelper TestBufferStack + * @run testng/othervm --enable-native-access=ALL-UNNAMED TestBufferStack + */ + +import jdk.internal.foreign.abi.BufferStack; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.invoke.MethodHandle; +import java.time.Duration; +import java.util.Arrays; +import java.util.stream.IntStream; + +import static java.lang.foreign.MemoryLayout.structLayout; +import static java.lang.foreign.ValueLayout.*; +import static java.time.temporal.ChronoUnit.SECONDS; + +public class TestBufferStack extends NativeTestHelper { + @Test + public void testScopedAllocation() { + int stackSize = 128; + BufferStack stack = new BufferStack(stackSize); + MemorySegment stackSegment; + try (Arena frame1 = stack.pushFrame(3 * JAVA_INT.byteSize(), JAVA_INT.byteAlignment())) { + // Segments have expected sizes and are accessible and allocated consecutively in the same scope. + MemorySegment segment11 = frame1.allocate(JAVA_INT); + Assert.assertEquals(segment11.scope(), frame1.scope()); + Assert.assertEquals(segment11.byteSize(), JAVA_INT.byteSize()); + segment11.set(JAVA_INT, 0, 1); + stackSegment = segment11.reinterpret(stackSize); + + MemorySegment segment12 = frame1.allocate(JAVA_INT); + Assert.assertEquals(segment12.address(), segment11.address() + JAVA_INT.byteSize()); + Assert.assertEquals(segment12.byteSize(), JAVA_INT.byteSize()); + Assert.assertEquals(segment12.scope(), frame1.scope()); + segment12.set(JAVA_INT, 0, 1); + + MemorySegment segment2; + try (Arena frame2 = stack.pushFrame(JAVA_LONG.byteSize(), JAVA_LONG.byteAlignment())) { + Assert.assertNotEquals(frame2.scope(), frame1.scope()); + // same here, but a new scope. + segment2 = frame2.allocate(JAVA_LONG); + Assert.assertEquals(segment2.address(), segment12.address() + /*segment12 size + frame 1 spare + alignment constraint*/ 3 * JAVA_INT.byteSize()); + Assert.assertEquals(segment2.byteSize(), JAVA_LONG.byteSize()); + Assert.assertEquals(segment2.scope(), frame2.scope()); + segment2.set(JAVA_LONG, 0, 1); + + // Frames must be closed in stack order. + Assert.assertThrows(IllegalStateException.class, frame1::close); + } + // Scope is closed here, inner segments throw. + Assert.assertThrows(IllegalStateException.class, () -> segment2.get(JAVA_INT, 0)); + // A new stack frame allocates at the same location (but different scope) as the previous did. + try (Arena frame3 = stack.pushFrame(2 * JAVA_INT.byteSize(), JAVA_INT.byteAlignment())) { + MemorySegment segment3 = frame3.allocate(JAVA_INT); + Assert.assertEquals(segment3.scope(), frame3.scope()); + Assert.assertEquals(segment3.address(), segment12.address() + 2 * JAVA_INT.byteSize()); + } + + // Fallback arena behaves like regular stack frame. + MemorySegment outOfStack; + try (Arena hugeFrame = stack.pushFrame(1024, 4)) { + outOfStack = hugeFrame.allocate(4); + Assert.assertEquals(outOfStack.scope(), hugeFrame.scope()); + Assert.assertTrue(outOfStack.asOverlappingSlice(stackSegment).isEmpty()); + } + Assert.assertThrows(IllegalStateException.class, () -> outOfStack.get(JAVA_INT, 0)); + + // Outer segments are still accessible. + segment11.get(JAVA_INT, 0); + segment12.get(JAVA_INT, 0); + } + } + + @Test + public void stress() throws InterruptedException { + BufferStack stack = new BufferStack(256); + Thread[] vThreads = IntStream.range(0, 1024).mapToObj(_ -> + Thread.ofVirtual().start(() -> { + long threadId = Thread.currentThread().threadId(); + while (!Thread.interrupted()) { + for (int i = 0; i < 1_000_000; i++) { + try (Arena arena = stack.pushFrame(JAVA_LONG.byteSize(), JAVA_LONG.byteAlignment())) { + // Try to assert no two vThreads get allocated the same stack space. + MemorySegment segment = arena.allocate(JAVA_LONG); + JAVA_LONG.varHandle().setVolatile(segment, 0L, threadId); + Assert.assertEquals(threadId, (long) JAVA_LONG.varHandle().getVolatile(segment, 0L)); + } + } + Thread.yield(); // make sure the driver thread gets a chance. + } + })).toArray(Thread[]::new); + Thread.sleep(Duration.of(10, SECONDS)); + Arrays.stream(vThreads).forEach( + thread -> { + Assert.assertTrue(thread.isAlive()); + thread.interrupt(); + }); + } + + static { + System.loadLibrary("TestBufferStack"); + } + + private static final MemoryLayout HVAPoint3D = structLayout(NativeTestHelper.C_DOUBLE, C_DOUBLE, C_DOUBLE); + private static final MemorySegment UPCALL_MH = upcallStub(TestBufferStack.class, "recurse", FunctionDescriptor.of(HVAPoint3D, C_INT)); + private static final MethodHandle DOWNCALL_MH = downcallHandle("recurse", FunctionDescriptor.of(HVAPoint3D, C_INT, ADDRESS)); + + public static MemorySegment recurse(int depth) { + try { + return (MemorySegment) DOWNCALL_MH.invokeExact((SegmentAllocator) Arena.ofAuto(), depth, UPCALL_MH); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + @Test + public void testDeepStack() throws Throwable { + // Each downcall and upcall require 48 bytes of stack. + // After five allocations we start falling back. + MemorySegment point = recurse(10); + Assert.assertEquals(point.getAtIndex(C_DOUBLE, 0), 12.0); + Assert.assertEquals(point.getAtIndex(C_DOUBLE, 1), 11.0); + Assert.assertEquals(point.getAtIndex(C_DOUBLE, 2), 10.0); + } +} diff --git a/test/jdk/java/foreign/libTestBufferStack.c b/test/jdk/java/foreign/libTestBufferStack.c new file mode 100644 index 0000000000000..79eb32bf9334c --- /dev/null +++ b/test/jdk/java/foreign/libTestBufferStack.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 "export.h" + +typedef struct { double x, y, z; } HVAPoint3D; + +EXPORT HVAPoint3D recurse(int depth, HVAPoint3D (*cb)(int)) { + if (depth == 0) { + HVAPoint3D result = { 2, 1, 0}; + return result; + } + + HVAPoint3D result = cb(depth - 1); + result.x += 1; + result.y += 1; + result.z += 1; + return result; +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadByValue.java b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadByValue.java new file mode 100644 index 0000000000000..8fae1905472ec --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadByValue.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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.foreign; + +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.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.util.concurrent.TimeUnit; + +import static org.openjdk.bench.java.lang.foreign.CLayouts.C_DOUBLE; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@State(org.openjdk.jmh.annotations.Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +public class CallOverheadByValue { + + public static final MemoryLayout POINT_LAYOUT = MemoryLayout.structLayout( + C_DOUBLE, C_DOUBLE + ); + private static final MethodHandle MH_UNIT_BY_VALUE; + private static final MethodHandle MH_UNIT_BY_PTR; + + static { + Linker abi = Linker.nativeLinker(); + System.loadLibrary("CallOverheadByValue"); + SymbolLookup loaderLibs = SymbolLookup.loaderLookup(); + MH_UNIT_BY_VALUE = abi.downcallHandle( + loaderLibs.findOrThrow("unit"), + FunctionDescriptor.of(POINT_LAYOUT) + ); + MH_UNIT_BY_PTR = abi.downcallHandle( + loaderLibs.findOrThrow("unit_ptr"), + FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); + } + + Arena arena = Arena.ofConfined(); + MemorySegment point = arena.allocate(POINT_LAYOUT); + + @TearDown + public void tearDown() { + arena.close(); + } + + @Benchmark + public void byValue() throws Throwable { + // point = unit(); + MemorySegment unused = (MemorySegment) MH_UNIT_BY_VALUE.invokeExact( + (SegmentAllocator) (_, _) -> point); + } + + @Benchmark + public void byPtr() throws Throwable { + // unit_ptr(&point); + MH_UNIT_BY_PTR.invokeExact(point); + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/libCallOverheadByValue.c b/test/micro/org/openjdk/bench/java/lang/foreign/libCallOverheadByValue.c new file mode 100644 index 0000000000000..2eb80f537d8c8 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/libCallOverheadByValue.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 "export.h" + +typedef struct { + double x; + double y; +} DoublePoint; + +EXPORT DoublePoint unit() { + DoublePoint result = { 1, 0 }; + return result; +} + +EXPORT void unit_ptr(DoublePoint* out) { + *out = unit(); +} From 21feef32803b2593b097fb225c7a4c7cd46525da Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Mon, 27 Jan 2025 19:45:50 +0000 Subject: [PATCH 251/263] 8348239: SA does not know about DeoptimizeObjectsALotThread Reviewed-by: kevinw, dlong, dholmes, lmesnik --- src/hotspot/share/compiler/compileBroker.cpp | 14 ------- src/hotspot/share/compiler/compileBroker.hpp | 18 +++++++- src/hotspot/share/runtime/vmStructs.cpp | 2 + .../runtime/DeoptimizeObjectsALotThread.java | 42 +++++++++++++++++++ .../sun/jvm/hotspot/runtime/Thread.java | 3 +- .../sun/jvm/hotspot/runtime/Threads.java | 18 ++++---- 6 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index badcfeab2954e..6659ac90dd822 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -773,20 +773,6 @@ void CompileBroker::compilation_init(JavaThread* THREAD) { } #if defined(ASSERT) && COMPILER2_OR_JVMCI -// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to -// the running java application. Configured with vm options DeoptimizeObjectsALot*. -class DeoptimizeObjectsALotThread : public JavaThread { - - static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS); - void deoptimize_objects_alot_loop_single(); - void deoptimize_objects_alot_loop_all(); - -public: - DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { } - - bool is_hidden_from_external_view() const { return true; } -}; - // Entry for DeoptimizeObjectsALotThread. The threads are started in // CompileBroker::init_compiler_threads() iff DeoptimizeObjectsALot is enabled void DeoptimizeObjectsALotThread::deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS) { diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index f6067f75d32aa..ac62a20bc6ff2 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,22 @@ class nmethod; +#if defined(ASSERT) && COMPILER2_OR_JVMCI +// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to +// the running java application. Configured with vm options DeoptimizeObjectsALot*. +class DeoptimizeObjectsALotThread : public JavaThread { + + static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS); + void deoptimize_objects_alot_loop_single(); + void deoptimize_objects_alot_loop_all(); + +public: + DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { } + + bool is_hidden_from_external_view() const { return true; } +}; +#endif + // CompilerCounters // // Per Compiler Performance Counters. diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 37c4aebf58bfb..6613f30016109 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -1261,6 +1261,8 @@ declare_type(CompilerThread, JavaThread) \ declare_type(StringDedupThread, JavaThread) \ declare_type(AttachListenerThread, JavaThread) \ + DEBUG_ONLY(COMPILER2_OR_JVMCI_PRESENT( \ + declare_type(DeoptimizeObjectsALotThread, JavaThread))) \ declare_toplevel_type(OSThread) \ declare_toplevel_type(JavaFrameAnchor) \ \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java new file mode 100644 index 0000000000000..b79d43948a209 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 sun.jvm.hotspot.runtime; + +import java.io.*; + +import sun.jvm.hotspot.debugger.Address; + +public class DeoptimizeObjectsALotThread extends JavaThread { + + public DeoptimizeObjectsALotThread (Address addr) { + super(addr); + } + + public boolean isJavaThread() { return false; } + public boolean isHiddenFromExternalView() { return true; } + + public boolean isDeoptimizeObjectsALotThread() { return true; } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java index d9828b06e260c..f9f2f57892869 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,7 @@ public long allocatedBytes() { public boolean isServiceThread() { return false; } public boolean isMonitorDeflationThread() { return false; } public boolean isAttachListenerThread() { return false; } + public boolean isDeoptimizeObjectsALotThread() { return false; } /** Memory operations */ public void oopsDo(AddressVisitor oopVisitor) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index e2e0c98942557..f449fc317e1aa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,19 +155,19 @@ private static synchronized void initialize(TypeDataBase db) { virtualConstructor.addMapping("NotificationThread", NotificationThread.class); virtualConstructor.addMapping("StringDedupThread", StringDedupThread.class); virtualConstructor.addMapping("AttachListenerThread", AttachListenerThread.class); + virtualConstructor.addMapping("DeoptimizeObjectsALotThread", DeoptimizeObjectsALotThread.class); } public Threads() { _list = VMObjectFactory.newObject(ThreadsList.class, threadListField.getValue()); } - /** NOTE: this returns objects of type JavaThread, CompilerThread, - JvmtiAgentThread, NotificationThread, MonitorDeflationThread, - StringDedupThread, AttachListenerThread and ServiceThread. - The latter seven subclasses of the former. Most operations - (fetching the top frame, etc.) are only allowed to be performed on - a "pure" JavaThread. For this reason, {@link - sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been + /** NOTE: this returns objects of type JavaThread or one if its subclasses: + CompilerThread, JvmtiAgentThread, NotificationThread, MonitorDeflationThread, + StringDedupThread, AttachListenerThread, DeoptimizeObjectsALotThread and + ServiceThread. Most operations (fetching the top frame, etc.) are only + allowed to be performed on a "pure" JavaThread. For this reason, + {@link sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been changed from the definition in the VM (which returns true for all of these thread types) to return true for JavaThreads and false for the seven subclasses. FIXME: should reconsider the @@ -195,7 +195,7 @@ public JavaThread createJavaThreadWrapper(Address threadAddr) { } catch (Exception e) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + " (expected type JavaThread, CompilerThread, MonitorDeflationThread, AttachListenerThread," + - " StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e); + " DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e); } } From 1916a7773f2083096e18b92d71d384453652c07d Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Mon, 27 Jan 2025 22:41:55 +0000 Subject: [PATCH 252/263] 8346923: MetaspaceShared base calculation may cause overflow in align_up Reviewed-by: iklam, matsaave --- src/hotspot/share/cds/metaspaceShared.cpp | 57 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 2020a477d73a8..a51a903df090a 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -214,34 +214,64 @@ void MetaspaceShared::dump_loaded_classes(const char* file_name, TRAPS) { } } -static bool shared_base_too_high(char* specified_base, char* aligned_base, size_t cds_max) { - if (specified_base != nullptr && aligned_base < specified_base) { - // SharedBaseAddress is very high (e.g., 0xffffffffffffff00) so - // align_up(SharedBaseAddress, MetaspaceShared::core_region_alignment()) has wrapped around. - return true; +// If p is not aligned, move it up to the next address that's aligned with alignment. +// If this is not possible (because p is too high), return nullptr. Example: +// p = 0xffffffffffff0000, alignment= 0x10000 => return nullptr. +static char* align_up_or_null(char* p, size_t alignment) { + assert(p != nullptr, "sanity"); + if (is_aligned(p, alignment)) { + return p; + } + + char* down = align_down(p, alignment); + if (max_uintx - uintx(down) < uintx(alignment)) { + // Run out of address space to align up. + return nullptr; } + + char* aligned = align_up(p, alignment); + assert(aligned >= p, "sanity"); + assert(aligned != nullptr, "sanity"); + return aligned; +} + +static bool shared_base_too_high(char* specified_base, char* aligned_base, size_t cds_max) { + // Caller should have checked if align_up_or_null( returns nullptr (comparing specified_base + // with nullptr is UB). + assert(aligned_base != nullptr, "sanity"); + assert(aligned_base >= specified_base, "sanity"); + if (max_uintx - uintx(aligned_base) < uintx(cds_max)) { - // The end of the archive will wrap around + // Not enough address space to hold an archive of cds_max bytes from aligned_base. return true; + } else { + return false; } - - return false; } static char* compute_shared_base(size_t cds_max) { char* specified_base = (char*)SharedBaseAddress; - char* aligned_base = align_up(specified_base, MetaspaceShared::core_region_alignment()); + size_t alignment = MetaspaceShared::core_region_alignment(); if (UseCompressedClassPointers) { - aligned_base = align_up(specified_base, Metaspace::reserve_alignment()); + alignment = MAX2(alignment, Metaspace::reserve_alignment()); } + if (SharedBaseAddress == 0) { + // Special meaning of -XX:SharedBaseAddress=0 -> Always map archive at os-selected address. + return specified_base; + } + + char* aligned_base = align_up_or_null(specified_base, alignment); + if (aligned_base != specified_base) { log_info(cds)("SharedBaseAddress (" INTPTR_FORMAT ") aligned up to " INTPTR_FORMAT, p2i(specified_base), p2i(aligned_base)); } const char* err = nullptr; - if (shared_base_too_high(specified_base, aligned_base, cds_max)) { + if (aligned_base == nullptr) { + err = "too high"; + } else if (shared_base_too_high(specified_base, aligned_base, cds_max)) { err = "too high"; } else if (!shared_base_valid(aligned_base)) { err = "invalid for this platform"; @@ -249,12 +279,15 @@ static char* compute_shared_base(size_t cds_max) { return aligned_base; } + // Arguments::default_SharedBaseAddress() is hard-coded in cds_globals.hpp. It must be carefully + // picked that (a) the align_up() below will always return a valid value; (b) none of + // the following asserts will fail. log_warning(cds)("SharedBaseAddress (" INTPTR_FORMAT ") is %s. Reverted to " INTPTR_FORMAT, p2i((void*)SharedBaseAddress), err, p2i((void*)Arguments::default_SharedBaseAddress())); specified_base = (char*)Arguments::default_SharedBaseAddress(); - aligned_base = align_up(specified_base, MetaspaceShared::core_region_alignment()); + aligned_base = align_up(specified_base, alignment); // Make sure the default value of SharedBaseAddress specified in globals.hpp is sane. assert(!shared_base_too_high(specified_base, aligned_base, cds_max), "Sanity"); From 46f48e4e3d5dd4506c77cda1b01b9c008cb6a738 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 28 Jan 2025 00:12:57 +0000 Subject: [PATCH 253/263] 8348515: Add docs for -XX:AOT* options in java man pages Reviewed-by: adinn, kvn --- src/java.base/share/man/java.md | 104 ++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/src/java.base/share/man/java.md b/src/java.base/share/man/java.md index 78b763f578639..49a74daea067d 100644 --- a/src/java.base/share/man/java.md +++ b/src/java.base/share/man/java.md @@ -4004,6 +4004,110 @@ JVM will execute without loading any CDS archives. In addition, if you try to create a CDS archive with any of these 3 options specified, the JVM will report an error. +## Ahead-of-Time Cache + +The JDK supports ahead-of-time (AOT) optimizations that can be performed before an +application is executed. One example is Class Data Sharing (CDS), as described above, +that parses classes ahead of time. AOT optimizations can improve the start-up and +warm-up performance of Java applications. + +The Ahead-of-Time Cache (AOTCache) is a container introduced in JDK 24 for +storing artifacts produced by AOT optimizations. The AOTCache currently contains +Java classes and heap objects. The plans is to include other types of artifacts, +such as execution profiles and compiled methods, in future JDK releases. + +An AOTCache is specific to a combination of the following: + +- A particular application (as expressed by `-classpath`, `-jar`, or `--module-path`.) +- A particular JDK release. +- A particular OS and CPU architecture. + +If any of the above changes, you must recreate the AOTCache. + +The deployment of the AOTCache is divided into three phases: + +- **Training:** We execute the application with a representative work-load + to gather statistical data that tell us what artifacts should be included + into the AOTCache. The data are saved in an *AOT Configuration* file. + +- **Assembly:** We use the AOT Configuration file to produce an AOTCache. + +- **Production:** We execute the application with the AOTCache for better + start-up and warm-up performance. + +The AOTCache can be used with the following command-line options: + +`-XX:AOTCache:=`*cachefile* +: Specifies the location of the AOTCache. The standard extension for *cachefile* is `.aot`. + If `-XX:AOTCache` is specified but `-XX:AOTMode` is not specified, + then `AOTMode` will be given the value of `auto`. + +`-XX:AOTConfiguration:=`*configfile* +: Specifies the AOT Configuration file for the JVM to write to or read from. + This option can be used only with `-XX:AOTMode=record` and `-XX:AOTMode=create`. + The standard extension for *configfile* is `.aotconfig`. + +`-XX:+AOTMode:=`*mode* +: *mode* must be one of the following: `off`, `record`, `create`, `auto`, or `on`. + +- `off`: AOTCache is not used. + +- `record`: Execute the application in the Training phase. + `-XX:AOTConfiguration=`*configfile* must be specified. The JVM gathers + statistical data and stores them into *configfile*. + +- `create`: Perform the Assembly phase. `-XX:AOTConfiguration=`*configfile* + and `-XX:AOTCache=`*cachefile* must be specified. The JVM reads the statistical + data from *configfile* and writes the optimization artifacts into *cachefile*. + Note that the application itself is not executed in this phase. + +- `auto` or `on`: These modes should be used in the Production phase. + If `-XX:AOTCache=`*cachefile* is specified, the JVM tries to + load *cachefile* as the AOTCache. Otherwise, the JVM tries to load + a *default CDS archive* from the JDK installation directory as the AOTCache. + + The loading of an AOTCache can fail for a number of reasons: + + - You are trying to use the AOTCache with an incompatible application, JDK release, + or OS/CPU. + + - The specified AOTCache file does not exist or is not accessible. + + - Incompatible JVM options are used (for example, certain JVMTI options). + + Since AOTCache is an optimization feature, there's no guarantee that it will be + compatible with all possible JVM options. See [JEP 483](https://openjdk.org/jeps/483), + section **Consistency of training and subsequent runs** for a representitive + list of scenarios that may be incompatible with the AOTCache for JDK 24. + + These scenarios usually involve arbitrary modification of classes for diagnostic + purposes and are typically not relevant for production environments. + + When the AOTCache fails to load: + + - If `AOTMode` is `auto`, the JVM will continue execution without using the + AOTCache. This is the recommended mode for production environments, especially + when you may not have complete control of the command-line (e.g., your + application's launch script may allow users to inject options to the command-line). + This allows your application to function correctly, although sometimes it may not + benefit from the AOTCache. + + - If `AOTMode` is `on`, the JVM will print an error message and exit immediately. This + mode should be used only as a "fail-fast" debugging aid to check if your command-line + options are compatible with the AOTCache. An alternative is to run your application with + `-XX:AOTMode=auto -Xlog:cds` to see if the AOTCache can be used or not. + +`-XX:+AOTClassLinking` +: If this options is specified with `-XX:AOTMode=create`, the JVM will perform more + advanced optimizations (such as ahead-of-time resolution of invokedynamic instructions) + when creating the AOTCache. As a result, the appication will see further improvements + in start-up and warm-up performance. + + Using `-XX:+AOTClassLinking` will impose further restrictions on command-line options + that can be used in the Production phase. Please see [JEP 483](https://openjdk.org/jeps/483) for a + detailed discussion of `-XX:+AOTClassLinking` and its restrictions. + + ## Performance Tuning Examples You can use the Java advanced runtime options to optimize the performance of From 2537a05c06171ce91eae69d478c4e4e88a11a60f Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Tue, 28 Jan 2025 07:35:30 +0000 Subject: [PATCH 254/263] 8348384: RISC-V: Disable auto-enable Vector on buggy kernels Reviewed-by: fyang, mli, luhenry --- src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp index 10652660c7362..5b427693a8dfd 100644 --- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -24,6 +24,8 @@ */ #include "logging/log.hpp" +#include "logging/logMessage.hpp" +#include "os_linux.hpp" #include "riscv_hwprobe.hpp" #include "runtime/os.hpp" #include "runtime/vm_version.hpp" @@ -163,7 +165,18 @@ void RiscvHwprobe::add_features_from_query_result() { VM_Version::ext_C.enable_feature(); } if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_V)) { - VM_Version::ext_V.enable_feature(); + // Linux signal return bug when using vector with vlen > 128b in pre 6.8.5. + long major, minor, patch; + os::Linux::kernel_version(&major, &minor, &patch); + if (os::Linux::kernel_version_compare(major, minor, patch, 6, 8, 5) == -1) { + LogMessage(os) log; + if (log.is_info()) { + log.info("Linux kernels before 6.8.5 (current %ld.%ld.%ld) have a known bug when using Vector and signals.", major, minor, patch); + log.info("Vector not enabled automatically via hwprobe, but can be turned on with -XX:+UseRVV."); + } + } else { + VM_Version::ext_V.enable_feature(); + } } if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZBA)) { VM_Version::ext_Zba.enable_feature(); From f71541c93b814cd39c3dd253234a453e5d71f4c0 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Tue, 28 Jan 2025 09:22:50 +0000 Subject: [PATCH 255/263] 8344976: Remove the jmx.invoke.getters compatibility property Reviewed-by: cjplummer, dfuchs, sspitsyn --- .../com/sun/jmx/mbeanserver/PerInterface.java | 79 +------------------ .../Introspector/InvokeGettersTest.java | 13 ++- 2 files changed, 8 insertions(+), 84 deletions(-) diff --git a/src/java.management/share/classes/com/sun/jmx/mbeanserver/PerInterface.java b/src/java.management/share/classes/com/sun/jmx/mbeanserver/PerInterface.java index 6684e0390cf31..f8cab63c48422 100644 --- a/src/java.management/share/classes/com/sun/jmx/mbeanserver/PerInterface.java +++ b/src/java.management/share/classes/com/sun/jmx/mbeanserver/PerInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,8 +108,7 @@ Object invoke(Object resource, String operation, Object[] params, final List list = ops.get(operation); if (list == null) { final String msg = "No such operation: " + operation; - return noSuchMethod(msg, resource, operation, params, signature, - cookie); + throw new ReflectionException(new NoSuchMethodException(operation + sigString(signature)), msg); } if (signature == null) signature = new String[0]; @@ -131,83 +130,11 @@ Object invoke(Object resource, String operation, Object[] params, msg = "Operation " + operation + " exists but not with " + "this signature: " + badSig; } - return noSuchMethod(msg, resource, operation, params, signature, - cookie); + throw new ReflectionException(new NoSuchMethodException(operation + badSig), msg); } return introspector.invokeM(found.method, resource, params, cookie); } - /* - * This method is called when invoke doesn't find the named method. - * Before throwing an exception, we check to see whether the - * jmx.invoke.getters property is set, and if so whether the method - * being invoked might be a getter or a setter. If so we invoke it - * and return the result. This is for compatibility - * with code based on JMX RI 1.0 or 1.1 which allowed invoking getters - * and setters. It is *not* recommended that new code use this feature. - * - * Since this method is either going to throw an exception or use - * functionality that is strongly discouraged, we consider that its - * performance is not very important. - * - * A simpler way to implement the functionality would be to add the getters - * and setters to the operations map when jmx.invoke.getters is set. - * However, that means that the property is consulted when an MBean - * interface is being introspected and not thereafter. Previously, - * the property was consulted on every invocation. So this simpler - * implementation could potentially break code that sets and unsets - * the property at different times. - */ - @SuppressWarnings("removal") - private Object noSuchMethod(String msg, Object resource, String operation, - Object[] params, String[] signature, - Object cookie) - throws MBeanException, ReflectionException { - - // Construct the exception that we will probably throw - final NoSuchMethodException nsme = - new NoSuchMethodException(operation + sigString(signature)); - final ReflectionException exception = - new ReflectionException(nsme, msg); - - if (introspector.isMXBean()) - throw exception; // No compatibility requirement here - - // Is the compatibility property set? - String invokeGettersS = System.getProperty("jmx.invoke.getters"); - if (invokeGettersS == null) - throw exception; - - int rest = 0; - Map methods = null; - if (signature == null || signature.length == 0) { - if (operation.startsWith("get")) - rest = 3; - else if (operation.startsWith("is")) - rest = 2; - if (rest != 0) - methods = getters; - } else if (signature.length == 1 && - operation.startsWith("set")) { - rest = 3; - methods = setters; - } - - if (rest != 0) { - String attrName = operation.substring(rest); - M method = methods.get(attrName); - if (method != null && introspector.getName(method).equals(operation)) { - String[] msig = introspector.getSignature(method); - if ((signature == null && msig.length == 0) || - Arrays.equals(signature, msig)) { - return introspector.invokeM(method, resource, params, cookie); - } - } - } - - throw exception; - } - private String sigString(String[] signature) { StringBuilder b = new StringBuilder("("); if (signature != null) { diff --git a/test/jdk/javax/management/Introspector/InvokeGettersTest.java b/test/jdk/javax/management/Introspector/InvokeGettersTest.java index 6036069a6f5b2..71e22ca3d711f 100644 --- a/test/jdk/javax/management/Introspector/InvokeGettersTest.java +++ b/test/jdk/javax/management/Introspector/InvokeGettersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ /* * @test - * @bug 6317101 - * @summary Test that the jmx.invoke.getters system property works + * @bug 6317101 8344976 + * @summary Test invocation after removal of the jmx.invoke.getters system property * @author Eamonn McManus * * @run clean InvokeGettersTest @@ -63,10 +63,7 @@ public static void main(String[] args) throws Exception { ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(new Thing(), on); if (test(mbs, on, false)) - System.out.println("OK: invoke without jmx.invoke.getters"); - System.setProperty("jmx.invoke.getters", "true"); - if (test(mbs, on, true)) - System.out.println("OK: invoke with jmx.invoke.getters"); + System.out.println("OK"); if (failure == null) System.out.println("TEST PASSED"); else @@ -117,7 +114,7 @@ private static boolean test(MBeanServer mbs, ObjectName on, System.out.println("isTrue got expected exception: " + e); } - // Following cases should fail whether or not jmx.invoke.getters is set + // Following cases should fail final Object[][] badInvokes = { {"isWhatsit", null, null}, {"getWhatsit", new Object[] {5}, new String[] {"int"}}, From 1f74caa7da9dc0bf0eb515b36791f6fd069e044d Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Tue, 28 Jan 2025 09:41:12 +0000 Subject: [PATCH 256/263] 8348401: [IR Framework] PrintTimes should not require verbose Reviewed-by: kvn, chagedorn --- .../lib/ir_framework/shared/TestFrameworkSocket.java | 7 +++++++ .../jtreg/compiler/lib/ir_framework/test/TestVM.java | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java index c59f432f5ffb1..7f7aa3f5b32fd 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java @@ -43,6 +43,7 @@ public class TestFrameworkSocket implements AutoCloseable { public static final String STDOUT_PREFIX = "[STDOUT]"; public static final String TESTLIST_TAG = "[TESTLIST]"; public static final String DEFAULT_REGEX_TAG = "[DEFAULT_REGEX]"; + public static final String PRINT_TIMES_TAG = "[PRINT_TIMES]"; // Static fields used for test VM only. private static final String SERVER_PORT_PROPERTY = "ir.framework.server.port"; @@ -123,6 +124,12 @@ public static void write(String msg, String tag) { /** * Only called by test VM to write to server socket. + *

    + * The test VM is spawned by the main jtreg VM. The stdout of the test VM is hidden + * unless the Verbose or ReportStdout flag is used. TestFrameworkSocket is used by the parent jtreg + * VM and the test VM to communicate. By sending the prints through the TestFrameworkSocket with the + * parameter stdout set to true, the parent VM will print the received messages to its stdout, making it + * visible to the user. */ public static void write(String msg, String tag, boolean stdout) { if (REPRODUCE) { diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java index 4e601ec973964..e4f49d494d2b8 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static compiler.lib.ir_framework.shared.TestFrameworkSocket.PRINT_TIMES_TAG; + /** * This class' main method is called from {@link TestFramework} and represents the so-called "test VM". The class is * the heart of the framework and is responsible for executing all the specified tests in the test class. It uses the @@ -883,9 +885,10 @@ private void runTests() { // Print execution times if (VERBOSE || PRINT_TIMES) { - System.out.println(System.lineSeparator() + System.lineSeparator() + "Test execution times:"); + TestFrameworkSocket.write("Test execution times:", PRINT_TIMES_TAG, true); for (Map.Entry entry : durations.entrySet()) { - System.out.format("%-10s%15d ns%n", entry.getValue() + ":", entry.getKey()); + TestFrameworkSocket.write(String.format("%-25s%15d ns%n", entry.getValue() + ":", entry.getKey()), + PRINT_TIMES_TAG, true); } } From 558255ae7029ea1091ec5bb05d2d48e9f0c58f72 Mon Sep 17 00:00:00 2001 From: Volkan Yazici Date: Tue, 28 Jan 2025 10:22:55 +0000 Subject: [PATCH 257/263] 8328919: Add BodyHandlers / BodySubscribers methods to handle excessive server input Reviewed-by: jpai --- .../classes/java/net/http/HttpResponse.java | 55 ++- .../internal/net/http/LimitingSubscriber.java | 148 +++++++ .../httpclient/HttpResponseLimitingTest.java | 418 ++++++++++++++++++ 3 files changed, 620 insertions(+), 1 deletion(-) create mode 100644 src/java.net.http/share/classes/jdk/internal/net/http/LimitingSubscriber.java create mode 100644 test/jdk/java/net/httpclient/HttpResponseLimitingTest.java diff --git a/src/java.net.http/share/classes/java/net/http/HttpResponse.java b/src/java.net.http/share/classes/java/net/http/HttpResponse.java index b9ea775532d17..41a439d551918 100644 --- a/src/java.net.http/share/classes/java/net/http/HttpResponse.java +++ b/src/java.net.http/share/classes/java/net/http/HttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,7 @@ import java.util.stream.Stream; import javax.net.ssl.SSLSession; import jdk.internal.net.http.BufferingSubscriber; +import jdk.internal.net.http.LimitingSubscriber; import jdk.internal.net.http.LineSubscriberAdapter; import jdk.internal.net.http.ResponseBodyHandlers.FileDownloadBodyHandler; import jdk.internal.net.http.ResponseBodyHandlers.PathBodyHandler; @@ -748,6 +749,33 @@ public static BodyHandler buffering(BodyHandler downstreamHandler, .buffering(downstreamHandler.apply(responseInfo), bufferSize); } + + /** + * {@return a {@code BodyHandler} that limits the number of body bytes + * that are delivered to the given {@code downstreamHandler}} + *

    + * If the number of body bytes received exceeds the given + * {@code capacity}, {@link BodySubscriber#onError(Throwable) onError} + * is called on the downstream {@code BodySubscriber} with an + * {@link IOException} indicating that the capacity is exceeded, and + * the upstream subscription is cancelled. + * + * @param downstreamHandler the downstream handler to pass received data to + * @param capacity the maximum number of bytes that are allowed + * @throws IllegalArgumentException if {@code capacity} is negative + * @since 25 + */ + public static BodyHandler limiting(BodyHandler downstreamHandler, long capacity) { + Objects.requireNonNull(downstreamHandler, "downstreamHandler"); + if (capacity < 0) { + throw new IllegalArgumentException("capacity must not be negative: " + capacity); + } + return responseInfo -> { + BodySubscriber downstreamSubscriber = downstreamHandler.apply(responseInfo); + return BodySubscribers.limiting(downstreamSubscriber, capacity); + }; + } + } /** @@ -1350,5 +1378,30 @@ public static BodySubscriber mapping(BodySubscriber upstream, { return new ResponseSubscribers.MappingSubscriber<>(upstream, mapper); } + + /** + * {@return a {@code BodySubscriber} that limits the number of body + * bytes that are delivered to the given {@code downstreamSubscriber}} + *

    + * If the number of body bytes received exceeds the given + * {@code capacity}, {@link BodySubscriber#onError(Throwable) onError} + * is called on the downstream {@code BodySubscriber} with an + * {@link IOException} indicating that the capacity is exceeded, and + * the upstream subscription is cancelled. + * + * @param downstreamSubscriber the downstream subscriber to pass received data to + * @param capacity the maximum number of bytes that are allowed + * @throws IllegalArgumentException if {@code capacity} is negative + * @since 25 + */ + public static BodySubscriber limiting(BodySubscriber downstreamSubscriber, long capacity) { + Objects.requireNonNull(downstreamSubscriber, "downstreamSubscriber"); + if (capacity < 0) { + throw new IllegalArgumentException("capacity must not be negative: " + capacity); + } + return new LimitingSubscriber<>(downstreamSubscriber, capacity); + } + } + } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/LimitingSubscriber.java b/src/java.net.http/share/classes/jdk/internal/net/http/LimitingSubscriber.java new file mode 100644 index 0000000000000..f1fd8e69a628f --- /dev/null +++ b/src/java.net.http/share/classes/jdk/internal/net/http/LimitingSubscriber.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.net.http; + +import jdk.internal.net.http.ResponseSubscribers.TrustedSubscriber; +import jdk.internal.net.http.common.Utils; + +import java.io.IOException; +import java.net.http.HttpResponse.BodySubscriber; +import java.nio.ByteBuffer; +import java.util.List; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Flow.Subscription; + +import static java.util.Objects.requireNonNull; + +/** + * A subscriber limiting the maximum number of bytes that are allowed to be consumed by a downstream subscriber. + * + * @param the response type + */ +public final class LimitingSubscriber implements TrustedSubscriber { + + private final BodySubscriber downstreamSubscriber; + + private final long capacity; + + private State state; + + private long length; + + private interface State { + + State TERMINATED = new State() {}; + + record Subscribed(Subscription subscription) implements State {} + + } + + /** + * @param downstreamSubscriber the downstream subscriber to pass received data to + * @param capacity the maximum number of bytes that are allowed + * @throws IllegalArgumentException if {@code capacity} is negative + */ + public LimitingSubscriber(BodySubscriber downstreamSubscriber, long capacity) { + if (capacity < 0) { + throw new IllegalArgumentException("capacity must not be negative: " + capacity); + } + this.downstreamSubscriber = requireNonNull(downstreamSubscriber, "downstreamSubscriber"); + this.capacity = capacity; + } + + @Override + public void onSubscribe(Subscription subscription) { + requireNonNull(subscription, "subscription"); + if (state != null) { + subscription.cancel(); + } else { + state = new State.Subscribed(subscription); + downstreamSubscriber.onSubscribe(subscription); + } + } + + @Override + public void onNext(List buffers) { + + // Check arguments + requireNonNull(buffers, "buffers"); + assert Utils.hasRemaining(buffers); + + // Short-circuit if not subscribed + if (!(state instanceof State.Subscribed subscribed)) { + return; + } + + // See if we may consume the input + boolean lengthAllocated = allocateLength(buffers); + if (lengthAllocated) { + downstreamSubscriber.onNext(buffers); + } else { // Otherwise, trigger failure + state = State.TERMINATED; + downstreamSubscriber.onError(new IOException("body exceeds capacity: " + capacity)); + subscribed.subscription.cancel(); + } + + } + + private boolean allocateLength(List buffers) { + long bufferLength = Utils.remaining(buffers); + long nextLength; + try { + nextLength = Math.addExact(length, bufferLength); + } catch (ArithmeticException _) { + return false; + } + if (nextLength > capacity) { + return false; + } + length = nextLength; + return true; + } + + @Override + public void onError(Throwable throwable) { + requireNonNull(throwable, "throwable"); + if (state instanceof State.Subscribed) { + state = State.TERMINATED; + downstreamSubscriber.onError(throwable); + } + } + + @Override + public void onComplete() { + if (state instanceof State.Subscribed) { + state = State.TERMINATED; + downstreamSubscriber.onComplete(); + } + } + + @Override + public CompletionStage getBody() { + return downstreamSubscriber.getBody(); + } + +} diff --git a/test/jdk/java/net/httpclient/HttpResponseLimitingTest.java b/test/jdk/java/net/httpclient/HttpResponseLimitingTest.java new file mode 100644 index 0000000000000..b87e7ea8e49dd --- /dev/null +++ b/test/jdk/java/net/httpclient/HttpResponseLimitingTest.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * 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 8328919 + * @summary tests `limiting()` in `HttpResponse.Body{Handlers,Subscribers}` + * @key randomness + * @library /test/lib + * /test/jdk/java/net/httpclient/lib + * @build jdk.httpclient.test.lib.common.HttpServerAdapters + * jdk.test.lib.RandomFactory + * jdk.test.lib.net.SimpleSSLContext + * @run junit HttpResponseLimitingTest + */ + +import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestServer; +import jdk.test.lib.RandomFactory; +import jdk.test.lib.net.SimpleSSLContext; +import org.junit.jupiter.api.AfterAll; +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 javax.net.ssl.SSLContext; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpHeaders; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandler; +import java.net.http.HttpResponse.BodyHandlers; +import java.net.http.HttpResponse.BodySubscriber; +import java.net.http.HttpResponse.BodySubscribers; +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Flow.Subscription; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.net.http.HttpClient.Builder.NO_PROXY; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Arrays.copyOfRange; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class HttpResponseLimitingTest { + + private static final Random RANDOM = RandomFactory.getRandom(); + + private static final byte[] RESPONSE_BODY = "random non-empty body".getBytes(UTF_8); + + private static final String RESPONSE_HEADER_NAME = "X-Excessive-Data"; + + /** + * A header value larger than {@link #RESPONSE_BODY} to verify that {@code limiting()} doesn't affect header parsing. + */ + private static final String RESPONSE_HEADER_VALUE = "!".repeat(RESPONSE_BODY.length + 1); + + private static final ServerClientPair HTTP1 = ServerClientPair.of(HttpClient.Version.HTTP_1_1, false); + + private static final ServerClientPair HTTPS1 = ServerClientPair.of(HttpClient.Version.HTTP_1_1, true); + + private static final ServerClientPair HTTP2 = ServerClientPair.of(HttpClient.Version.HTTP_2, false); + + private static final ServerClientPair HTTPS2 = ServerClientPair.of(HttpClient.Version.HTTP_2, true); + + private record ServerClientPair(HttpTestServer server, HttpClient client, HttpRequest request) { + + private static final SSLContext SSL_CONTEXT = createSslContext(); + + private static SSLContext createSslContext() { + try { + return new SimpleSSLContext().get(); + } catch (IOException exception) { + throw new UncheckedIOException(exception); + } + } + + private ServerClientPair { + try { + server.start(); + } catch (Exception serverException) { + try { + client.close(); + } catch (Exception clientException) { + Exception localClientException = new RuntimeException("failed closing client", clientException); + serverException.addSuppressed(localClientException); + } + throw new RuntimeException("failed closing server", serverException); + } + } + + private static ServerClientPair of(HttpClient.Version version, boolean secure) { + + // Create the server and the request URI + SSLContext sslContext = secure ? SSL_CONTEXT : null; + HttpTestServer server = createServer(version, sslContext); + String handlerPath = "/"; + String requestUriScheme = secure ? "https" : "http"; + URI requestUri = URI.create(requestUriScheme + "://" + server.serverAuthority() + handlerPath); + + // Register the request handler + server.addHandler( + (exchange) -> { + exchange.getResponseHeaders().addHeader(RESPONSE_HEADER_NAME, RESPONSE_HEADER_VALUE); + exchange.sendResponseHeaders(200, RESPONSE_BODY.length); + try (var outputStream = exchange.getResponseBody()) { + outputStream.write(RESPONSE_BODY); + } + exchange.close(); + }, + handlerPath); + + // Create the client and the request + HttpClient client = createClient(version, sslContext); + HttpRequest request = HttpRequest.newBuilder(requestUri).version(version).build(); + + // Create the pair + return new ServerClientPair(server, client, request); + + } + + private static HttpTestServer createServer(HttpClient.Version version, SSLContext sslContext) { + try { + return HttpTestServer.create(version, sslContext); + } catch (IOException exception) { + throw new UncheckedIOException(exception); + } + } + + private static HttpClient createClient(HttpClient.Version version, SSLContext sslContext) { + HttpClient.Builder builder = HttpClient.newBuilder().version(version).proxy(NO_PROXY); + if (sslContext != null) { + builder.sslContext(sslContext); + } + return builder.build(); + } + + private HttpResponse request(BodyHandler downstreamHandler, long capacity) throws Exception { + var handler = BodyHandlers.limiting(downstreamHandler, capacity); + return client.send(request, handler); + } + + @Override + public String toString() { + String version = client.version().toString(); + return client.sslContext() != null ? version.replaceFirst("_", "S_") : version; + } + + } + + @AfterAll + static void closeServerClientPairs() { + Exception[] exceptionRef = {null}; + Stream + .of(HTTP1, HTTPS1, HTTP2, HTTPS2) + .flatMap(pair -> Stream.of( + pair.client::close, + pair.server::stop)) + .forEach(closer -> { + try { + closer.run(); + } catch (Exception exception) { + if (exceptionRef[0] == null) { + exceptionRef[0] = exception; + } else { + exceptionRef[0].addSuppressed(exception); + } + } + }); + if (exceptionRef[0] != null) { + throw new RuntimeException("failed closing one or more server-client pairs", exceptionRef[0]); + } + } + + @ParameterizedTest + @MethodSource("sufficientCapacities") + void testSuccessOnSufficientCapacityForByteArray(ServerClientPair pair, long sufficientCapacity) throws Exception { + HttpResponse response = pair.request(BodyHandlers.ofByteArray(), sufficientCapacity); + verifyHeaders(response.headers()); + assertArrayEquals(RESPONSE_BODY, response.body()); + } + + @ParameterizedTest + @MethodSource("sufficientCapacities") + void testSuccessOnSufficientCapacityForInputStream(ServerClientPair pair, long sufficientCapacity) throws Exception { + HttpResponse response = pair.request(BodyHandlers.ofInputStream(), sufficientCapacity); + verifyHeaders(response.headers()); + try (InputStream responseBodyStream = response.body()) { + byte[] responseBodyBuffer = responseBodyStream.readAllBytes(); + assertArrayEquals(RESPONSE_BODY, responseBodyBuffer); + } + } + + static Arguments[] sufficientCapacities() { + long minExtremeCapacity = RESPONSE_BODY.length; + long maxExtremeCapacity = Long.MAX_VALUE; + long nonExtremeCapacity = RANDOM.nextLong(minExtremeCapacity + 1, maxExtremeCapacity); + return capacityArgs(minExtremeCapacity, nonExtremeCapacity, maxExtremeCapacity); + } + + @ParameterizedTest + @MethodSource("insufficientCapacities") + void testFailureOnInsufficientCapacityForByteArray(ServerClientPair pair, long insufficientCapacity) { + BodyHandler handler = responseInfo -> { + verifyHeaders(responseInfo.headers()); + return BodySubscribers.limiting(BodySubscribers.ofByteArray(), insufficientCapacity); + }; + var exception = assertThrows(IOException.class, () -> pair.request(handler, insufficientCapacity)); + assertEquals(exception.getMessage(), "body exceeds capacity: " + insufficientCapacity); + } + + @ParameterizedTest + @MethodSource("insufficientCapacities") + void testFailureOnInsufficientCapacityForInputStream(ServerClientPair pair, long insufficientCapacity) throws Exception { + HttpResponse response = pair.request(BodyHandlers.ofInputStream(), insufficientCapacity); + verifyHeaders(response.headers()); + try (InputStream responseBodyStream = response.body()) { + var exception = assertThrows(IOException.class, responseBodyStream::readAllBytes); + assertNotNull(exception.getCause()); + assertEquals(exception.getCause().getMessage(), "body exceeds capacity: " + insufficientCapacity); + } + } + + static Arguments[] insufficientCapacities() { + long minExtremeCapacity = 0; + long maxExtremeCapacity = RESPONSE_BODY.length - 1; + long nonExtremeCapacity = RANDOM.nextLong(minExtremeCapacity + 1, maxExtremeCapacity); + return capacityArgs(minExtremeCapacity, nonExtremeCapacity, maxExtremeCapacity); + } + + private static void verifyHeaders(HttpHeaders responseHeaders) { + List responseHeaderValues = responseHeaders.allValues(RESPONSE_HEADER_NAME); + assertEquals(List.of(RESPONSE_HEADER_VALUE), responseHeaderValues); + } + + @ParameterizedTest + @MethodSource("invalidCapacities") + void testFailureOnInvalidCapacityForHandler(long invalidCapacity) { + var exception = assertThrows( + IllegalArgumentException.class, + () -> BodyHandlers.limiting(BodyHandlers.ofByteArray(), invalidCapacity)); + assertEquals(exception.getMessage(), "capacity must not be negative: " + invalidCapacity); + } + + @ParameterizedTest + @MethodSource("invalidCapacities") + void testFailureOnInvalidCapacityForSubscriber(long invalidCapacity) { + var exception = assertThrows( + IllegalArgumentException.class, + () -> BodySubscribers.limiting(BodySubscribers.ofByteArray(), invalidCapacity)); + assertEquals(exception.getMessage(), "capacity must not be negative: " + invalidCapacity); + } + + static long[] invalidCapacities() { + long minExtremeCapacity = Long.MIN_VALUE; + long maxExtremeCapacity = -1; + long nonExtremeCapacity = RANDOM.nextLong(minExtremeCapacity + 1, maxExtremeCapacity); + return new long[]{minExtremeCapacity, nonExtremeCapacity, maxExtremeCapacity}; + } + + @Test + void testFailureOnNullDownstreamHandler() { + var exception = assertThrows(NullPointerException.class, () -> BodyHandlers.limiting(null, 0)); + assertEquals(exception.getMessage(), "downstreamHandler"); + } + + @Test + void testFailureOnNullDownstreamSubscriber() { + var exception = assertThrows(NullPointerException.class, () -> BodySubscribers.limiting(null, 0)); + assertEquals(exception.getMessage(), "downstreamSubscriber"); + } + + private static Arguments[] capacityArgs(long... capacities) { + return Stream + .of(HTTP1, HTTPS1, HTTP2, HTTPS2) + .flatMap(pair -> Arrays + .stream(capacities) + .mapToObj(capacity -> Arguments.of(pair, capacity))) + .toArray(Arguments[]::new); + } + + @Test + void testSubscriberForCompleteConsumption() { + + // Create the subscriber (with sufficient capacity) + ObserverSubscriber downstreamSubscriber = new ObserverSubscriber(); + int sufficientCapacity = RESPONSE_BODY.length; + BodySubscriber subscriber = BodySubscribers.limiting(downstreamSubscriber, sufficientCapacity); + + // Emit values + subscriber.onSubscribe(DummySubscription.INSTANCE); + byte[] responseBodyPart1 = {RESPONSE_BODY[0]}; + byte[] responseBodyPart2 = copyOfRange(RESPONSE_BODY, 1, RESPONSE_BODY.length); + List buffers = toByteBuffers(responseBodyPart1, responseBodyPart2); + subscriber.onNext(buffers); + + // Verify the downstream propagation + assertSame(buffers, downstreamSubscriber.lastBuffers); + assertNull(downstreamSubscriber.lastThrowable); + assertFalse(downstreamSubscriber.completed); + + } + + @Test + void testSubscriberForFailureOnExcess() { + + // Create the subscriber (with insufficient capacity) + ObserverSubscriber downstreamSubscriber = new ObserverSubscriber(); + int insufficientCapacity = 2; + BodySubscriber subscriber = BodySubscribers.limiting(downstreamSubscriber, insufficientCapacity); + + // Emit values + subscriber.onSubscribe(DummySubscription.INSTANCE); + byte[] responseBodyPart1 = {RESPONSE_BODY[0]}; + byte[] responseBodyPart2 = copyOfRange(RESPONSE_BODY, 1, RESPONSE_BODY.length); + List buffers = toByteBuffers(responseBodyPart1, responseBodyPart2); + subscriber.onNext(buffers); + + // Verify the downstream propagation + assertNull(downstreamSubscriber.lastBuffers); + assertNotNull(downstreamSubscriber.lastThrowable); + assertEquals( + "body exceeds capacity: " + insufficientCapacity, + downstreamSubscriber.lastThrowable.getMessage()); + assertFalse(downstreamSubscriber.completed); + + } + + private static List toByteBuffers(byte[]... buffers) { + return Arrays.stream(buffers).map(ByteBuffer::wrap).collect(Collectors.toList()); + } + + private static final class ObserverSubscriber implements BodySubscriber { + + private List lastBuffers; + + private Throwable lastThrowable; + + private boolean completed; + + @Override + public CompletionStage getBody() { + throw new UnsupportedOperationException(); + } + + @Override + public void onSubscribe(Subscription subscription) { + subscription.request(Long.MAX_VALUE); + } + + @Override + public void onNext(List buffers) { + lastBuffers = buffers; + } + + @Override + public void onError(Throwable throwable) { + lastThrowable = throwable; + } + + @Override + public void onComplete() { + completed = true; + } + + } + + private enum DummySubscription implements Subscription { + + INSTANCE; + + @Override + public void request(long n) { + // Do nothing + } + + @Override + public void cancel() { + // Do nothing + } + + } + +} From a4942a2f7a2afdea5577eaae7cc4322ef1662fb9 Mon Sep 17 00:00:00 2001 From: Joachim Kern Date: Tue, 28 Jan 2025 10:25:36 +0000 Subject: [PATCH 258/263] 8348286: [AIX] clang 17 introduces new warning Wtentative-Definitions which produces Build errors Reviewed-by: ihse, azvegint --- .../native/libawt/awt/image/imageInitIDs.c | 74 ++++++++++- .../native/libawt/awt/image/imageInitIDs.h | 120 +++++++++--------- .../unix/native/libawt_xawt/awt/fp_pipewire.h | 90 ------------- .../libawt_xawt/awt/screencast_pipewire.c | 58 ++++++++- 4 files changed, 187 insertions(+), 155 deletions(-) delete mode 100644 src/java.desktop/unix/native/libawt_xawt/awt/fp_pipewire.h diff --git a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.c b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.c index 81bac6a414f19..75b585e3496c0 100644 --- a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.c +++ b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.c @@ -24,8 +24,78 @@ */ #include #include "jni_util.h" -#define IMGEXTERN -#include "imageInitIDs.h" + +/* BufferedImage ids */ +jfieldID g_BImgRasterID; +jfieldID g_BImgTypeID; +jfieldID g_BImgCMID; +jmethodID g_BImgGetRGBMID; +jmethodID g_BImgSetRGBMID; + +/* Raster ids */ +jfieldID g_RasterWidthID; +jfieldID g_RasterHeightID; +jfieldID g_RasterMinXID; +jfieldID g_RasterMinYID; +jfieldID g_RasterBaseOriginXID; +jfieldID g_RasterBaseOriginYID; +jfieldID g_RasterSampleModelID; +jfieldID g_RasterDataBufferID; +jfieldID g_RasterNumDataElementsID; +jfieldID g_RasterNumBandsID; + +jfieldID g_BCRdataID; +jfieldID g_BCRscanstrID; +jfieldID g_BCRpixstrID; +jfieldID g_BCRdataOffsetsID; +jfieldID g_BCRtypeID; +jfieldID g_BPRdataID; +jfieldID g_BPRscanstrID; +jfieldID g_BPRpixstrID; +jfieldID g_BPRtypeID; +jfieldID g_BPRdataBitOffsetID; +jfieldID g_SCRdataID; +jfieldID g_SCRscanstrID; +jfieldID g_SCRpixstrID; +jfieldID g_SCRdataOffsetsID; +jfieldID g_SCRtypeID; +jfieldID g_ICRdataID; +jfieldID g_ICRscanstrID; +jfieldID g_ICRpixstrID; +jfieldID g_ICRdataOffsetsID; +jfieldID g_ICRtypeID; + +/* Color Model ids */ +jfieldID g_CMnBitsID; +jfieldID g_CMcspaceID; +jfieldID g_CMnumComponentsID; +jfieldID g_CMsuppAlphaID; +jfieldID g_CMisAlphaPreID; +jfieldID g_CMtransparencyID; +jfieldID g_CMcsTypeID; +jfieldID g_CMis_sRGBID; +jmethodID g_CMgetRGBdefaultMID; + +jfieldID g_ICMtransIdxID; +jfieldID g_ICMmapSizeID; +jfieldID g_ICMrgbID; + +/* Sample Model ids */ +jfieldID g_SMWidthID; +jfieldID g_SMHeightID; +jmethodID g_SMGetPixelsMID; +jmethodID g_SMSetPixelsMID; + +/* Single Pixel Packed Sample Model ids */ +jfieldID g_SPPSMmaskArrID; +jfieldID g_SPPSMmaskOffID; +jfieldID g_SPPSMnBitsID; +jfieldID g_SPPSMmaxBitID; + +/* Kernel ids */ +jfieldID g_KernelWidthID; +jfieldID g_KernelHeightID; +jfieldID g_KernelDataID; JNIEXPORT void JNICALL Java_java_awt_image_BufferedImage_initIDs(JNIEnv *env, jclass cls) { diff --git a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h index c1c7a61680aca..b042c091b3a5d 100644 --- a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h +++ b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h @@ -28,80 +28,76 @@ #include "jni.h" -#ifndef IMGEXTERN -# define IMGEXTERN extern -#endif - /* BufferedImage ids */ -IMGEXTERN jfieldID g_BImgRasterID; -IMGEXTERN jfieldID g_BImgTypeID; -IMGEXTERN jfieldID g_BImgCMID; -IMGEXTERN jmethodID g_BImgGetRGBMID; -IMGEXTERN jmethodID g_BImgSetRGBMID; +extern jfieldID g_BImgRasterID; +extern jfieldID g_BImgTypeID; +extern jfieldID g_BImgCMID; +extern jmethodID g_BImgGetRGBMID; +extern jmethodID g_BImgSetRGBMID; /* Raster ids */ -IMGEXTERN jfieldID g_RasterWidthID; -IMGEXTERN jfieldID g_RasterHeightID; -IMGEXTERN jfieldID g_RasterMinXID; -IMGEXTERN jfieldID g_RasterMinYID; -IMGEXTERN jfieldID g_RasterBaseOriginXID; -IMGEXTERN jfieldID g_RasterBaseOriginYID; -IMGEXTERN jfieldID g_RasterSampleModelID; -IMGEXTERN jfieldID g_RasterDataBufferID; -IMGEXTERN jfieldID g_RasterNumDataElementsID; -IMGEXTERN jfieldID g_RasterNumBandsID; +extern jfieldID g_RasterWidthID; +extern jfieldID g_RasterHeightID; +extern jfieldID g_RasterMinXID; +extern jfieldID g_RasterMinYID; +extern jfieldID g_RasterBaseOriginXID; +extern jfieldID g_RasterBaseOriginYID; +extern jfieldID g_RasterSampleModelID; +extern jfieldID g_RasterDataBufferID; +extern jfieldID g_RasterNumDataElementsID; +extern jfieldID g_RasterNumBandsID; -IMGEXTERN jfieldID g_BCRdataID; -IMGEXTERN jfieldID g_BCRscanstrID; -IMGEXTERN jfieldID g_BCRpixstrID; -IMGEXTERN jfieldID g_BCRdataOffsetsID; -IMGEXTERN jfieldID g_BCRtypeID; -IMGEXTERN jfieldID g_BPRdataID; -IMGEXTERN jfieldID g_BPRscanstrID; -IMGEXTERN jfieldID g_BPRpixstrID; -IMGEXTERN jfieldID g_BPRtypeID; -IMGEXTERN jfieldID g_BPRdataBitOffsetID; -IMGEXTERN jfieldID g_SCRdataID; -IMGEXTERN jfieldID g_SCRscanstrID; -IMGEXTERN jfieldID g_SCRpixstrID; -IMGEXTERN jfieldID g_SCRdataOffsetsID; -IMGEXTERN jfieldID g_SCRtypeID; -IMGEXTERN jfieldID g_ICRdataID; -IMGEXTERN jfieldID g_ICRscanstrID; -IMGEXTERN jfieldID g_ICRpixstrID; -IMGEXTERN jfieldID g_ICRdataOffsetsID; -IMGEXTERN jfieldID g_ICRtypeID; +extern jfieldID g_BCRdataID; +extern jfieldID g_BCRscanstrID; +extern jfieldID g_BCRpixstrID; +extern jfieldID g_BCRdataOffsetsID; +extern jfieldID g_BCRtypeID; +extern jfieldID g_BPRdataID; +extern jfieldID g_BPRscanstrID; +extern jfieldID g_BPRpixstrID; +extern jfieldID g_BPRtypeID; +extern jfieldID g_BPRdataBitOffsetID; +extern jfieldID g_SCRdataID; +extern jfieldID g_SCRscanstrID; +extern jfieldID g_SCRpixstrID; +extern jfieldID g_SCRdataOffsetsID; +extern jfieldID g_SCRtypeID; +extern jfieldID g_ICRdataID; +extern jfieldID g_ICRscanstrID; +extern jfieldID g_ICRpixstrID; +extern jfieldID g_ICRdataOffsetsID; +extern jfieldID g_ICRtypeID; /* Color Model ids */ -IMGEXTERN jfieldID g_CMnBitsID; -IMGEXTERN jfieldID g_CMcspaceID; -IMGEXTERN jfieldID g_CMnumComponentsID; -IMGEXTERN jfieldID g_CMsuppAlphaID; -IMGEXTERN jfieldID g_CMisAlphaPreID; -IMGEXTERN jfieldID g_CMtransparencyID; -IMGEXTERN jfieldID g_CMcsTypeID; -IMGEXTERN jfieldID g_CMis_sRGBID; -IMGEXTERN jmethodID g_CMgetRGBdefaultMID; +extern jfieldID g_CMnBitsID; +extern jfieldID g_CMcspaceID; +extern jfieldID g_CMnumComponentsID; +extern jfieldID g_CMsuppAlphaID; +extern jfieldID g_CMisAlphaPreID; +extern jfieldID g_CMtransparencyID; +extern jfieldID g_CMcsTypeID; +extern jfieldID g_CMis_sRGBID; +extern jmethodID g_CMgetRGBdefaultMID; -IMGEXTERN jfieldID g_ICMtransIdxID; -IMGEXTERN jfieldID g_ICMmapSizeID; -IMGEXTERN jfieldID g_ICMrgbID; +extern jfieldID g_ICMtransIdxID; +extern jfieldID g_ICMmapSizeID; +extern jfieldID g_ICMrgbID; /* Sample Model ids */ -IMGEXTERN jfieldID g_SMWidthID; -IMGEXTERN jfieldID g_SMHeightID; -IMGEXTERN jmethodID g_SMGetPixelsMID; -IMGEXTERN jmethodID g_SMSetPixelsMID; +extern jfieldID g_SMWidthID; +extern jfieldID g_SMHeightID; +extern jmethodID g_SMGetPixelsMID; +extern jmethodID g_SMSetPixelsMID; /* Single Pixel Packed Sample Model ids */ -IMGEXTERN jfieldID g_SPPSMmaskArrID; -IMGEXTERN jfieldID g_SPPSMmaskOffID; -IMGEXTERN jfieldID g_SPPSMnBitsID; -IMGEXTERN jfieldID g_SPPSMmaxBitID; +extern jfieldID g_SPPSMmaskArrID; +extern jfieldID g_SPPSMmaskOffID; +extern jfieldID g_SPPSMnBitsID; +extern jfieldID g_SPPSMmaxBitID; /* Kernel ids */ -IMGEXTERN jfieldID g_KernelWidthID; -IMGEXTERN jfieldID g_KernelHeightID; -IMGEXTERN jfieldID g_KernelDataID; +extern jfieldID g_KernelWidthID; +extern jfieldID g_KernelHeightID; +extern jfieldID g_KernelDataID; #endif /* IMAGEINITIDS_H */ diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/fp_pipewire.h b/src/java.desktop/unix/native/libawt_xawt/awt/fp_pipewire.h deleted file mode 100644 index d39f7c833b77b..0000000000000 --- a/src/java.desktop/unix/native/libawt_xawt/awt/fp_pipewire.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2023, 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. 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. - */ - -#ifdef HEADLESS -#error This file should not be included in headless library -#endif -#ifndef _FP_PIPEWIRE_H -#define _FP_PIPEWIRE_H - - -struct pw_buffer *(*fp_pw_stream_dequeue_buffer)(struct pw_stream *stream); -const char * (*fp_pw_stream_state_as_string)(enum pw_stream_state state); -int (*fp_pw_stream_queue_buffer)(struct pw_stream *stream, - struct pw_buffer *buffer); -int (*fp_pw_stream_set_active)(struct pw_stream *stream, bool active); - -int (*fp_pw_stream_connect)( - struct pw_stream *stream, - enum pw_direction direction, - uint32_t target_id, - enum pw_stream_flags flags, - const struct spa_pod **params, - uint32_t n_params); - -struct pw_stream *(*fp_pw_stream_new)( - struct pw_core *core, - const char *name, - struct pw_properties *props -); -void (*fp_pw_stream_add_listener)(struct pw_stream *stream, - struct spa_hook *listener, - const struct pw_stream_events *events, - void *data); -int (*fp_pw_stream_disconnect)(struct pw_stream *stream); -void (*fp_pw_stream_destroy)(struct pw_stream *stream); - - -void (*fp_pw_init)(int *argc, char **argv[]); - -struct pw_core * -(*fp_pw_context_connect_fd)(struct pw_context *context, - int fd, - struct pw_properties *properties, - size_t user_data_size); - -int (*fp_pw_core_disconnect)(struct pw_core *core); - -struct pw_context * (*fp_pw_context_new)(struct pw_loop *main_loop, - struct pw_properties *props, - size_t user_data_size); - -struct pw_thread_loop * -(*fp_pw_thread_loop_new)(const char *name, const struct spa_dict *props); -struct pw_loop * (*fp_pw_thread_loop_get_loop)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_signal)(struct pw_thread_loop *loop, - bool wait_for_accept); -void (*fp_pw_thread_loop_wait)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_accept)(struct pw_thread_loop *loop); -int (*fp_pw_thread_loop_start)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_stop)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_destroy)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_lock)(struct pw_thread_loop *loop); -void (*fp_pw_thread_loop_unlock)(struct pw_thread_loop *loop); - -struct pw_properties * (*fp_pw_properties_new)(const char *key, ...); - - -#endif //_FP_PIPEWIRE_H diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/screencast_pipewire.c b/src/java.desktop/unix/native/libawt_xawt/awt/screencast_pipewire.c index e81bd5410b3b7..09585964ac8b8 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/screencast_pipewire.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/screencast_pipewire.c @@ -31,7 +31,63 @@ #include "jni_util.h" #include "awt.h" #include "screencast_pipewire.h" -#include "fp_pipewire.h" + +struct pw_buffer *(*fp_pw_stream_dequeue_buffer)(struct pw_stream *stream); +const char * (*fp_pw_stream_state_as_string)(enum pw_stream_state state); +int (*fp_pw_stream_queue_buffer)(struct pw_stream *stream, + struct pw_buffer *buffer); +int (*fp_pw_stream_set_active)(struct pw_stream *stream, bool active); + +int (*fp_pw_stream_connect)( + struct pw_stream *stream, + enum pw_direction direction, + uint32_t target_id, + enum pw_stream_flags flags, + const struct spa_pod **params, + uint32_t n_params); + +struct pw_stream *(*fp_pw_stream_new)( + struct pw_core *core, + const char *name, + struct pw_properties *props +); +void (*fp_pw_stream_add_listener)(struct pw_stream *stream, + struct spa_hook *listener, + const struct pw_stream_events *events, + void *data); +int (*fp_pw_stream_disconnect)(struct pw_stream *stream); +void (*fp_pw_stream_destroy)(struct pw_stream *stream); + + +void (*fp_pw_init)(int *argc, char **argv[]); + +struct pw_core * +(*fp_pw_context_connect_fd)(struct pw_context *context, + int fd, + struct pw_properties *properties, + size_t user_data_size); + +int (*fp_pw_core_disconnect)(struct pw_core *core); + +struct pw_context * (*fp_pw_context_new)(struct pw_loop *main_loop, + struct pw_properties *props, + size_t user_data_size); + +struct pw_thread_loop * +(*fp_pw_thread_loop_new)(const char *name, const struct spa_dict *props); +struct pw_loop * (*fp_pw_thread_loop_get_loop)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_signal)(struct pw_thread_loop *loop, + bool wait_for_accept); +void (*fp_pw_thread_loop_wait)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_accept)(struct pw_thread_loop *loop); +int (*fp_pw_thread_loop_start)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_stop)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_destroy)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_lock)(struct pw_thread_loop *loop); +void (*fp_pw_thread_loop_unlock)(struct pw_thread_loop *loop); + +struct pw_properties * (*fp_pw_properties_new)(const char *key, ...); + #include #include "gtk_interface.h" From 3a8680e919fb2505ff0e05e6ea6ae39ef25c81b2 Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Tue, 28 Jan 2025 11:13:54 +0000 Subject: [PATCH 259/263] 8347058: When automatically translating the page to pt-br, all CSS styling disappears Reviewed-by: hannesw, liach --- .../internal/doclets/formats/html/markup/Head.java | 4 ++-- .../jdk/javadoc/internal/html/HtmlTree.java | 8 +++----- .../TestModuleSpecificStylesheet.java | 14 +++++++------- .../javadoc/doclet/testOptions/TestOptions.java | 14 +++++++------- .../TestPackageSpecificStylesheet.java | 10 +++++----- .../jdk/javadoc/doclet/testSearch/TestSearch.java | 6 +++--- .../doclet/testStylesheet/TestStylesheet.java | 8 ++++---- 7 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java index 9b6b1c831b179..7170c6bcc8a2e 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -347,7 +347,7 @@ private void addStylesheets(HtmlTree head) { private void addStylesheet(HtmlTree head, DocPath stylesheet) { head.add(HtmlTree.LINK("stylesheet", "text/css", - pathToRoot.resolve(stylesheet).getPath(), "Style")); + pathToRoot.resolve(stylesheet).getPath())); } private void addScripts(HtmlTree head) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java index 4c2477babf59f..d664239033544 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. * 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,15 +779,13 @@ public static HtmlTree LI(HtmlStyle style, Content body) { * @param rel the relevance of the link: the {@code rel} attribute * @param type the type of link: the {@code type} attribute * @param href the path for the link: the {@code href} attribute - * @param title title for the link: the {@code title} attribute * @return the element */ - public static HtmlTree LINK(String rel, String type, String href, String title) { + public static HtmlTree LINK(String rel, String type, String href) { return new HtmlTree(HtmlTag.LINK) .put(HtmlAttr.REL, rel) .put(HtmlAttr.TYPE, type) - .put(HtmlAttr.HREF, href) - .put(HtmlAttr.TITLE, title); + .put(HtmlAttr.HREF, href); } /** diff --git a/test/langtools/jdk/javadoc/doclet/testModuleSpecificStylesheet/TestModuleSpecificStylesheet.java b/test/langtools/jdk/javadoc/doclet/testModuleSpecificStylesheet/TestModuleSpecificStylesheet.java index 48b4750573b26..68deacb0e4756 100644 --- a/test/langtools/jdk/javadoc/doclet/testModuleSpecificStylesheet/TestModuleSpecificStylesheet.java +++ b/test/langtools/jdk/javadoc/doclet/testModuleSpecificStylesheet/TestModuleSpecificStylesheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 8219313 + * @bug 8219313 8347058 * @summary Support module specific stylesheets * @library /tools/lib ../../lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -82,22 +82,22 @@ public void test(Path base) throws Exception { checkOutput("ma/module-summary.html", true, """ - """); + """); checkOutput("ma/pa/package-summary.html", true, """ - """); + """); checkOutput("ma/pa/A.html", true, """ - """); + """); checkOutput("ma/pa/pb/B.html", true, """ - """); + """); checkOutput("ma/pa/pb/package-summary.html", true, """ - """); + """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java index 898a498ddeeae..e04135382114b 100644 --- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java +++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 4749567 8071982 8175200 8186332 8185371 8182765 8217034 8261976 8261976 - * 8275786 + * 8275786 8347058 * @summary Test the output for -header, -footer, -nooverview, -nodeprecatedlist, * -nonavbar, -notree, -stylesheetfile, --main-stylesheet, --add-stylesheet, * --add-script options. @@ -118,7 +118,7 @@ public void testStylesheetFile() { checkOutput("resource-files/custom-stylesheet.css", true, "Custom javadoc style sheet"); checkOutput("pkg/Foo.html", true, """ - """); + """); } @Test @@ -131,7 +131,7 @@ public void testStylesheetFileAltOption() { checkOutput("resource-files/custom-stylesheet.css", true, "Custom javadoc style sheet"); checkOutput("pkg/Foo.html", true, """ - """); + """); } @Test @@ -149,9 +149,9 @@ public void testAdditionalStylesheetFile() { checkOutput("resource-files/additional-stylesheet-3.css", true, "Additional javadoc style sheet 3"); checkOutput("pkg/Foo.html", true, """ - - - """); + + + """); } @Test diff --git a/test/langtools/jdk/javadoc/doclet/testPackageSpecificStylesheet/TestPackageSpecificStylesheet.java b/test/langtools/jdk/javadoc/doclet/testPackageSpecificStylesheet/TestPackageSpecificStylesheet.java index 9c6ddc5616d4a..284b79577591e 100644 --- a/test/langtools/jdk/javadoc/doclet/testPackageSpecificStylesheet/TestPackageSpecificStylesheet.java +++ b/test/langtools/jdk/javadoc/doclet/testPackageSpecificStylesheet/TestPackageSpecificStylesheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * 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 8213354 + * @bug 8213354 8347058 * @summary Support package-specific stylesheets * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -82,15 +82,15 @@ public void test(Path base) throws Exception { checkOutput("pkg/A.html", true, """ - """); + """); checkOutput("pkg/package-summary.html", true, """ - """); + """); checkOutput("pkg2/B.html", false, """ - """); + """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java index 292d82459829f..ba3f64cd8b29e 100644 --- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java +++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881 * 8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202 * 8184205 8214468 8222548 8223378 8234746 8241219 8254627 8247994 8263528 - * 8266808 8248863 8305710 8318082 + * 8266808 8248863 8305710 8318082 8347058 * @summary Test the search feature of javadoc. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -418,7 +418,7 @@ void checkSearchOutput(String fileName, boolean expectedOutput) { // Test for search related markup checkOutput(fileName, expectedOutput, """ - + """, """ diff --git a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java index 06663d2f4181d..a3dce5448f0f8 100644 --- a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java +++ b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * 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 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417 * 8175218 8176452 8181215 8182263 8183511 8169819 8183037 8185369 8182765 8196201 8184205 8223378 8241544 - * 8253117 8263528 8289334 8292594 + * 8253117 8263528 8289334 8292594 8347058 * @summary Run tests on doclet stylesheet. * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -186,7 +186,7 @@ public void test(Path base) { // Test whether a link to the stylesheet file is inserted properly // in the class documentation. """ - """, + """, """

    Test comment for a class which has an anchor_with_name and an anchor_with_id.
    """); @@ -200,7 +200,7 @@ public void test(Path base) { checkOutput("index.html", true, """ - """); + """); checkOutput("resource-files/stylesheet.css", false, """ From 2bef5b4a877f4d3bc766558b8782b7b57dee79a8 Mon Sep 17 00:00:00 2001 From: Dhamoder Nalla Date: Tue, 28 Jan 2025 11:32:00 +0000 Subject: [PATCH 260/263] 8348323: Corrupted timezone string in JVM crash log Reviewed-by: dholmes, amitkumar, kevinw --- src/hotspot/share/runtime/os.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 094d68e1a84b9..0654bd3e092d8 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -1212,8 +1212,7 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) { if (localtime_pd(&tloc, &tz) != nullptr) { wchar_t w_buf[80]; size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz); - if (n > 0) { - ::wcstombs(buf, w_buf, buflen); + if (n > 0 && ::wcstombs(buf, w_buf, buflen) != (size_t)-1) { st->print("Time: %s %s", timestring, buf); } else { st->print("Time: %s", timestring); From 5fec999474dd4e88299ca02fccce8332fa5766ec Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Tue, 28 Jan 2025 13:29:37 +0000 Subject: [PATCH 261/263] 8339668: Parallel: Adopt PartialArrayState to consolidate marking stack in Full GC Co-authored-by: Thomas Schatzl Reviewed-by: tschatzl, ayang --- .../share/gc/parallel/psCompactionManager.cpp | 99 ++++++++++++------- .../share/gc/parallel/psCompactionManager.hpp | 66 ++++++------- .../parallel/psCompactionManager.inline.hpp | 63 +++++------- .../share/gc/parallel/psParallelCompact.cpp | 16 ++- src/hotspot/share/gc/parallel/psScavenge.cpp | 2 +- src/hotspot/share/gc/shared/taskqueue.hpp | 10 +- 6 files changed, 137 insertions(+), 119 deletions(-) diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp index 0601c5047ebe3..f00e18c3297b9 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp @@ -28,6 +28,8 @@ #include "gc/parallel/psCompactionManager.inline.hpp" #include "gc/parallel/psOldGen.hpp" #include "gc/parallel/psParallelCompact.inline.hpp" +#include "gc/shared/partialArraySplitter.inline.hpp" +#include "gc/shared/partialArrayState.hpp" #include "gc/shared/preservedMarks.inline.hpp" #include "gc/shared/taskqueue.inline.hpp" #include "logging/log.hpp" @@ -42,9 +44,9 @@ PSOldGen* ParCompactionManager::_old_gen = nullptr; ParCompactionManager** ParCompactionManager::_manager_array = nullptr; -ParCompactionManager::OopTaskQueueSet* ParCompactionManager::_oop_task_queues = nullptr; -ParCompactionManager::ObjArrayTaskQueueSet* ParCompactionManager::_objarray_task_queues = nullptr; +ParCompactionManager::PSMarkTasksQueueSet* ParCompactionManager::_marking_stacks = nullptr; ParCompactionManager::RegionTaskQueueSet* ParCompactionManager::_region_task_queues = nullptr; +PartialArrayStateManager* ParCompactionManager::_partial_array_state_manager = nullptr; ObjectStartArray* ParCompactionManager::_start_array = nullptr; ParMarkBitMap* ParCompactionManager::_mark_bitmap = nullptr; @@ -54,8 +56,10 @@ Monitor* ParCompactionManager::_shadow_region_monitor = nullptr; PreservedMarksSet* ParCompactionManager::_preserved_marks_set = nullptr; ParCompactionManager::ParCompactionManager(PreservedMarks* preserved_marks, - ReferenceProcessor* ref_processor) - : _mark_and_push_closure(this, ref_processor) { + ReferenceProcessor* ref_processor, + uint parallel_gc_threads) + :_partial_array_splitter(_partial_array_state_manager, parallel_gc_threads), + _mark_and_push_closure(this, ref_processor) { ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); @@ -78,8 +82,10 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) { assert(_manager_array == nullptr, "Attempt to initialize twice"); _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads, mtGC); - _oop_task_queues = new OopTaskQueueSet(parallel_gc_threads); - _objarray_task_queues = new ObjArrayTaskQueueSet(parallel_gc_threads); + assert(_partial_array_state_manager == nullptr, "Attempt to initialize twice"); + _partial_array_state_manager + = new PartialArrayStateManager(parallel_gc_threads); + _marking_stacks = new PSMarkTasksQueueSet(parallel_gc_threads); _region_task_queues = new RegionTaskQueueSet(parallel_gc_threads); _preserved_marks_set = new PreservedMarksSet(true); @@ -88,16 +94,15 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) { // Create and register the ParCompactionManager(s) for the worker threads. for(uint i=0; iget(i), - PSParallelCompact::ref_processor()); - oop_task_queues()->register_queue(i, _manager_array[i]->oop_stack()); - _objarray_task_queues->register_queue(i, &_manager_array[i]->_objarray_stack); + PSParallelCompact::ref_processor(), + parallel_gc_threads); + marking_stacks()->register_queue(i, _manager_array[i]->marking_stack()); region_task_queues()->register_queue(i, _manager_array[i]->region_stack()); } _shadow_region_array = new (mtGC) GrowableArray(10, mtGC); _shadow_region_monitor = new Monitor(Mutex::nosafepoint, "CompactionManager_lock"); - } void ParCompactionManager::flush_all_string_dedup_requests() { @@ -114,42 +119,41 @@ ParCompactionManager::gc_thread_compaction_manager(uint index) { return _manager_array[index]; } -inline void ParCompactionManager::publish_and_drain_oop_tasks() { - oop obj; - while (oop_stack()->pop_overflow(obj)) { - if (!oop_stack()->try_push_to_taskqueue(obj)) { - follow_contents(obj); - } - } - while (oop_stack()->pop_local(obj)) { - follow_contents(obj); - } +void ParCompactionManager::push_objArray(oop obj) { + assert(obj->is_objArray(), "precondition"); + _mark_and_push_closure.do_klass(obj->klass()); + + objArrayOop obj_array = objArrayOop(obj); + size_t array_length = obj_array->length(); + size_t initial_chunk_size = + _partial_array_splitter.start(&_marking_stack, obj_array, nullptr, array_length); + follow_array(obj_array, 0, initial_chunk_size); } -bool ParCompactionManager::publish_or_pop_objarray_tasks(ObjArrayTask& task) { - while (_objarray_stack.pop_overflow(task)) { - if (!_objarray_stack.try_push_to_taskqueue(task)) { - return true; - } - } - return false; +void ParCompactionManager::process_array_chunk(PartialArrayState* state, bool stolen) { + // Access before release by claim(). + oop obj = state->source(); + PartialArraySplitter::Claim claim = + _partial_array_splitter.claim(state, &_marking_stack, stolen); + follow_array(objArrayOop(obj), claim._start, claim._end); } void ParCompactionManager::follow_marking_stacks() { + ScannerTask task; do { // First, try to move tasks from the overflow stack into the shared buffer, so // that other threads can steal. Otherwise process the overflow stack first. - publish_and_drain_oop_tasks(); - - // Process ObjArrays one at a time to avoid marking stack bloat. - ObjArrayTask task; - if (publish_or_pop_objarray_tasks(task) || - _objarray_stack.pop_local(task)) { - follow_array((objArrayOop)task.obj(), task.index()); + while (marking_stack()->pop_overflow(task)) { + if (!marking_stack()->try_push_to_taskqueue(task)) { + follow_contents(task, false); + } + } + while (marking_stack()->pop_local(task)) { + follow_contents(task, false); } - } while (!marking_stacks_empty()); + } while (!marking_stack_empty()); - assert(marking_stacks_empty(), "Sanity"); + assert(marking_stack_empty(), "Sanity"); } void ParCompactionManager::drain_region_stacks() { @@ -196,11 +200,32 @@ void ParCompactionManager::remove_all_shadow_regions() { _shadow_region_array->clear(); } + +#if TASKQUEUE_STATS +void ParCompactionManager::print_and_reset_taskqueue_stats() { + marking_stacks()->print_and_reset_taskqueue_stats("Marking Stacks"); + + auto get_pa_stats = [&](uint i) { + return _manager_array[i]->partial_array_task_stats(); + }; + PartialArrayTaskStats::log_set(ParallelGCThreads, get_pa_stats, + "Partial Array Task Stats"); + uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().max_workers(); + for (uint i = 0; i < parallel_gc_threads; ++i) { + get_pa_stats(i)->reset(); + } +} + +PartialArrayTaskStats* ParCompactionManager::partial_array_task_stats() { + return _partial_array_splitter.stats(); +} +#endif // TASKQUEUE_STATS + #ifdef ASSERT void ParCompactionManager::verify_all_marking_stack_empty() { uint parallel_gc_threads = ParallelGCThreads; for (uint i = 0; i < parallel_gc_threads; i++) { - assert(_manager_array[i]->marking_stacks_empty(), "Marking stack should be empty"); + assert(_manager_array[i]->marking_stack_empty(), "Marking stack should be empty"); } } diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.hpp index cd4eefe775b57..739d2cb1cc7e2 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp @@ -27,6 +27,9 @@ #include "classfile/classLoaderData.hpp" #include "gc/parallel/psParallelCompact.hpp" +#include "gc/shared/partialArraySplitter.hpp" +#include "gc/shared/partialArrayTaskStats.hpp" +#include "gc/shared/partialArrayState.hpp" #include "gc/shared/preservedMarks.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/taskqueue.hpp" @@ -64,26 +67,22 @@ class ParCompactionManager : public CHeapObj { friend class PCAddThreadRootsMarkingTaskClosure; private: - typedef OverflowTaskQueue OopTaskQueue; - typedef GenericTaskQueueSet OopTaskQueueSet; - - // 32-bit: 4K * 8 = 32KiB; 64-bit: 8K * 16 = 128KiB - #define QUEUE_SIZE (1 << NOT_LP64(12) LP64_ONLY(13)) - typedef OverflowTaskQueue ObjArrayTaskQueue; - typedef GenericTaskQueueSet ObjArrayTaskQueueSet; - #undef QUEUE_SIZE - typedef OverflowTaskQueue RegionTaskQueue; - typedef GenericTaskQueueSet RegionTaskQueueSet; + typedef OverflowTaskQueue PSMarkTaskQueue; + typedef GenericTaskQueueSet PSMarkTasksQueueSet; + typedef OverflowTaskQueue RegionTaskQueue; + typedef GenericTaskQueueSet RegionTaskQueueSet; static ParCompactionManager** _manager_array; - static OopTaskQueueSet* _oop_task_queues; - static ObjArrayTaskQueueSet* _objarray_task_queues; + static PSMarkTasksQueueSet* _marking_stacks; static ObjectStartArray* _start_array; static RegionTaskQueueSet* _region_task_queues; static PSOldGen* _old_gen; - OopTaskQueue _oop_stack; - ObjArrayTaskQueue _objarray_stack; + static PartialArrayStateManager* _partial_array_state_manager; + PartialArraySplitter _partial_array_splitter; + + PSMarkTaskQueue _marking_stack; + size_t _next_shadow_region; PCMarkAndPushClosure _mark_and_push_closure; @@ -109,23 +108,20 @@ class ParCompactionManager : public CHeapObj { static PSOldGen* old_gen() { return _old_gen; } static ObjectStartArray* start_array() { return _start_array; } - static OopTaskQueueSet* oop_task_queues() { return _oop_task_queues; } + static PSMarkTasksQueueSet* marking_stacks() { return _marking_stacks; } static void initialize(ParMarkBitMap* mbm); - void publish_and_drain_oop_tasks(); - // Try to publish all contents from the objArray task queue overflow stack to - // the shared objArray stack. - // Returns true and a valid task if there has not been enough space in the shared - // objArray stack, otherwise returns false and the task is invalid. - bool publish_or_pop_objarray_tasks(ObjArrayTask& task); - ParCompactionManager(PreservedMarks* preserved_marks, - ReferenceProcessor* ref_processor); + ReferenceProcessor* ref_processor, + uint parallel_gc_threads); // Array of task queues. Needed by the task terminator. static RegionTaskQueueSet* region_task_queues() { return _region_task_queues; } - OopTaskQueue* oop_stack() { return &_oop_stack; } + + inline PSMarkTaskQueue* marking_stack() { return &_marking_stack; } + inline void push(PartialArrayState* stat); + void push_objArray(oop obj); // To collect per-region live-words in a worker local cache in order to // reduce threads contention. @@ -155,6 +151,11 @@ class ParCompactionManager : public CHeapObj { MarkingStatsCache* _marking_stats_cache; +#if TASKQUEUE_STATS + static void print_and_reset_taskqueue_stats(); + PartialArrayTaskStats* partial_array_task_stats(); +#endif // TASKQUEUE_STATS + public: static const size_t InvalidShadow = ~0; static size_t pop_shadow_region_mt_safe(PSParallelCompact::RegionData* region_ptr); @@ -189,7 +190,6 @@ class ParCompactionManager : public CHeapObj { // Save for later processing. Must not fail. inline void push(oop obj); - inline void push_objarray(oop objarray, size_t index); inline void push_region(size_t index); // Check mark and maybe push on marking stack. @@ -198,19 +198,19 @@ class ParCompactionManager : public CHeapObj { // Access function for compaction managers static ParCompactionManager* gc_thread_compaction_manager(uint index); - static bool steal(int queue_num, oop& t); - static bool steal_objarray(int queue_num, ObjArrayTask& t); + static bool steal(int queue_num, ScannerTask& t); static bool steal(int queue_num, size_t& region); - // Process tasks remaining on any marking stack + // Process tasks remaining on marking stack void follow_marking_stacks(); - inline bool marking_stacks_empty() const; + inline bool marking_stack_empty() const; // Process tasks remaining on any stack void drain_region_stacks(); - void follow_contents(oop obj); - void follow_array(objArrayOop array, int index); + inline void follow_contents(const ScannerTask& task, bool stolen); + inline void follow_array(objArrayOop array, size_t start, size_t end); + void process_array_chunk(PartialArrayState* state, bool stolen); class FollowStackClosure: public VoidClosure { private: @@ -234,8 +234,8 @@ class ParCompactionManager : public CHeapObj { static void verify_all_region_stack_empty() NOT_DEBUG_RETURN; }; -bool ParCompactionManager::marking_stacks_empty() const { - return _oop_stack.is_empty() && _objarray_stack.is_empty(); +bool ParCompactionManager::marking_stack_empty() const { + return _marking_stack.is_empty(); } #endif // SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_HPP diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp index 94529d2742305..2c0b8480726ab 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp @@ -32,6 +32,8 @@ #include "gc/parallel/parMarkBitMap.hpp" #include "gc/parallel/psParallelCompact.inline.hpp" #include "gc/parallel/psStringDedup.hpp" +#include "gc/shared/partialArrayState.hpp" +#include "gc/shared/partialArrayTaskStepper.inline.hpp" #include "gc/shared/taskqueue.inline.hpp" #include "oops/access.inline.hpp" #include "oops/arrayOop.hpp" @@ -46,12 +48,8 @@ inline void PCMarkAndPushClosure::do_oop_work(T* p) { _compaction_manager->mark_and_push(p); } -inline bool ParCompactionManager::steal(int queue_num, oop& t) { - return oop_task_queues()->steal(queue_num, t); -} - -inline bool ParCompactionManager::steal_objarray(int queue_num, ObjArrayTask& t) { - return _objarray_task_queues->steal(queue_num, t); +inline bool ParCompactionManager::steal(int queue_num, ScannerTask& t) { + return marking_stacks()->steal(queue_num, t); } inline bool ParCompactionManager::steal(int queue_num, size_t& region) { @@ -59,14 +57,11 @@ inline bool ParCompactionManager::steal(int queue_num, size_t& region) { } inline void ParCompactionManager::push(oop obj) { - _oop_stack.push(obj); + marking_stack()->push(ScannerTask(obj)); } -void ParCompactionManager::push_objarray(oop obj, size_t index) -{ - ObjArrayTask task(obj, index); - assert(task.is_valid(), "bad ObjArrayTask"); - _objarray_stack.push(task); +inline void ParCompactionManager::push(PartialArrayState* stat) { + marking_stack()->push(ScannerTask(stat)); } void ParCompactionManager::push_region(size_t index) @@ -111,43 +106,38 @@ inline void ParCompactionManager::FollowStackClosure::do_void() { } template -inline void follow_array_specialized(objArrayOop obj, int index, ParCompactionManager* cm) { - const size_t len = size_t(obj->length()); - const size_t beg_index = size_t(index); - assert(beg_index < len || len == 0, "index too large"); - - const size_t stride = MIN2(len - beg_index, (size_t)ObjArrayMarkingStride); - const size_t end_index = beg_index + stride; +inline void follow_array_specialized(objArrayOop obj, size_t start, size_t end, ParCompactionManager* cm) { + assert(start <= end, "invariant"); T* const base = (T*)obj->base(); - T* const beg = base + beg_index; - T* const end = base + end_index; - - if (end_index < len) { - cm->push_objarray(obj, end_index); // Push the continuation. - } + T* const beg = base + start; + T* const chunk_end = base + end; // Push the non-null elements of the next stride on the marking stack. - for (T* e = beg; e < end; e++) { + for (T* e = beg; e < chunk_end; e++) { cm->mark_and_push(e); } } -inline void ParCompactionManager::follow_array(objArrayOop obj, int index) { +inline void ParCompactionManager::follow_array(objArrayOop obj, size_t start, size_t end) { if (UseCompressedOops) { - follow_array_specialized(obj, index, this); + follow_array_specialized(obj, start, end, this); } else { - follow_array_specialized(obj, index, this); + follow_array_specialized(obj, start, end, this); } } -inline void ParCompactionManager::follow_contents(oop obj) { - assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked"); - - if (obj->is_objArray()) { - _mark_and_push_closure.do_klass(obj->klass()); - follow_array(objArrayOop(obj), 0); +inline void ParCompactionManager::follow_contents(const ScannerTask& task, bool stolen) { + if (task.is_partial_array_state()) { + assert(PSParallelCompact::mark_bitmap()->is_marked(task.to_partial_array_state()->source()), "should be marked"); + process_array_chunk(task.to_partial_array_state(), stolen); } else { - obj->oop_iterate(&_mark_and_push_closure); + oop obj = task.to_oop(); + assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked"); + if (obj->is_objArray()) { + push_objArray(obj); + } else { + obj->oop_iterate(&_mark_and_push_closure); + } } } @@ -219,5 +209,4 @@ inline void ParCompactionManager::flush_and_destroy_marking_stats_cache() { delete _marking_stats_cache; _marking_stats_cache = nullptr; } - #endif // SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index d2342dfd897c4..90f4d6367bd5e 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -1214,12 +1214,9 @@ void steal_marking_work(TaskTerminator& terminator, uint worker_id) { ParCompactionManager::gc_thread_compaction_manager(worker_id); do { - oop obj = nullptr; - ObjArrayTask task; - if (ParCompactionManager::steal_objarray(worker_id, task)) { - cm->follow_array((objArrayOop)task.obj(), task.index()); - } else if (ParCompactionManager::steal(worker_id, obj)) { - cm->follow_contents(obj); + ScannerTask task; + if (ParCompactionManager::steal(worker_id, task)) { + cm->follow_contents(task, true); } cm->follow_marking_stacks(); } while (!terminator.offer_termination()); @@ -1235,7 +1232,7 @@ class MarkFromRootsTask : public WorkerTask { MarkFromRootsTask(uint active_workers) : WorkerTask("MarkFromRootsTask"), _strong_roots_scope(active_workers), - _terminator(active_workers, ParCompactionManager::oop_task_queues()), + _terminator(active_workers, ParCompactionManager::marking_stacks()), _active_workers(active_workers) {} virtual void work(uint worker_id) { @@ -1273,7 +1270,7 @@ class ParallelCompactRefProcProxyTask : public RefProcProxyTask { public: ParallelCompactRefProcProxyTask(uint max_workers) : RefProcProxyTask("ParallelCompactRefProcProxyTask", max_workers), - _terminator(_max_workers, ParCompactionManager::oop_task_queues()) {} + _terminator(_max_workers, ParCompactionManager::marking_stacks()) {} void work(uint worker_id) override { assert(worker_id < _max_workers, "sanity"); @@ -1383,8 +1380,7 @@ void PSParallelCompact::marking_phase(ParallelOldTracer *gc_tracer) { _gc_tracer.report_object_count_after_gc(is_alive_closure(), &ParallelScavengeHeap::heap()->workers()); } #if TASKQUEUE_STATS - ParCompactionManager::oop_task_queues()->print_and_reset_taskqueue_stats("Oop Queue"); - ParCompactionManager::_objarray_task_queues->print_and_reset_taskqueue_stats("ObjArrayOop Queue"); + ParCompactionManager::print_and_reset_taskqueue_stats(); #endif } diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index 7434097da21cd..be31da5b05d3c 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -204,7 +204,7 @@ class ParallelScavengeRefProcProxyTask : public RefProcProxyTask { public: ParallelScavengeRefProcProxyTask(uint max_workers) : RefProcProxyTask("ParallelScavengeRefProcProxyTask", max_workers), - _terminator(max_workers, ParCompactionManager::oop_task_queues()) {} + _terminator(max_workers, ParCompactionManager::marking_stacks()) {} void work(uint worker_id) override { assert(worker_id < _max_workers, "sanity"); diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp index a6ab5741048fe..42d32f3dc96b9 100644 --- a/src/hotspot/share/gc/shared/taskqueue.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.hpp @@ -561,8 +561,10 @@ class ObjArrayTask class PartialArrayState; -// Discriminated union over oop*, narrowOop*, and PartialArrayState. +// Discriminated union over oop/oop*, narrowOop*, and PartialArrayState. // Uses a low tag in the associated pointer to identify the category. +// Oop/oop* are overloaded using the same tag because they can not appear at the +// same time. // Used as a task queue element type. class ScannerTask { void* _p; @@ -595,6 +597,8 @@ class ScannerTask { public: ScannerTask() : _p(nullptr) {} + explicit ScannerTask(oop p) : _p(encode(p, OopTag)) {} + explicit ScannerTask(oop* p) : _p(encode(p, OopTag)) {} explicit ScannerTask(narrowOop* p) : _p(encode(p, NarrowOopTag)) {} @@ -622,6 +626,10 @@ class ScannerTask { return static_cast(decode(OopTag)); } + oop to_oop() const { + return cast_to_oop(decode(OopTag)); + } + narrowOop* to_narrow_oop_ptr() const { return static_cast(decode(NarrowOopTag)); } From fb066caea8a6bbf5b7a6fbe1ca51282e2c7c1ff2 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Tue, 28 Jan 2025 13:51:04 +0000 Subject: [PATCH 262/263] 8347272: [ubsan] JvmLauncher.cpp:262:52: runtime error: applying non-zero offset 40 to null pointer Reviewed-by: almatvee, mbaesken --- src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp b/src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp index 5997b80fa5f69..83f45c2cdfe29 100644 --- a/src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp +++ b/src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,7 +259,8 @@ struct JliLaunchData { int initJvmlLauncherData(JvmlLauncherData* ptr) const { // Store path to JLI library just behind JvmlLauncherData header. - char* curPtr = reinterpret_cast(ptr + 1); + JvmlLauncherData dummy; + char* curPtr = reinterpret_cast((ptr ? ptr : &dummy) + 1); { const size_t count = sizeof(char) * (jliLibPath.size() + 1 /* trailing zero */); @@ -304,7 +305,7 @@ struct JliLaunchData { curPtr = copyStrings(envVarValues, ptr, offsetof(JvmlLauncherData, envVarValues), curPtr); - const size_t bufferSize = curPtr - reinterpret_cast(ptr); + const size_t bufferSize = curPtr - reinterpret_cast(ptr ? ptr : &dummy); if (ptr) { LOG_TRACE(tstrings::any() << "Initialized " << bufferSize << " bytes at " << ptr << " address"); From 81032560f797dc18bd6a4a75b44c26925aabac5b Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Tue, 28 Jan 2025 16:42:13 +0000 Subject: [PATCH 263/263] 8348348: Remove unnecessary #ifdef STATIC_BUILD around DEF_STATIC_JNI_OnLoad from zip_util.c Reviewed-by: sgehwolf --- src/java.base/share/native/libzip/zip_util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/java.base/share/native/libzip/zip_util.c b/src/java.base/share/native/libzip/zip_util.c index 8f2f19c66a2ec..c327d3376597d 100644 --- a/src/java.base/share/native/libzip/zip_util.c +++ b/src/java.base/share/native/libzip/zip_util.c @@ -72,11 +72,9 @@ static void freeCEN(jzfile *); static jint INITIAL_META_COUNT = 2; /* initial number of entries in meta name array */ /* - * Declare library specific JNI_Onload entry if static build + * Declare library specific JNI_Onload entry */ -#ifdef STATIC_BUILD DEF_STATIC_JNI_OnLoad -#endif /* * The ZFILE_* functions exist to provide some platform-independence with