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.
Rafael winterhalter
source share