Skip to content

Target Java 21, build with Java 25#1927

Merged
rickie merged 12 commits intomasterfrom
sschroevers/target-jdk-21
Nov 6, 2025
Merged

Target Java 21, build with Java 25#1927
rickie merged 12 commits intomasterfrom
sschroevers/target-jdk-21

Conversation

@Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Oct 19, 2025

To be merged after #1942. ❗

Suggested commit message (to be augmented later):

Target Java 21, build with Java 25 (#1927)

Raising the runtime baseline to Java 21 is necessary for compatibility with
Error Prone 2.43.0+. By raising the build baseline to Java 25 we reduce
maintenance overhead, without impacting downstream users.

Summary of changes:
- Generalize `generate-version-compatibility-overview.sh` to handle distinct
  JDK requirements and omit custom Git tags.
- Introduce SDKMAN! configuration to streamline environment setup for external
  contributors and to simplify future
  `generate-version-compatibility-overview.sh` maintenance.
- Update code to make use of Java 21 language features.
- Update code comments in accordance with the new Java baseline.
- Drop obsolete flags from `.mvn/jvm.config`.

This is a draft PR, to be merged just before we upgrade to the next version of Error Prone, which itself will target Java 21. Open points:

  • Release one more version of Error Prone Support targeting Java 17 before merging this PR. ✔️
  • Move the Refaster rule changes to a separate PR, to be merged after this one. ✔️
  • Drop the Java 17 assumption made by website/generate-version-compatibility-overview.sh. ✔️
  • Understand why not all list.get(0) occurrences are flagged by the new ListGetFirst Refaster rule. ✔️
  • Investigate other cleanup opportunities and improvements that may be unlocked by targeting Java 21. ✔️

Note that raising the build baseline to Java 25 isn't strictly necessary, but it (a) matches what we do for Maven (i.e., always requires the latest version) and (b) means that we retain the need for the Maven Toolchains setup (otherwise I'd be torn to drop all that for the time being, only to have to reintroduce it again later). I propose that we officially move to a cadence where we build with the latest LTS and target the oldest LTS supported by Error Prone.

@Stephan202 Stephan202 added the chore A task not related to code (build, formatting, process, ...) label Oct 19, 2025
@github-actions
Copy link

  • Surviving mutants in this change: 3
  • Killed mutants in this change: 23
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 1
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 9
🎉tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 64
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 10
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 1
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 6
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 9
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 5
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Comment on lines +487 to +498
/** Prefer {@link List#getFirst()} over less idiomatic alternatives. */
static final class ListGetFirst<T> {
@BeforeTemplate
T before(List<T> list) {
return list.get(0);
}

@AfterTemplate
T after(List<T> list) {
return list.getFirst();
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Not all list.get(0) expressions are replaced by the self check. Requires further investigation.

@Stephan202 Stephan202 added this to the 0.27.0 milestone Oct 25, 2025
@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 64
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 10
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 1
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 6
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 9
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 5
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 64
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 10
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 1
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 6
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 9
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 5
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/target-jdk-21 branch from 0bcc409 to 7252240 Compare October 26, 2025 13:58
@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 94
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 6
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202
Copy link
Member Author

Understand why not all list.get(0) occurrences are flagged by the new ListGetFirst Refaster rule.

Initially the new rules didn't match for invocations on List<? extends SomeType> instances. I resolved this by generalizing the Refaster rules. This shows that sometimes the return type of template methods does matter: given S and T extends S, List<T>#getFirst() may be of type S.

@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/target-jdk-21 branch from 91bde89 to 8e4c632 Compare October 31, 2025 18:59
@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Nov 1, 2025

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202
Copy link
Member Author

The PR is now ready for review. I moved the Refaster changes to separate PRs: #1943, #1944, #1945, #1946 and #1947.

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Collaborator

@mohamedsamehsalah mohamedsamehsalah left a comment

Choose a reason for hiding this comment

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

📈 📈 📈 📈

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Perfectly structured PR. Nice effort and I like the JDK 21 improvements 🚀 !

Amazing work @Stephan202 !

@rickie rickie force-pushed the sschroevers/target-jdk-21 branch from ac3ee99 to 96f070e Compare November 6, 2025 15:41
@rickie rickie force-pushed the sschroevers/target-jdk-21 branch from 96f070e to 67d7d5f Compare November 6, 2025 15:45
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2025

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 96
class surviving killed
🧟tech.picnic.errorprone.utils.ThirdPartyLibrary 2 5
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 1 3
🧟tech.picnic.errorprone.experimental.bugpatterns.MethodReferenceUsage 1 11
🎉tech.picnic.errorprone.refaster.matchers.ThrowsCheckedException 0 5
🎉tech.picnic.errorprone.refaster.matchers.ReturnsMono 0 3
🎉tech.picnic.errorprone.refaster.matchers.RequiresComputation 0 6
🎉tech.picnic.errorprone.documentation.BugPatternTestExtractor$BugPatternTestCollector 0 2
🎉tech.picnic.errorprone.bugpatterns.CanonicalAnnotationSyntax 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 8
🎉tech.picnic.errorprone.bugpatterns.MockitoMockClassReference 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting 0 8
🎉tech.picnic.errorprone.bugpatterns.SpringMvcAnnotation 0 3
🎉tech.picnic.errorprone.bugpatterns.StringJoining 0 2
🎉tech.picnic.errorprone.bugpatterns.RedundantStringConversion 0 2
🎉tech.picnic.errorprone.refaster.matchers.IsEmpty 0 13
🎉tech.picnic.errorprone.bugpatterns.PrimitiveComparison 0 8
🎉tech.picnic.errorprone.bugpatterns.DirectReturn 0 7
🎉tech.picnic.errorprone.bugpatterns.EagerStringFormatting$StringFormatExpression 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie merged commit ff828da into master Nov 6, 2025
18 checks passed
@rickie rickie deleted the sschroevers/target-jdk-21 branch November 6, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A task not related to code (build, formatting, process, ...)

Development

Successfully merging this pull request may close these issues.

3 participants