Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

Java-Runtime-Compiler

> 编程语言
Open source

Java Runtime Compiler

708 stars0 likes0 views
WebsiteGitHub

About

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

[source,xml,subs=+quotes]

net.openhft
compiler
Look up the most recent version on Maven Central.

[source,groovy,subs=+quotes]

/* Gradle (Kotlin DSL) */ implementation("net.openhft:compiler:Look up the most recent version on Maven Central.")

.Example: compile and run a Runnable at runtime [source,java]

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

Class clazz = CompilerUtils.CACHED_COMPILER.loadFromJava(className, src); ((Runnable) clazz.getDeclaredConstructor().newInstance()).run();

== Installation

  • Requires a full JDK (8, 11, 17 or 21 LTS), not a slim JRE.
  • On Java 11 + supply these flags (copy-paste safe):

[source,bash]

--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED

  • Spring-Boot / fat-JAR users ** unpack Chronicle jars: 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

  • Hot-swappable strategy interface for trading engines ** Rule-engine: compile business rules implementing 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

  • Compile on a background thread at start-up; then swap instances. ** Re-use class names or child classloaders to control Metaspace. *** Use 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

  • link:src/main/docs/project-requirements.adoc[Project requirements] outline functional, non-functional, and compliance obligations.
  • link:RELEASE_NOTES.adoc[Release notes] provide the tagged release history.

== FAQ / Troubleshooting

  • ToolProvider.getSystemJavaCompiler() == null
  • You are running on a JRE; use a JDK.
  • ClassNotFoundException: com.sun.tools.javac.api.JavacTool
  • tools.jar is required on JDK feature branch -> PR; run mvn spotless:apply before pushing. ** All code under the Apache License 2.0 - see LICENSE.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言