Disallowing the dynamic loading of agents by default (revised)
Stephen Felts
stephen.felts at oracle.com
Tue Apr 11 04:31:10 UTC 2017
The description below leaves out the " ancestor of the current process".
Which way is it - do we need to start two processes or one to work around this?
-----Original Message-----
From: Alan Bateman
Sent: Monday, April 10, 2017 2:39 PM
To: jigsaw-dev at openjdk.java.net
Subject: Re: Disallowing the dynamic loading of agents by default (revised)
The Jigsaw EA builds [1] have been refreshed to include some of the pieces in this proposal, specifically:
- If an executable JAR contains a java agent then it will be started by `java -jar` when the main manifest has the `Launcher-Agent-Class` attribute. The entry point that is invoked is the `agentmain` method. In the HotSpot implementation then all Can-XXX attributes can be used. The Boot-Class-Path attribute can be used too, say for cases where the executable JAR brings a helper JAR with classes that need to be visible to the boot loader (when instrumenting classes in modules defined to the boot loader for example).
The `Launcher-Agent-Class` attribute will be ignored when on small run-time image that doesn't include the `java.instrument` module.
One other point to mention is that the proposal (and implementation) does not include any built-in support for providing options to the agent. If configuration is needed then one simple approach is to include a resource file in the JAR file with the options and have the agent read that with Class.getResourceXXX.
- The attach API disallows attaching to the current process. For now, the "jdk.attach.allowAttachSelf" system property can be used for cases where the tool and target VM are the same process. The system property is set on the command line with `-Djdk.attach.allowAttachSelf` or `-Djdk.attach.allowAttachSelf=true`. It will be ignored on JDK 8 and older.
The builds don't have the Serguei Spitsyn's patch for EnableDynamicAgentLoading yet. We're re-align that with the revised proposal so that there are builds available to try out in the coming days.
-Alan
[1] https://jdk9.java.net/jigsaw/
More information about the jigsaw-dev
mailing list