Fix Java 11 compatibility: replace Stream.toList() and use --release flag#322
Merged
Conversation
…flag Replace Stream.toList() (Java 16+) with Collectors.toList() in JsonPathParser, which is in the base source set targeting Java 11. Additionally, replace sourceCompatibility/targetCompatibility with options.release for both compileJava (11) and compileJava17Java (17). The --release flag enforces API-level compatibility at compile time, preventing future use of APIs unavailable in the target Java version. Fixes #320
|
Note These results are affected by shared workloads on GitHub runners. Use the results only to detect possible regressions, but always rerun on a more stable machine before drawing conclusions! Benchmark resultsBaselineBenchmark
Full results — BaselineBenchmark
InstanceCreationBenchmarkNo significant changes (all within 3.0%). Full results — InstanceCreationBenchmark
JsonMaskerBenchmark
Full results — JsonMaskerBenchmark
LargeKeySetInstanceCreationBenchmarkNo significant changes (all within 3.0%). Full results — LargeKeySetInstanceCreationBenchmark
StreamTypeBenchmark
Full results — StreamTypeBenchmark
ValueMaskerBenchmark
Full results — ValueMaskerBenchmark
Raw output (PR @ 517ba4e)Raw output (master @ 550a7d4) |
|
gavlyukovskiy
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Problem
JsonPathParserin the base source set (src/main/java, targeting Java 11) usesStream.toList(), which was introduced in Java 16. Since the MRJAR only containsMETA-INF/versions/17/entries for other classes (notJsonPathParser), the JVM loads the base class on Java 11–15 and throwsNoSuchMethodErrorat runtime.The root cause is that the build used
sourceCompatibility/targetCompatibilityinstead of--release, which only controls bytecode version but does not enforce API-level compatibility.Fix
JsonPathParser.java: ReplaceStream.toList()(Java 16+) withCollectors.toList()(Java 8+).build.gradle.kts: ReplacesourceCompatibility/targetCompatibilitywithoptions.releasefor bothcompileJava(11) andcompileJava17Java(17). The--releaseflag tellsjavacto compile against the target JDK's API surface, so any future use of post-Java-11 APIs in the base source set will fail at compile time.Verification
build.gradle.ktschange applied (guard enabled, but.toList()still present),./gradlew compileJavafails with:./gradlew clean compileJavapasses.Fixes #320