From 9f8de221d7f0186718411ab3f5217e3883237e84 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Fri, 21 Jun 2024 13:51:06 +0000 Subject: [PATCH] 8327793: Deprecate jstatd for removal Reviewed-by: alanb, cjplummer --- src/jdk.jstatd/share/classes/module-info.java | 3 ++- src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java | 4 +++- test/jdk/sun/tools/jstatd/JstatdTest.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jdk.jstatd/share/classes/module-info.java b/src/jdk.jstatd/share/classes/module-info.java index ade59da4248..e9a9521ac73 100644 --- a/src/jdk.jstatd/share/classes/module-info.java +++ b/src/jdk.jstatd/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, 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 @@ -32,6 +32,7 @@ * @moduleGraph * @since 9 */ +@Deprecated(since="24", forRemoval=true) module jdk.jstatd { requires java.rmi; requires jdk.internal.jvmstat; diff --git a/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java b/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java index 5dc7f1fa2fb..cfd1212a67a 100644 --- a/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java +++ b/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -80,6 +80,8 @@ public class Jstatd { int rmiPort = 0; int argc = 0; + System.err.println("WARNING: jstatd is deprecated and will be removed in a future release."); + for ( ; (argc < args.length) && (args[argc].startsWith("-")); argc++) { String arg = args[argc]; diff --git a/test/jdk/sun/tools/jstatd/JstatdTest.java b/test/jdk/sun/tools/jstatd/JstatdTest.java index b2ac3804f68..5041bc40d75 100644 --- a/test/jdk/sun/tools/jstatd/JstatdTest.java +++ b/test/jdk/sun/tools/jstatd/JstatdTest.java @@ -356,7 +356,7 @@ public final class JstatdTest { OutputAnalyzer output = jstatdThread.getOutput(); List stdout = output.asLinesWithoutVMWarnings(); output.reportDiagnosticSummary(); - assertEquals(stdout.size(), 1, "Output should contain one line"); + assertEquals(stdout.size(), 2, "Output should contain two lines"); // includes deprecation warning assertTrue(stdout.get(0).startsWith("jstatd started"), "List should start with 'jstatd started'"); assertNotEquals(output.getExitValue(), 0, "jstatd process exited with unexpected exit code");