Building jar targeting multiple Java versions, including 9

Oliver Gondža ogondza at gmail.com
Fri Aug 26 12:21:57 UTC 2016


On 2016-08-26 12:02, Alan Bateman wrote:

> In your mail then the class is "MyClass", I'm guessing this isn't really
> your actual class name.

Exactly.

> On the attach API then the supported/documented API is
> com.sun.tools.attach. It's never been documented to make direct use of
> types in sun.tools.attach. Are you casting the VirtualMachine to a
> HotSpotVirtualMachine and hacking into implementation?

I have implemented my own JMX connector[1], that do need to cast to 
HotSpotVirtualMachine in order to load the agent into target process 
using jcmd. If there ware a portable way to initiate JXM connection 
using socket or pid that would work across different java vendors and 
versions I would love to throw that all away but I have not found any. I 
intend to elaborate further and report back if this use-case can be 
covered by exposed modules or not.

> It might be best
> to explain what you are doing. You can of temporarily break
> encapsulation to allow the above to compile/run with `--add-exports
> jdk.attach/sun.tools.attach=<target>", where <target> is your module
> name or ALL-UNNAMED if your library is on the class path.

Good to know that, thanks!

[1] 
https://github.com/olivergondza/dumpling/blob/26092acdb3e9bec540b68a18fe7519d6ee33a814/core/src/main/java/com/github/olivergondza/dumpling/factory/jmx/JmxLocalProcessConnector.java#L124
-- 
oliver


More information about the jigsaw-dev mailing list