Repository navigation
CodeWitness 1.0.21
CodeWitness 1.0.21 stops the shipped jar from prefixing every run with four lines of JDK warning: the
native-access permission the SQLite driver needs now travels with the artifact instead of depending on the
command line that starts it.
What changed
-
The shaded jar's manifest carries
Enable-Native-Access: ALL-UNNAMED. The bundled SQLite driver loads
a native library through JNI, which JDK 24 made a restricted operation (JEP 472). A jar that has not been
granted native access prints, on the first command that opens a database,WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by org.sqlite.SQLiteJDBCLoader in an unnamed module WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabledand on a later JDK the load is refused outright.
codewitness-cli/pom.xmlnow adds the attribute through
shade'sManifestResourceTransformer, so it is written intoMETA-INF/MANIFEST.MFat package time. A JVM
honours a jar-manifest attribute only when the jar is started with-jar; that is exactly how every entry
point other than the repository's own launcher starts it. -
Why this was a defect and not a cosmetic wart. The repository's launcher already passes
--enable-native-access=ALL-UNNAMED, which is why nothing here saw the problem — but the launcher is one
entry point out of several.java -jar codewitness.jar, an editor or IDE run configuration, a CI step that
invokes the jar directly, and the installed launcher (whose whole body isexec java -jar …) all printed the
warning. Two consequences made it worth an artifact-level fix rather than a note:- The fourth line is a deadline. Once restricted methods are blocked by default, a jar that relies on the
caller remembering a flag stops working, and it will look like the storage layer failing rather than a
packaging oversight. - The warning goes to the JVM's
stderr— the same stream amode: processscenario asserts on. A
requirement that asserts a cleanstderragainst this tool passed through./codewitnessand failed
throughjava -jar, a difference that had nothing to do with what was being verified.
- The fourth line is a deadline. Once restricted methods are blocked by default, a jar that relies on the
-
The launcher keeps its option, and a test says so. The flag still covers a jar built before this
release, and dropping it would be a silent regression, soPackagingNativeAccessTestasserts both halves:
the shade transformer declares<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access>, and the launcher
still passes--enable-native-access=ALL-UNNAMED. Nothing at runtime fails if either is removed — the
warning simply returns, or the old jar stops loading on a future JDK — so the guard is the only thing that
notices. -
Documentation states the arrangement.
README.mdnow says the built jar is self-contained and may be
started withjava -jar, that it carries the attribute because of the SQLite driver, and that the launcher
passes the equivalent option for jars that predate it.
What this does not fix
- It is not a permission grant to anything but the tool's own class path, and not a security boundary.
ALL-UNNAMEDis the whole of a shaded jar; the tool already documents that itslocal-processsandbox is a
resource boundary, not a security boundary, and this changes nothing about that. - A project under verification keeps whatever its own build prints. When CodeWitness builds a Java fixture
through Maven, that child JVM has its own command line; if it loads a native library it will warn in the
build output CodeWitness captures and reports. That output is reported as observed, deliberately — the tool's
own reporting is not the place to filter a project's diagnostics. - Older JDKs are unchanged. A JDK before 24 ignores an unknown manifest main attribute, so the same jar
still runs there; it simply had nothing to warn about.
Verified for this release
- Full reactor suite: 1,762 tests, 0 failures, 0 errors, 0 skipped across the 22 test modules (up from
1,760; the two new assertions are the only addition). - Both guards were proved to fire. With the
<manifestEntries>block removed the test fails with
the shaded jar's manifest must declare <Enable-Native-Access>; …; with the launcher's flag removed it fails
with…/codewitness must pass --enable-native-access=ALL-UNNAMED to the JVM: …. Both pass after the change. - The repackaged jar's manifest reads
Main-Class: dev.codewitness.cli.Mainfollowed byEnable-Native-Access: ALL-UNNAMED,java -jar codewitness.jar report .run from a project with a database prints no JVM warning, and./codewitness versionprintscodewitness 1.0.21. - Self-check against the built jar (
./codewitness verify . --requirements selfcheck/requirements.yaml --config selfcheck/codewitness.yaml --no-mutation --max-duration 30m): all seven ground rulesVERIFIED,
1,762 tests executed and passed, 0 findings — five suppressed with their reasons — and exit0in 1 m 51 s.
Process note
The defect survived because the path that was exercised was the one that hid it. Every local run goes through
./codewitness, which had carried the flag since the toolchain moved to Java 25, so the warning appeared only
to someone who ran the jar directly — in this case from the installed copy in ~/.local, which the launcher
script there starts with a bare java -jar. The lesson generalizes: a fix applied at the call site looks
complete for as long as everyone uses that call site, and the artifact is the thing that gets copied, installed
and invoked by strangers.
Compatibility
- No CLI, exit-code, report-key, SARIF, configuration-key or adapter-SPI change. One attribute is added to the
jar manifest; a JDK that does not know it ignores it. A project verified by 1.0.20 is verified identically
by 1.0.21.