Skip to content

Commit

Permalink
8299470: sun/jvm/hotspot/SALauncher.java handling of negative rmiport…
Browse files Browse the repository at this point in the history
… args

Backport-of: 2ccdefc81c0ea2ea5c4380bb045aa82ad1eb8205
  • Loading branch information
MBaesken committed Jan 18, 2023
1 parent 7d6adf2 commit b45eb50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -59,7 +59,8 @@ private void extractOptarg(String opt) {
}

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];
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -500,7 +500,8 @@ public static void main(String[] args) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -101,12 +101,18 @@ private static void testWithPid(final boolean useRmiPort, final boolean useRegis
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));
}
Expand Down

1 comment on commit b45eb50

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.