Java 9 jigsaw javaagent support

Is there any plan in Java 9 (specifically Jigsaw) to support the specific requirements of Java monitoring agents?

Typically, monitoring agents require access to a class, packages, and modules that are not available by default for original Java applications. Monitoring agents loaded into the JVM using the -javaagent command line argument are not loaded as modules, even if the jar file contains the module-info.class file. The only way I was able to give my monitoring agent the necessary permissions was to add command line arguments that grant these permissions to all unnamed modules.

+8
java-9 agent monitoring java-module
source share
1 answer

The Instrumentation class has been extended with a method that allows you to override any module. It allows you to add additional modules, read, export, open, use services and services:

 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); 

In addition, the ClassFileTransformer API has been extended to register the Java Module during conversion:

 default byte[] transform(Module module, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException; 

This module, combined with the toolkit API, allows you to perform any necessary configuration.

Currently, Java agents are still loaded along the class path without any modulation; this may change since Java 9 is not yet final.

+6
source share

All Articles