One RUNTIME bootstrap for every Java2D user in vis (attachment conversion, the PIL shim, the matplotlib shim).
A native image inherits nothing from build time: a top-level
(System/setProperty "java.awt.headless" ...) runs while the image is being
BUILT and is gone by the time the binary starts, so the first createGraphics
in a shipped vis dies with NoClassDefFoundError java/awt/event/InputEvent
(the platform toolkit -- LWCToolkit on macOS -- loads because nothing said
headless). The repair therefore has to happen at RUNTIME, exactly once, before
the first Graphics2D call -- which is what ensure! is for.
One RUNTIME bootstrap for every Java2D user in vis (attachment conversion, the PIL shim, the matplotlib shim). A native image inherits nothing from build time: a top-level `(System/setProperty "java.awt.headless" ...)` runs while the image is being BUILT and is gone by the time the binary starts, so the first `createGraphics` in a shipped `vis` dies with `NoClassDefFoundError java/awt/event/InputEvent` (the platform toolkit -- LWCToolkit on macOS -- loads because nothing said headless). The repair therefore has to happen at RUNTIME, exactly once, before the first Graphics2D call -- which is what `ensure!` is for.
(ensure!)Force the headless/font bootstrap once. Returns true when AWT is usable. Call it before the FIRST Java2D operation on any code path a native binary can reach; it is idempotent and cheap after the first call.
Force the headless/font bootstrap once. Returns true when AWT is usable. Call it before the FIRST Java2D operation on any code path a native binary can reach; it is idempotent and cheap after the first call.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |