What this is. OpenJDK's Project Babylon adds code reflection to Java, and HAT (Heterogeneous Accelerator Toolkit) is the GPU programming toolkit built on it. A January 2026 OpenJDK article by Juan Fumero walks a matrix multiply from 7.1 GFLOP/s on CPU to 14 TFLOP/s on an NVIDIA A10, ending within striking distance of hand-written cuBLAS. This note covers what the mechanism actually is, what the measured numbers are, and what the project itself says is not working.
The mechanism: a code model you can transform
Babylon's stated goal, in its own words, is "to extend the reach of Java to foreign programming models such as SQL, differentiable programming, machine learning models, and GPUs." It is sponsored by the Core Libraries and Compiler Groups.
Code reflection is described as "an enhancement to reflective programming in Java" with three parts: modelling Java programs as code models "suitable for access, analysis, and transformation"; reflection enhancements that expose those models at compile time and run time; and APIs to build, analyse and transform them. The project page does not use the word "IR", but that is the shape of it — a compiler intermediate form reachable from ordinary Java reflection.
HAT is the proof that this is fit for purpose. The project commits to "ensure that code reflection is fit for purpose by creating a GPU programming model for Java that leverages code reflection and is implemented as a Java library." So the relationship runs the other way from how it is usually described: HAT is not an application of Babylon so much as Babylon's acceptance test.
The runtime flow is worth stating precisely. Kernel and compute methods are annotated @Reflect. When a compute graph is built, HAT "retrieves all reachable code models from the code reflection API that are annotated with Reflect, builds its code model, and passes a set of transformation to translate the original code model into a GPU-friendly" form, then generates OpenCL or CUDA C99 from it. Data lives off-heap through the Panama FFM API. The kernel API is SIMT: GIX() for global thread id, an ND-Range of 1, 2 or 3 dimensions, cc.dispatchKernel(ndRange, () -> kernel(...)) as a blocking call with automatic host-device transfer.
The constraint that defines the whole design: "HAT kernels support a reduced set of Java." Kernel bodies are Java source and compile as Java, but only a subset is translatable. The code model is where that subset is enforced, not the language.
What runs where
The toolkit's own README lists exactly three backends: OpenCL C, CUDA C/C++, and Java. Not SPIR-V, HIP or Metal.
The OpenCL backend reaches "any OpenCL-compatible device (including Apple M-chip, Intel CPUs, GPUs and FPGAs) and even ARM and RISC-V CPU system via OpenCL implementations such as OCK." There is also a Java multithreaded backend — but with a caveat worth reading twice: "some advanced constructs are not implemented just yet (e.g, 2D and 3D ranges and shared memory)." Those are precisely the constructs every optimized kernel in the performance walkthrough depends on. The pure-Java backend runs the naive kernel, not the fast one.
A separate tile-kernel API exists but is "Currently only available to target NVIDIA GPUs (Ampere or later)."
Getting it to run at all
This is early-access engineering, and the prerequisites say so. HAT requires the Babylon JDK — a full OpenJDK build you clone and make images yourself — on top of a base JDK of 26 or later (OpenJDK 26 in development). Then OpenCL 1.2 or later, or CUDA SDK 13.0 or later; cmake 3.22.1+; gcc 12+ or clang 17+. Running a program needs --enable-preview, --add-modules=jdk.incubator.code and --enable-native-access=ALL-UNNAMED.
Actively supported systems are listed as Apple Silicon M1–M5, Fedora 43+, Oracle Linux 10.0+, Ubuntu 22.04+. The repository was created in November 2023, carries about 163 stars, and is actively pushed to.
The numbers, and what they were measured on
All figures below come from the January 2026 article, on one machine: an OCI BM.GPU.A10 instance — Intel Xeon Platinum 8358 at 2.60 GHz, 236 GB RAM, NVIDIA A10 (compute capability 8.6), Ubuntu 22.04.5, NVIDIA driver 580.105.08, CUDA SDK 13.0.88, Babylon build 9b1ef462b0a on base JDK 26.ea.10-open. Matrices are 1024×1024 FP32 unless noted.
CPU baseline: Java parallel streams, one dot product per thread, 100 runs averaged, 299 ms, which the author computes as 7.1 GFLOP/s. He is explicit that this run does not flush caches or pin CPU frequency, while the GPU measurements do — so the CPU baseline is, if anything, flattered.
The optimization ladder, in the article's own order: a 2D GPU kernel, global coalesced memory access, loop tiling with shared memory, register tiling with increased work per thread, GPU vectorization, and finally FP16. Eight kernels in total. One intermediate datapoint: the register-tiled FP16 kernel at a 16×16 block takes 281 µs, "an 33% improvement over the previous version."
Against cuBLAS. Two measurement regimes, and the difference matters. Under the ncu profiler, which pins GPU frequency and controls cache behaviour for deterministic comparison, the numbers are lower. Using CUDA kernel events instead — caches not flushed, frequency left to the driver, which the author calls "a more real-world scenario" — cuBLAS reaches 12.7 TFLOP/s and HAT reaches 10.2 TFLOP/s in FP32, and 14 TFLOP/s in FP16. Note that cuBLAS was not run in FP16, so the 14 is not a like-for-like win over it; the honest FP32 comparison is 10.2 against 12.7, or about 80% of a vendor BLAS from Java source.
End to end, including host-device transfer, against the Java parallel-streams CPU baseline: 83× for FP32 and 132× for FP16.
What the article itself says you should not conclude
The caveats are the article's own, and they are unusually candid for a performance walkthrough.
On generality: "we have focused on a single data point (data size) on a specific GPU to illustrate the mechanisms of code-reflection and HAT." One size, one GPU, one vendor.
On portability: "performance portability and automated tuning remain open research questions." The tuning parameters that produced these numbers — thread-block size, tiling strategy, hardware-specific intrinsics — "can be different" across micro-architecture generations and vendors. The 16-threads-per-block choice is called out explicitly as A10-specific: "if you are running this example on another GPU, you may need to tune this number."
On data movement: the kernel-optimization sections deliberately ignore transfer cost — "This is something we have overlooked in this article, since we are focusing on GPU kernel optimizations" — which is why the separate end-to-end graph exists.
On maturity: "HAT is in active development, parallel constructs and APIs might evolve to higher level-abstractions." Named future work includes Tensor Core operations and double buffering, neither of which these numbers use.
Why this is interesting beyond Java
Three things generalise.
A reflection API over code models turns a language into a compiler front end. The same @Reflect-annotated method is both ordinary Java the IDE understands and an input to a source-to-source translator. The cost is that only a subset of the language survives translation, and the subset is enforced at model-transformation time rather than by the type system — which is a correctness boundary a reader should ask about before relying on it.
The debug backend is where this kind of design usually leaks. Having a CPU backend so you can debug kernels in a normal debugger is the right idea; having one that does not implement 2D ranges or shared memory means the optimized kernel has no debuggable twin. That gap, not the GFLOP/s, is the thing to watch across releases.
"Close to native" has a denominator. 10.2 against 12.7 TFLOP/s is a meaningful claim precisely because the comparison target is a named vendor library on named hardware with the measurement regime stated twice. A great many "near-native" claims do not survive being written down that carefully.
Sources: the OpenJDK Project Babylon page; the HAT README in the openjdk/babylon repository (branch code-reflection); "Optimizing GPU Programs from Java using Babylon and HAT" by Juan Fumero, OpenJDK, January 2026; and an inside.java JavaOne session page. The podcast episode that prompted this note is not a source for it; nothing here comes from it. Nothing was built or run.