Is there any plan in Java 9 (specifically Jigsaw) to support the special requirements of Java monitoring agents?
Typically, monitoring agents require the ability to access class, packages, and modules that are not available by default to original Java applications. Monitoring agents loaded into the JVM via the -javaagent command line argument are not loaded as modules, even if the jar file contains a module-info.class file. The only way that I have been able to provide my monitoring agent with the permissions it need is by adding command line arguments which provide these permissions to all unnamed modules.
The Instrumentation
class was extended with a method that allows the redefinition of any module. It allows you to add additional module reads, exports, opens, service usages and providings:
void redefineModule(Module module,
Set<Module> extraReads,
Map<String,Set<Module>> extraExports,
Map<String,Set<Module>> extraOpens,
Set<Class<?>> extraUses,
Map<Class<?>,List<Class<?>>> extraProvides);
Also, the ClassFileTransformer
API was extended to register a Java Module
upon a transformation:
default byte[] transform(Module module,
ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException;
This module, in combination with the instrumentation API allows for any necessary adjustment.
Currently, Java agents are still loaded on the class path without applying any modularization; this can however change as Java 9 is not yet final.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With