Disallowing the dynamic loading of agents by default (revised)
mark.reinhold at oracle.com
mark.reinhold at oracle.com
Sun Apr 9 21:04:27 UTC 2017
2017/4/6 2:07:27 -0700, michael.rasmussen at zeroturnaround.com:
> On 6 April 2017 at 02:34, <mark.reinhold at oracle.com> wrote:
>> Interesting. Perhaps we need a `Self-Premain-Class` attribute, or some
>> such.
>>
>> Out of curiosity, would it do any harm in your `java -jar` case if the
>> agent is activated?
>
> As it is right now, yes, that would cause the execution to potentially fail.
> Should a Self-Premain-Class (or like) not be implements, we would have
> to check in the beginning of premain if we are running in java -jar
> mode, and if such, make premain a no-op.
Okay, so how about this revised proposal:
- Define a new JAR-file manifest attribute, `Launcher-Agent-Class`.
If this attribute is present in the manifest of an executable JAR
file then the `agentmain` method of the specified class will be
invoked prior to invoking the `main` method of the application.
The JAR file will, effectively, be loaded also as a dynamic agent.
This will allow `java -jar foo.jar` to be used in place of the more
verbose `java -javaagent:foo.jar -jar foo.jar`.
- Mark
More information about the jigsaw-dev
mailing list