JDK-8279007 : jstatd fails to start because SecurityManager is disabled
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 18
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-12-20
  • Updated: 2021-12-23
  • Resolved: 2021-12-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18 JDK 19
18 b29Fixed 19Fixed
Related Reports
Relates :  
Description
In JDK 18, attempting to run jstatd results in the following:

$ jstatd
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
	at java.base/java.lang.System.setSecurityManager(System.java:416)
	at jdk.jstatd/sun.tools.jstatd.Jstatd.main(Jstatd.java:136)

The workaround is to allow setting the security manager property on the command line to allow programmatic setting of the security manager:

$ jstatd -J-Djava.security.manager=allow

Alternatively, the security manager could be enabled directly on the command line:

$ jstatd -J-Djava.security.manager

Either works, though they give different warning messages.

The property should be set by the jstatd launcher instead of requiring the user to provide it.
Comments
Changeset: 73414391 Author: Kevin Walls <kevinw@openjdk.org> Date: 2021-12-22 11:36:53 +0000 URL: https://git.openjdk.java.net/jdk18/commit/734143918de540382b5a0754bb7be1500b6f3596
22-12-2021

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk18/pull/53 Date: 2021-12-21 13:00:26 +0000
21-12-2021

make/modules/jdk.jstatd/Launcher.gmk can be used to set the system property to allow.
21-12-2021

System.setProperty anywhere in jstat itself is not early enough to set java.security.manager=allow System.java's initPhase3() sets the allowSecurityManager value, and is called during hotspot VM startup in Threads::create_vm() ..so no application can get there earlier. Launching with -J-Djava.security.manager=allow does work as VM arguments are parsed earlier than the call to initPhase3(). Will need to set JAVA_ARGS in launcher makefile, simlar to JDK-8278967 for rmiregistry.
21-12-2021