Chapter 08 · Java + TeaVM
Annotated handlers call Java hosts.
LMCode supplies chart data through typed host functions. Java owns the Bar records and replaces the chart only after the handler completes successfully.
Starting the TeaVM application…
How it works
The three buttons run @release, @components, and @failure. The last handler stages a chart and then fails on a second lm2d_use call, leaving the visible chart unchanged.
@release
fn releaseChart() -> void implements ChartHandler {
lm2d_clear();
lm2d_bar("Core", 42.0, "#61d6c5");
lm2d_bar("SVG", 68.0, "#ffcb6b");
lm2d_use();
}