diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c61d978feb3..970e97469be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -245,7 +245,7 @@ jobs: with: platform: macos-aarch64 runs-on: 'macos-14' - xcode-toolset-version: '14.3.1' + xcode-toolset-version: '15.4' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.macos-aarch64 == 'true' @@ -299,6 +299,7 @@ jobs: platform: macos-x64 bootjdk-platform: macos-x64 runs-on: macos-13 + xcode-toolset-version: '14.3.1' test-macos-aarch64: name: macos-aarch64 @@ -309,6 +310,7 @@ jobs: platform: macos-aarch64 bootjdk-platform: macos-aarch64 runs-on: macos-14 + xcode-toolset-version: '15.4' test-windows-x64: name: windows-x64 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8885866c12..3517fa53941 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,9 @@ on: runs-on: required: true type: string + xcode-toolset-version: + required: false + type: string env: # These are needed to make the MSYS2 bash work properly @@ -147,7 +150,7 @@ jobs: run: | # On macOS we need to install some dependencies for testing brew install make - sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-toolset-version }}.app/Contents/Developer # This will make GNU make available as 'make' and not only as 'gmake' echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH if: runner.os == 'macOS' diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 52fa413fa1f..490edb45318 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -2316,7 +2316,7 @@ struct JNINativeInterface_* jni_functions_check() { // make sure the last pointer in the checked table is not null, indicating // an addition to the JNINativeInterface_ structure without initializing // it in the checked table. - debug_only(int *lastPtr = (int *)((char *)&checked_jni_NativeInterface + \ + debug_only(intptr_t *lastPtr = (intptr_t *)((char *)&checked_jni_NativeInterface + \ sizeof(*unchecked_jni_NativeInterface) - sizeof(char *));) assert(*lastPtr != 0, "Mismatched JNINativeInterface tables, check for new entries"); diff --git a/src/java.base/share/classes/java/security/MessageDigestSpi.java b/src/java.base/share/classes/java/security/MessageDigestSpi.java index 17bd34e507c..c99abf79ecd 100644 --- a/src/java.base/share/classes/java/security/MessageDigestSpi.java +++ b/src/java.base/share/classes/java/security/MessageDigestSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -204,7 +204,15 @@ protected int engineDigest(byte[] buf, int offset, int len) */ public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) { - return super.clone(); + MessageDigestSpi o = (MessageDigestSpi)super.clone(); + if (o.tempArray != null) { + // New byte arrays are allocated when the ByteBuffer argument + // to engineUpdate is not backed by a byte array. + // Here, the newly allocated byte array must also be cloned + // to prevent threads from sharing the same memory. + o.tempArray = tempArray.clone(); + } + return o; } else { throw new CloneNotSupportedException(); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java index 86a8e1faa5e..d7a1bbc7833 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -292,7 +292,7 @@ private void testRun() for (int i = 0; ; i++) { - breakpointForCommunication(); + breakpointForCommunication(debuggeeName); int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/jdk/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java b/test/jdk/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java index b284a033316..f5c349ac9a5 100644 --- a/test/jdk/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java +++ b/test/jdk/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,90 +27,89 @@ @key printer @summary verify that child components can draw only inside their visible bounds - @author das@sparc.spb.su area=awt.print - @run main/manual=yesno ConstrainedPrintingTest + @library /test/lib + @library /javax/accessibility/manual + @build lib.ManualTestFrame + @build lib.TestResult + @build jtreg.SkippedException + @run main/manual ConstrainedPrintingTest */ -// Note there is no @ in front of test above. This is so that the -// harness will not mistake this file as a test file. It should -// only see the html file as a test file. (the harness runs all -// valid test files, so it would run this test twice if this file -// were valid as well as the html file.) -// Also, note the area= after Your Name in the author tag. Here, you -// should put which functional area the test falls in. See the -// AWT-core home page -> test areas and/or -> AWT team for a list of -// areas. -// There are several places where ManualYesNoTest appear. It is -// recommended that these be changed by a global search and replace, -// such as ESC-% in xemacs. - - - -/** - * ConstrainedPrintingTest.java - * - * summary: verify that child components can draw only inside their - * visible bounds - * - */ - -import java.applet.Applet; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -//Manual tests should run as applet tests if possible because they -// get their environments cleaned up, including AWT threads, any -// test created threads, and any system resources used by the test -// such as file descriptors. (This is normally not a problem as -// main tests usually run in a separate VM, however on some platforms -// such as the Mac, separate VMs are not possible and non-applet -// tests will cause problems). Also, you don't have to worry about -// synchronisation stuff in Applet tests the way you do in main -// tests... - - -public class ConstrainedPrintingTest implements ActionListener - { - //Declare things used in the test, like buttons and labels here - final Frame frame = new Frame("PrintTest"); - final Button button = new Button("Print"); - final Panel panel = new Panel(); - final Component testComponent = new Component() { - public void paint(Graphics g) { - ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.green); - } - public Dimension getPreferredSize() { - return new Dimension(100, 100); - } - }; - final Canvas testCanvas = new Canvas() { - public void paint(Graphics g) { - ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.red); - // The frame is sized so that only the upper part of - // the canvas is visible. We draw on the lower part, - // so that we can verify that the output is clipped - // by the parent container bounds. - Dimension panelSize = panel.getSize(); - Rectangle b = getBounds(); - g.setColor(Color.red); - g.setClip(null); - for (int i = panelSize.height - b.y; i < b.height; i+= 10) { - g.drawLine(0, i, b.width, i); +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.JobAttributes; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.PrintJob; +import java.awt.Rectangle; +import java.awt.print.PrinterJob; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.function.Consumer; +import java.util.function.Supplier; +import javax.swing.JEditorPane; +import jtreg.SkippedException; +import lib.ManualTestFrame; +import lib.TestResult; + +public class ConstrainedPrintingTest { + + public static void createTestUI() { + Frame frame = new Frame("PrintTest"); + Button button = new Button("Print"); + Panel panel = new Panel(); + Component testComponent = new Component() { + public void paint(Graphics g) { + ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.green); } - } - public Dimension getPreferredSize() { - return new Dimension(100, 100); - } - }; - - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - button.addActionListener(this); + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + }; + + Canvas testCanvas = new Canvas() { + public void paint(Graphics g) { + ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.red); + // The frame is sized so that only the upper part of + // the canvas is visible. We draw on the lower part, + // so that we can verify that the output is clipped + // by the parent container bounds. + Dimension panelSize = panel.getSize(); + Rectangle b = getBounds(); + g.setColor(Color.red); + g.setClip(null); + for (int i = panelSize.height - b.y; i < b.height; i+= 10) { + g.drawLine(0, i, b.width, i); + } + } + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + }; + + button.addActionListener((actionEvent) -> { + PageAttributes pa = new PageAttributes(); + pa.setPrinterResolution(36); + PrintJob pjob = frame.getToolkit().getPrintJob(frame, "NewTest", + new JobAttributes(), pa); + if (pjob != null) { + Graphics pg = pjob.getGraphics(); + if (pg != null) { + pg.translate(20, 20); + frame.printAll(pg); + pg.dispose(); + } + pjob.end(); + } + }); panel.setBackground(Color.white); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20)); @@ -123,63 +122,8 @@ public void init() frame.setSize(200, 250); frame.validate(); frame.setResizable(false); - - String[] instructions = - { - "1.Look at the frame titled \"PrintTest\". If you see green or", - " red lines on the white area below the \"Print\" button, the", - " test fails. Otherwise go to step 2.", - "2.Press \"Print\" button. The print dialog will appear. Select", - " a printer and proceed. Look at the output. If you see multiple", - " lines outside of the frame bounds or in the white area below", - " the image of the \"Print\" button, the test fails. Otherwise", - " the test passes." - }; - Sysout.createDialogWithInstructions( instructions ); - - }//End init() - - public void start () - { - //Get things going. Request focus, set size, et cetera - + frame.setLocationRelativeTo(null); frame.setVisible(true); - - //What would normally go into main() will probably go here. - //Use System.out.println for diagnostic messages that you want - // to read after the test is done. - //Use Sysout.println for messages you want the tester to read. - - }// start() - - //The rest of this class is the actions which perform the test... - - //Use Sysout.println to communicate with the user NOT System.out!! - //Sysout.println ("Something Happened!"); - - public void stop() { - frame.setVisible(false); - } - - public void destroy() { - frame.dispose(); - } - - public void actionPerformed(ActionEvent e) { - PageAttributes pa = new PageAttributes(); - pa.setPrinterResolution(36); - PrintJob pjob = frame.getToolkit().getPrintJob(frame, "NewTest", - new JobAttributes(), - pa); - if (pjob != null) { - Graphics pg = pjob.getGraphics(); - if (pg != null) { - pg.translate(20, 20); - frame.printAll(pg); - pg.dispose(); - } - pjob.end(); - } } public static void paintOutsideBounds(Component comp, @@ -204,153 +148,37 @@ public static void paintOutsideBounds(Component comp, } } - public static void main(String[] args) { - ConstrainedPrintingTest c = new ConstrainedPrintingTest(); - - c.init(); - c.start(); - } + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, IOException { - }// class ConstrainedPrintingTest - -/* Place other classes related to the test after this line */ - - - - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. - */ - -class Sysout - { - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.show(); - println( "Any messages for the tester will display here." ); - } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.show(); - println( "Any messages for the tester will display here." ); - } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - - }// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog - { - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("South", messageText); - - pack(); - - show(); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() + if (PrinterJob.lookupPrintServices().length == 0) { + throw new SkippedException("Printer not configured or available." + + " Test cannot continue."); + } - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); + String instruction = """ + 1.Look at the frame titled "PrintTest". If you see green or, + red lines on the white area below the "Print" button, the, + test fails. Otherwise go to step 2., + 2.Press "Print" button. The print dialog will appear. + Select, a printer and proceed. Look at the output. + If you see multiple, lines outside of the frame bounds + or in the white area below, the image of the "Print" + button, the test fails. Otherwise,the test passes. + """; + Consumer testInstProvider = e -> { + e.setContentType("text/plain"); + e.setText(instruction); + }; + + Supplier resultSupplier = ManualTestFrame.showUI( + "Tests ConstrainedPrintingTest", + "Wait until the Test UI is seen", testInstProvider); + EventQueue.invokeAndWait(ConstrainedPrintingTest::createTestUI); + + //this will block until user decision to pass or fail the test + TestResult testResult = resultSupplier.get(); + ManualTestFrame.handleResult(testResult,"ConstrainedPrintingTest"); } +} - }// TestDialog class diff --git a/test/jdk/java/security/MessageDigest/TestCloneable.java b/test/jdk/java/security/MessageDigest/TestCloneable.java index 915f0c0996e..3a4feb82ff6 100644 --- a/test/jdk/java/security/MessageDigest/TestCloneable.java +++ b/test/jdk/java/security/MessageDigest/TestCloneable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,16 @@ /* * @test - * @bug 8246077 + * @bug 8246077 8300416 * @summary Make sure that digest spi and the resulting digest impl are - * consistent in the impl of Cloneable interface + * consistent in the impl of Cloneable interface, and that clones do not + * share memory. * @run testng TestCloneable */ +import java.nio.ByteBuffer; import java.security.*; +import java.util.Arrays; +import java.util.Random; import java.util.Objects; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -53,7 +57,7 @@ public Object[][] testData() { @Test(dataProvider = "testData") public void test(String algo, String provName) throws NoSuchProviderException, NoSuchAlgorithmException, - CloneNotSupportedException { + CloneNotSupportedException, InterruptedException { System.out.print("Testing " + algo + " impl from " + provName); Provider p = Security.getProvider(provName); Provider.Service s = p.getService("MessageDigest", algo); @@ -71,6 +75,52 @@ public void test(String algo, String provName) System.out.println(": NOT Cloneable"); Assert.assertThrows(CNSE, ()->md.clone()); } + + System.out.print("Testing " + algo + " impl from " + provName); + final var d1 = MessageDigest.getInstance(algo, provName); + final var buffer = ByteBuffer.allocateDirect(1024); + final var r = new Random(1024); + + fillBuffer(r, buffer); + d1.update(buffer); // this statement triggers tempArray allocation + final var d2 = (MessageDigest) d1.clone(); + assert Arrays.equals(d1.digest(), d2.digest()); + + final var t1 = updateThread(d1); + final var t2 = updateThread(d2); + t1.join(); + t2.join(); + + System.out.println(": Shared data check"); + // Random is producing the same sequence of bytes for each thread, + // and thus each MessageDigest should be equal. When the memory is + // shared, they inevitably overwrite each other's tempArray and + // you get different results. + if (!Arrays.equals(d1.digest(), d2.digest())) { + throw new AssertionError("digests differ"); + } + System.out.println("Test Passed"); } + + private static void fillBuffer(final Random r, final ByteBuffer buffer) { + final byte[] bytes = new byte[buffer.capacity()]; + r.nextBytes(bytes); + buffer.clear(); + buffer.put(bytes); + buffer.flip(); + } + + public static Thread updateThread(final MessageDigest d) { + final var t = new Thread(() -> { + final var r = new Random(1024); + final ByteBuffer buffer = ByteBuffer.allocateDirect(1024); + for (int i = 0; i < 1024; i++) { + fillBuffer(r, buffer); + d.update(buffer); + } + }); + t.start(); + return t; + } } diff --git a/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java index 51fd2e045f4..aa74c631389 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestClassLoaderLeak.java @@ -55,11 +55,14 @@ public static void main(String[] args) throws Exception { r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); r.start(); TestClassLoader testClassLoader = new TestClassLoader(); - for (Class clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 20)) { + for (Class clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 200)) { // Allocate array to trigger sampling code path for interpreter / c1 - for (int i = 0; i < 20; i++) { + for (int i = 0; i < 200; i++) { Object classArray = Array.newInstance(clazz, 20); - Array.set(classArray, i, clazz.newInstance()); + // No need to fill whole array + for (int j = 0; j < 5; j++) { + Array.set(classArray, j, clazz.getConstructors()[0].newInstance()); + } classObjects.add(classArray); } } @@ -67,6 +70,7 @@ public static void main(String[] args) throws Exception { List events = Events.fromRecording(r); Events.hasEvents(events); for (RecordedEvent e : events) { + System.out.println(e); RecordedObject object = e.getValue("object"); RecordedClass rc = object.getValue("type"); if (rc.getName().contains("TestClass")) { diff --git a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java index 1e6259ef0d7..fc1b4883220 100644 --- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -88,8 +88,6 @@ public final void setup() throws Exception { args.addAll(getCustomVmArgs()); args.add(TEST_APP_NAME); testAppPb = ProcessTools.createTestJavaProcessBuilder(args); - - jcmd = new ManagementAgentJcmd(TEST_APP_NAME, false); } @BeforeMethod @@ -98,6 +96,7 @@ public final void startTestApp() throws Exception { TEST_APP_NAME, testAppPb, (Predicate)l->l.trim().equals("main enter") ); + jcmd = new ManagementAgentJcmd(testApp, false); } @AfterMethod diff --git a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java index 0781bc941fd..7135f6ea2db 100644 --- a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java +++ b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -47,11 +47,11 @@ final class ManagementAgentJcmd { private static final String CMD_STATUS = "ManagementAgent.status"; private static final String CMD_PRINTPERF = "PerfCounter.print"; - private final String id; + private final long pid; private final boolean verbose; - public ManagementAgentJcmd(String targetApp, boolean verbose) { - this.id = targetApp; + public ManagementAgentJcmd(Process targetApp, boolean verbose) { + this.pid = targetApp.pid(); this.verbose = verbose; } @@ -174,7 +174,7 @@ private String jcmd(String ... command) throws IOException, InterruptedException * @throws InterruptedException */ private String jcmd(Consumer c, String ... command) throws IOException, InterruptedException { - return jcmd(id, c, command); + return jcmd(Long.toString(pid), c, command); } /** diff --git a/test/jdk/sun/security/krb5/auto/Renew.java b/test/jdk/sun/security/krb5/auto/Renew.java index 9b3ac7db38b..30e5be285ab 100644 --- a/test/jdk/sun/security/krb5/auto/Renew.java +++ b/test/jdk/sun/security/krb5/auto/Renew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,10 @@ public static void main(String[] args) throws Exception { Date d1 = c.s().getPrivateCredentials(KerberosTicket.class).iterator().next().getAuthTime(); // 6s is longer than half of 10s - Thread.sleep(6000); + Date expiring = new Date(d1.getTime() + 6000); + while (new Date().before(expiring)) { + Thread.sleep(500); + } // The second login uses the cache c = Context.fromJAAS("second");