Skip to content

BUILD: Target Java 8 for the published library.#1

Open
oleksandrlazarenko-pi wants to merge 1 commit into
SWAN-community:mainfrom
51Degrees:feature/java8-baseline
Open

BUILD: Target Java 8 for the published library.#1
oleksandrlazarenko-pi wants to merge 1 commit into
SWAN-community:mainfrom
51Degrees:feature/java8-baseline

Conversation

@oleksandrlazarenko-pi

@oleksandrlazarenko-pi oleksandrlazarenko-pi commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Lowers the compile target of the shipped library from Java 21 to Java 8, so
the artifact can be consumed by projects on a Java 8 baseline. Test sources keep
using modern language features and are compiled at a newer release. One Java 11
API call in Io.java is replaced with its Java 8 equivalent.

Motivation

We'd like to build on owid-java from SDKs that still target Java 8 (in our
case the 51Degrees pipeline-java). The library's source is almost entirely
Java 8-compatible already — only the build target and a single JDK 11 API stand
in the way. This change makes the published jar usable on Java 8 runtimes
without affecting behaviour or the development experience.

Changes

  • pom.xml — set maven.compiler.release to 8 for the main sources.
    Added a default-testCompile execution at release 17, because the test
    sources use records (FixturesTest) and List.of(...), which are not part of
    the shipped artifact.
  • Io.java — replaced the three ByteArrayOutputStream.writeBytes(byte[])
    calls (added in Java 11) with write(b, 0, b.length). This was the only JDK
    9+ API used in the main sources.

Compatibility & behaviour

  • Behaviour is unchanged. ByteArrayOutputStream.write(byte[], int, int)
    writes the same bytes and, unlike the inherited OutputStream.write(byte[]),
    does not declare IOException, so no signatures or call sites change.
  • API surface is unchanged — no public types or methods added, removed, or
    modified.
  • The published bytecode moves to class file version 52 (Java 8).

Building

  • Building still requires a modern JDK (17+) because the tests compile at
    release 17. Only the main artifact targets Java 8.
  • CI (ci.yml) runs mvn test on JDK 21 across ubuntu + windows; both pass.
    Locally: Owid.class is major version 52, and an independent
    javac --release 8 of the main sources compiles cleanly (no Java 9+ API).

Notes for reviewers

  • If you'd prefer the whole module (tests included) to build on JDK 8, the two
    test-only usages (record Fixtures, List.of) can be backported as well —
    happy to fold that in if you want a single uniform release level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants