The development of instrumentation-based dynamic analyses for Java bytecode is enabled by various bytecode rewriting frameworks. Those frameworks are all implemented in Java. This complicates their use for developing full-coverage analyses that not only observe application code, but that also observe the execution of the complete Java class library. Moreover, it makes it hard to avoid perturbation due to the Java code of the instrumentation tool
interfering with the Java code of the observed program. So far, workarounds for these problems required either statically instrumenting the runtime library or running a separate JVM as an instrumentation server.
This paper solves this problem. It introduces JNIF, the first complete bytecode rewriting framework implemented in native code. JNIF can be used in a JVMTI agent to create isolated, full-coverage, in-process dynamic instrumentation tools. JNIF is written in C++ and has an object-oriented design familiar to users of Java-based rewriting libraries. JNIF is able to decode, analyze, edit, and encode Java class files. This includes the generation of stack maps required by split-time verifiers of modern JVMs. Our performance evaluation shows that JNIF is often faster than the most performant competitive approach based on ASM.