Opening -javaagent classes to named modules

Fabian Meumertzheim meumertzheim at code-intelligence.com
Tue May 11 15:10:13 UTC 2021


I am currently working on a JVM fuzzer (
https://github.com/CodeIntelligenceTesting/jazzer/) and would like to apply
it also to classes delivered with the JDK, e.g. the image parsers in
javax.imageio.* in the java.desktop module. The fuzzer uses a Java agent to
add coverage instrumentation (similar to JaCoCo) to classes at runtime.

As opposed to JaCoCo, for technical reasons the fuzzer needs to inject
bytecode referencing a public static byte[] field defined on a class of the
agent. Since -javaagent does not support Java modules, this class will be
part of the unnamed module and thus can't be "opened" to other modules,
leading to a "NoClassDefFoundError" when the bytecode is injected into a
class in a different module, e.g. java.desktop.

Is there any way to have a Java agent open up a class for direct access by
named modules? I have full control over the JVM args within the fuzzer, but
haven't found a way to achieve this.

Fabian


More information about the jigsaw-dev mailing list