Skip to content

Report the running Jawk version to JSR 223 hosts - #600

Merged
bertysentry merged 2 commits into
mainfrom
598-jsr223-getengineversion-reports-a-hardcoded-version
Aug 20, 2026
Merged

Report the running Jawk version to JSR 223 hosts#600
bertysentry merged 2 commits into
mainfrom
598-jsr223-getengineversion-reports-a-hardcoded-version

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Fixes#598
Fixes#599

Two issues, one bug: JawkScriptEngineFactory.getEngineVersion() answered with the literal "3.3.06-SNAPSHOT", frozen at the 3.x line and carried through the move to io.jawk. Every JSR 223 host — and getParameter(ScriptEngine.ENGINE_VERSION) with it — was told it ran a Jawk that had stopped shipping eleven releases ago, four of them major.

One source of truth

Cli already resolved the real version for -V/--version (#590): manifest Implementation-Version first, the Maven pom.properties resource as the fallback, unknown when Jawk runs from a plain class directory. That lookup was private static in Cli, so the factory could not reach it.

This lifts it into io.jawk.util.JawkVersion, resolved once and read by both callers. A second hard-coded copy is what went stale in the first place, so CliOptionTest now pins the two reports to each other:

assertEquals(JawkVersion.getVersion(), reported);
assertEquals(reported, newJawkScriptEngineFactory().getEngineVersion());

JawkVersion.getVersion() is public because embedders that do not go through JSR 223 want the same value for their own logs; it is documented in java-advanced.md.

Language version

getLanguageVersion() returned "1", which corresponds to no AWK specification. It now reports POSIX, naming the language Jawk implements. A revision number would only invite the same staleness the engine version just had, so the value is deliberately the spec name rather than an edition.

Verified against the built jars

Probing the engine exactly as java-advanced.md documents it, against jawk-7.2.00-SNAPSHOT-standalone.jar:

engine name : Jawk
engine version : 7.2.00-SNAPSHOT
language name : awk
language ver. : POSIX
ENGINE_VERSION : 7.2.00-SNAPSHOT
LANGUAGE_VER. : POSIX
jar Impl-Ver. : 7.2.00-SNAPSHOT

The engine version now matches the jar it was loaded from, and matches jawk --version. The plain jar reports the same; a class-directory run reports unknown, as documented.

Checks

mvn clean verify site: 880 unit tests pass, 0 checkstyle / 0 PMD / 0 SpotBugs findings, no Javadoc warnings. Compatibility (failsafe) results are unchanged — nothing here touches AWK semantics.

🤖 Generated with Claude Code

JawkScriptEngineFactory.getEngineVersion() answered with the literal
"3.3.06-SNAPSHOT", frozen at the 3.x line and carried through the move to
io.jawk, so every JSR 223 host — and getParameter(ENGINE_VERSION) with it —
was told it ran a Jawk that had stopped shipping eleven releases ago.
Cli already resolved the real version for -V/--version. Lift that lookup into
io.jawk.util.JawkVersion, the single source both callers now read, so the two
reports cannot drift apart again; a test pins the CLI report and the engine
version to each other.
getLanguageVersion() returned "1", which corresponds to no AWK specification.
It now reports POSIX, naming the language Jawk actually implements.
Fixes#598Fixes#599
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:c86f8ea84e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

*/
private static String resolveVersion() {
Package myPackage = JawkVersion.class.getPackage();
String version = myPackage != null ? myPackage.getImplementationVersion() : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prefer Jawk-owned metadata over the enclosing manifest

When Jawk is embedded in a shaded/fat application JAR whose main manifest defines the host application's Implementation-Version, Java exposes that value through every package, including io.jawk.util. This branch therefore reports the host application's version and never reaches Jawk's still-correct pom.properties, causing JSR 223 version checks and jawk -V to identify Jawk incorrectly. Resolve the Jawk-owned Maven descriptor first, or otherwise verify that the manifest metadata belongs to the Jawk artifact.

Useful? React with 👍 / 👎.

Package.getImplementationVersion() serves the main attributes of whichever jar
encloses the classes, so a Jawk shaded into an application uber-jar reported
that application's version: verified at 4.1.0-HOST for io.jawk.util inside a
host jar carrying Jawk's classes and descriptor.
The Maven pom.properties resource names the artifact it belongs to, so it can
only be Jawk's. Resolve it first and keep the manifest as the fallback for jars
repackaged without META-INF/maven. Jawk's own jars carry both and they agree, so
their reports are unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@bertysentry

Copy link
Copy Markdown
ContributorAuthor

Good catch — that one was real, and it was latent in jawk -V too, since Cli resolved the version the same way before this PR moved the lookup.

Verified the premise by shading Jawk's classes and its META-INF/maven/io.jawk/jawk/pom.properties into a host jar whose manifest declares Implementation-Version: 4.1.0-HOST:

io.jawk.util package Implementation-Version: 4.1.0-HOST
JawkVersion.getVersion() : 7.2.00-SNAPSHOT

The package really does serve the host's value, so manifest-first reported the application's version. The Maven descriptor names the artifact it belongs to, so it can only be Jawk's — it now decides, with the manifest kept as the fallback for jars repackaged without META-INF/maven. Both of Jawk's own jars carry both sources and they agree, so their reports are unchanged (re-probed the plain and standalone jars: still 7.2.00-SNAPSHOT).

Pinned the precedence in JawkVersionTest, and noted the -V change under Unreleased.

@codex please review again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit:56c6fd5c9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bertysentry
bertysentry merged commit 8f4bd5d into mainAug 20, 2026
5 checks passed
@bertysentry
bertysentry deleted the 598-jsr223-getengineversion-reports-a-hardcoded-version branch August 20, 2026 19:12
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant

@bertysentry