Repository navigation
Upgrade Java8InAction to Java 17 LTS - #15
tobydrinkall wants to merge 1 commit into
Conversation
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| <configuration> | ||
| <source>1.9</source> | ||
| <target>1.9</target> | ||
| <release>17</release> |
There was a problem hiding this comment.
📝 Info: Verified sources compile under --release 17
I compiled all sources (excluding the JMH-annotated ParallelStreamBenchmark, which needs jmh-core on the classpath) with javac --release 17 -encoding UTF-8. The only remaining errors were missing JUnit symbols in src/main/java/lambdasinaction/chap10/ReadPositiveIntParam.java (satisfied by the compile-scoped junit dependency in the real build). Remaining output is limited to deprecation-for-removal warnings for new Double(String) in src/main/java/lambdasinaction/chap11/Util.java:28 and the deprecated new Date(114, 2, 18) in src/main/java/lambdasinaction/chap12/DateTimeExamples.java:42, plus an unchecked warning in src/main/java/lambdasinaction/appc/StreamForker.java. So the 1.9 → 17 release switch does not break compilation, matching the PR claim.
Was this helpful? React with 👍 or 👎 to provide feedback.
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.11</version> | ||
| <version>4.13.2</version> | ||
| </dependency> |
There was a problem hiding this comment.
📝 Info: JUnit remains compile-scoped and gets shaded into benchmarks.jar
junit has no <scope>, so it is a compile-scope dependency and is bundled by the shade plugin into target/benchmarks.jar along with hamcrest. This is pre-existing (main sources like chap10/ReadPositiveIntParam.java and chap8 use org.junit.Assert from src/main/java), but while the versions are being modernized it would be worth moving those assertion-using examples to src/test/java and marking junit test-scoped, especially now that surefire is explicitly pinned.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Moving the org.junit.Assert examples to src/test/java and making junit test-scoped is a reasonable cleanup, but it relocates book example sources and is out of scope for this Java 17 build upgrade. Leaving the pre-existing compile scope as-is. (My earlier identical reply landed in the .gitignore thread by mistake — this is the intended thread.)
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-shade-plugin</artifactId> | ||
| <version>3.6.2</version> |
There was a problem hiding this comment.
📝 Info: Shade config lacks signature/service filters recommended by JMH
The JMH archetype's shade configuration normally adds a filter removing META-INF/*.SF, *.DSA, *.RSA from bundled dependencies (jopt-simple, commons-math3) to avoid SecurityException: Invalid signature file digest when running the uber-jar. The author's smoke test of -h/-l passed, and the JMH 1.37 dependencies are not signed today, so this is not a demonstrated failure — just a robustness gap now that the plugin version is pinned and dependencies were bumped.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Agreed it's a robustness gap rather than a failure — none of the JMH 1.37 transitive jars are signed today and the uber-jar runs (-h/-l verified locally and in CI). Adding the META-INF/*.SF|*.DSA|*.RSA filter is outside the scoped build changes, so I'm not adding it here; it's a cheap follow-up if you'd like it.
| <configuration> | ||
| <source>1.9</source> | ||
| <target>1.9</target> | ||
| <release>17</release> |
There was a problem hiding this comment.
📝 Info: README still instructs installing JDK 8
README.md still contains a "Make sure to have JDK8 installed" section with a Java 8 download link and java -version sample output. After moving the build to <release>17</release> and CI to temurin 17, the docs are inconsistent with the required toolchain.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Correct, the README is now stale. The upgrade plan for this repo scoped changes to pom.xml plus the CI workflow with no docs edits, so I'm leaving it out rather than expanding scope — happy to update the README's JDK section in a follow-up if wanted.
| # Eclipse, Netbeans and IntelliJ files | ||
| /.* | ||
| !.gitignore | ||
| !/.github |
There was a problem hiding this comment.
📝 Info: Gitignore negation verified to actually track the workflow
The root pattern /.* excludes .github, and because the directory itself is excluded git would not descend into it; the added !/.github re-includes the directory so nested files are considered. Confirmed empirically: git ls-files lists .github/workflows/build.yml and git check-ignore returns non-match for it.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Moving the org.junit.Assert examples to src/test/java and making junit test-scoped is a reasonable cleanup, but it relocates book example sources and is out of scope for this Java 17 build upgrade. Leaving as-is (pre-existing behavior).
|
Superseded by the Java 17 fan-out tracked on Devin board UNT52 (https://app.devin.ai/boards/board-9cb8fbbff9e04d81be8174384344309f); a fresh Java 17 PR will replace this one. |
Summary
Moves the build from Java 9 to Java 17 LTS. The compiler switches from
<source>/<target>1.9to<release>17, so the bootclasspath is pinned to JDK 17 APIs and source cannot accidentally reach newer JDK APIs. JMH must be bumped because1.17.4cannot run on Java 17; the shadedbenchmarks.jarkeepsorg.openjdk.jmh.Mainas its main class.Build/dependency changes (
pom.xml):maven-compiler-plugin3.1→3.13.0,<source>1.9</source><target>1.9</target>→<release>17</release>maven-surefire-plugin3.5.6(was unpinned/absent)maven-shade-pluginpinned to3.6.2(was unversioned)org.openjdk.jmh:jmh-coreandjmh-generator-annprocess1.17.4→1.37junit:junit4.11→4.13.2Source changes: none needed.
DateTimeExamples.java'snew Date(114, 2, 18)andUtil.java'snew Double(String)are deprecated but still compile on 17 (one deprecation warning, no error).CI: new
.github/workflows/build.yml— on push/PR, temurin JDK 17 + maven cache, runsmvn -B -V clean packagethenjava -jar target/benchmarks.jar -hand-las a runtime smoke test.Deviations from the plan:
.gitignorecontained/.*, which silently ignored.github/. Added!/.githubso the workflow is actually tracked.java-17-upgrade-3:origin/java-17-upgradealready exists with open PR Upgrade build to Java 17 #10 from a prior run, and superseded branches were to be left untouched.Verification
mvn -V clean package(OpenJDK 17.0.13, Maven 3.6.3):java -jar target/benchmarks.jar -h:java -jar target/benchmarks.jar -l— lists 5 benchmarks:No tests exist in this repo, so verification is compile + package + JAR runtime smoke test.
Link to Devin session: https://app.devin.ai/sessions/db2ed3d5c29c4e4c9405108805408f24
Requested by: @tobydrinkall
Devin Review