Skip to content

Use --release 8 instead of -source/-target on JDK 17+ buildsΒ #750

Closed

Description

@authorjapps

Currently the Maven compiler plugin is configured with:

<source>1.8</source>
<target>1.8</target>

This produces Java 8 bytecode but does not restrict the API surface β€”
a JDK 17 compiler can silently use APIs introduced after Java 8, causing
runtime failures on JDK 8 environments.

Fix: add maven.compiler.release=8 to the existing jdk-17plus profile.
The --release flag enforces both the language level and the available API
surface in one setting, closing this gap where it matters most (LTS JDKs 17, 21, 23).

JDK 8 and 11 continue to use source/target β€” --release requires JDK 9+
as the compiler, and JDK 9/10 are non-LTS, end-of-life, and not in the CI matrix.

Acceptance Criteria

  • maven.compiler.release=8 is set inside the jdk-17plus profile in pom.xml
  • <source> / <target> properties remain in place (still used for JDK 8 / 11 builds)
  • CI matrix passes on all five JDK versions: 8, 11, 17, 21, 23
  • A brief comment in pom.xml explains why the strategy differs across JDK versions

Raise a PR with proposed changes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions