Java Runtime Compiler
= Chronicle Runtime Compiler Chronicle Software :css-signature: demo :toc: macro :sectnums: :source-highlighter: rouge
image:https://img.shields.io/maven-central/v/net.openhft/compiler.svg[Maven Central,link=https://central.sonatype.com/artifact/net.openhft/compiler] image:https://javadoc.io/badge2/net.openhft/compiler/javadoc.svg[] image:https://sonarcloud.io/api/project_badges/measure?project=OpenHFT_Java-Runtime-Compiler&metric=alert_status[]
toc::[]
This library lets you feed plain Java source as a String, compile it in-memory and immediately load the resulting Class - perfect for hot-swapping logic while the JVM is still running.
== Quick-Start
net.openhft
compiler
Look up the most recent version on Maven Central.import net.openhft.compiler.CompilerUtils;
String className = "mypackage.MyDynamicClass"; String src = """ package mypackage; public class MyDynamicClass implements Runnable { public void run() { System.out.println("Hello World"); } } """;
== Installation
bootJar { requiresUnpack("**/chronicle-*.jar") }== Feature Highlights
|=== | Feature | Benefit
| In-memory compile & load | Hot-swap code without restarting JVM
| CachedCompiler | Skips recompilation of unchanged source
| Debug Mode
| Writes .java / .class so IDE breakpoints work
| Custom ClassLoader support | Isolate plugins or enable class unloading
| Nested-class handling | Build helper hierarchy in a single call |===
== Advanced Usage & Patterns
Rule
*** Supports validator hook to vet user code
** Replace reflection: generate POJO accessors, 10 x faster
** Off-heap accessors with Chronicle Bytes / Map== Operational Notes
CompilerUtils.DEBUGGING = true during dev; remember to prune artefacts.
** SLF4J categories: net.openhft.compiler (INFO), compilation errors at ERROR.
** Micrometer timers/counters: compiler.compiles, compiler.failures.== Documentation & Requirements
== FAQ / Troubleshooting
ToolProvider.getSystemJavaCompiler() == nullClassNotFoundException: com.sun.tools.javac.api.JavacToolmvn spotless:apply before pushing.
** All code under the Apache License 2.0 - see LICENSE.No open issues yet, or sync has not completed.