You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 36 (#543, #551) the jdk9+ profile sets maven.compiler.release to ${javaVersion}, which defaults to 8. Parents 32 to 35 derived it from maven.compiler.target instead, so overriding target in a child still took effect there. maven-compiler-plugin gives release precedence over source/target (plexus-compiler emits --release whenever the value is non-empty), so a child POM that declares maven.compiler.source and maven.compiler.target but no release, which is every child written against a parent before 32, is compiled for Java 8 on JDK 9+ regardless of its own settings.
Observed on flink-connector-parent moving from org.apache:apache:20 to 39 with source 11 / target 17:
[INFO] Compiling 130 source files with javac [debug release 8] to target/classes
[ERROR] TransactionOwnership.java:[74,29] method orElseThrow in class java.util.Optional<T> cannot be applied to given types
The compile error is the good outcome. A child whose sources happen to be Java 8 compatible is silently downgraded to bytecode 52 instead.
Each available workaround has a cost:
Setting javaVersion fixes release, but it is a single value. A child with different source and target levels, or with per-profile targets, cannot express that through --release.
Overriding the compiler plugin's release parameter in the child works, but nothing points a user at it.
A POM profile cannot see whether the child set maven.compiler.source, so the profile itself cannot be made conditional. What would help:
Call this out in the release notes and on the parent's site: a child that sets maven.compiler.source/target must also set javaVersion or override maven.compiler.release, or its levels are ignored.
Consider having the parent's enforcer execution fail when maven.compiler.source or maven.compiler.target differs from javaVersion on JDK 9+, so the mismatch fails loudly instead of downgrading silently.
Since 36 (#543, #551) the
jdk9+profile setsmaven.compiler.releaseto${javaVersion}, which defaults to 8. Parents 32 to 35 derived it frommaven.compiler.targetinstead, so overridingtargetin a child still took effect there. maven-compiler-plugin givesreleaseprecedence oversource/target(plexus-compiler emits--releasewhenever the value is non-empty), so a child POM that declaresmaven.compiler.sourceandmaven.compiler.targetbut norelease, which is every child written against a parent before 32, is compiled for Java 8 on JDK 9+ regardless of its own settings.Observed on flink-connector-parent moving from
org.apache:apache:20to 39 with source 11 / target 17:The compile error is the good outcome. A child whose sources happen to be Java 8 compatible is silently downgraded to bytecode 52 instead.
Each available workaround has a cost:
javaVersionfixesrelease, but it is a single value. A child with different source and target levels, or with per-profile targets, cannot express that through--release.maven.compiler.releaserestores-source/-targetfor javac, but maven-javadoc-plugin fails on the empty string (Empty release value fails with StringIndexOutOfBoundsException maven-javadoc-plugin#1376).releaseparameter in the child works, but nothing points a user at it.A POM profile cannot see whether the child set
maven.compiler.source, so the profile itself cannot be made conditional. What would help:maven.compiler.source/targetmust also setjavaVersionor overridemaven.compiler.release, or its levels are ignored.maven.compiler.sourceormaven.compiler.targetdiffers fromjavaVersionon JDK 9+, so the mismatch fails loudly instead of downgrading silently.Context: FLINK-40630.
This issue was created with AI assistance.