diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SAGetopt.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SAGetopt.java index d23a057f584..65648a6add8 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SAGetopt.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SAGetopt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -59,7 +59,8 @@ public class SAGetopt { } if (! _argv[_optind].isEmpty() && _argv[_optind].charAt(0) == '-') { - throw new SAGetoptException("Argument is expected for '" + opt + "'"); + throw new SAGetoptException("Successor argument without leading - is expected for '" + opt + + "' but we got '" + _argv[_optind] + "'"); } _optarg = _argv[_optind]; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java index b873eb1e55b..b884058a3a2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -500,7 +500,8 @@ public class SALauncher { func.accept(oldArgs); } } catch (SAGetoptException e) { - System.err.println(e.getMessage()); + System.err.println("SA agent option related exception occurred: " + e.getMessage()); + e.printStackTrace(); toolHelp(args[0]); // Exit with error status System.exit(1); diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java index 49f90f7f9fd..4ba76034276 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -101,12 +101,18 @@ public class SADebugDTest { int registryPort = REGISTRY_DEFAULT_PORT; if (useRegistryPort) { registryPort = Utils.findUnreservedFreePort(REGISTRY_DEFAULT_PORT); + if (registryPort == -1) { + throw new RuntimeException("Cannot find a registryPort, findUnreservedFreePort returns -1"); + } jhsdbLauncher.addToolArg("--registryport"); jhsdbLauncher.addToolArg(Integer.toString(registryPort)); } final int rmiPort = useRmiPort ? Utils.findUnreservedFreePort(REGISTRY_DEFAULT_PORT, registryPort) : -1; if (useRmiPort) { + if (rmiPort == -1) { + throw new RuntimeException("Cannot find an rmiPort, findUnreservedFreePort returns -1"); + } jhsdbLauncher.addToolArg("--rmiport"); jhsdbLauncher.addToolArg(Integer.toString(rmiPort)); }