On 02/05/2017 20:21, stanislav lukyanov wrote:
Hi Alan,
In the Launcher-Agent-Class, would it make sense to use 'premain'
instead of 'agentmain'
to align it with Premain-Class rather than with Agent-Class?
(maybe even rename Launcher-Agent-Class to Launcher-Premain-Class?)
AFAIU Launcher-Agent-Class is meant to replace a particular use case
of self-attach in applications - hence the 'agentmain'.
But on the other hand, it is essentially a "shortcut" for '-jar
app.jar -javaagent:app.jar', so 'premain' might as well be expected to
be used (especially by a new user).
Also Launcher-Agent-Class is invoked before the application, like
Premain-Class and unlike Agent-Class,
and some agents out there might use the entry method (premain or
agentmain declared by the same class) to determine how they were invoked.
It will not be possible if 'agentmain' can be invoked both before and
after 'main'
(using different classes for Premain-Class, Agent-Class and
Launcher-Agent-Class will still work though).
Executable JARs is a launcher concept, specified in the JAR file spec,
and not something that the VM knows anything about. You won't see
anything about executable JARs in the JNI invocation interface for
example. This means that the agent declared via Launcher-Agent-Class is
started in a running VM and is more like Agent-Class/agentmain than
Premain-Class/premain. In particular, it may not be possible to get all
the capabilities that an agent specified via `-javaagent` can get. So I
think the proposed names are okay.
As regards using an executable JAR with `-javaagent`, or a tool loading
the executable JAR as an agent library into a running VM, then I think
there is enough flexibility with using different class names.
-Alan.