← 输入框|github.com|刷新
Skip to content

Upgrade Java8InAction to Java 17 LTS - #15

Closed
tobydrinkall wants to merge 1 commit into
masterfrom
java-17-upgrade-3
Closed

tobydrinkall wants to merge 1 commit into
masterfrom
java-17-upgrade-3

Conversation

@tobydrinkall

@tobydrinkall tobydrinkall commented Aug 7, 2026 •

Copy link
Copy Markdown

Summary

Moves the build from Java 9 to Java 17 LTS. The compiler switches from <source>/<target>1.9 to <release>17, so the bootclasspath is pinned to JDK 17 APIs and source cannot accidentally reach newer JDK APIs. JMH must be bumped because 1.17.4 cannot run on Java 17; the shaded benchmarks.jar keeps org.openjdk.jmh.Main as its main class.

Build/dependency changes (pom.xml):

  • maven-compiler-plugin 3.1 → 3.13.0, <source>1.9</source><target>1.9</target> → <release>17</release>
  • added maven-surefire-plugin 3.5.6 (was unpinned/absent)
  • maven-shade-plugin pinned to 3.6.2 (was unversioned)
  • org.openjdk.jmh:jmh-core and jmh-generator-annprocess 1.17.4 → 1.37
  • junit:junit 4.11 → 4.13.2

Source changes: none needed. DateTimeExamples.java's new Date(114, 2, 18) and Util.java's new 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, runs mvn -B -V clean package then java -jar target/benchmarks.jar -h and -l as a runtime smoke test.

Deviations from the plan:

  • .gitignore contained /.*, which silently ignored .github/. Added !/.github so the workflow is actually tracked.
  • Branch is java-17-upgrade-3: origin/java-17-upgrade already exists with open PR Upgrade build to Java 17 #10 from a prior run, and superseded branches were to be left untouched.
  • Maven 3.9.6 was not available on the executor; verified with the preinstalled Maven 3.6.3 on JDK 17. CI uses the runner's Maven.

Verification

mvn -V clean package (OpenJDK 17.0.13, Maven 3.6.3):

[INFO] BUILD SUCCESS
[INFO] Total time:  9.823 s

java -jar target/benchmarks.jar -h:

Usage: java -jar ... [regexp*] [options]
 [opt] means optional argument.
 <opt> means required argument.
 "time" arguments accept time suffixes, like "100ms".
  [arguments]                 Benchmarks to run (regexp+). (default: .*)

java -jar target/benchmarks.jar -l — lists 5 benchmarks:

lambdasinaction.chap7.ParallelStreamBenchmark.iterativeSum
lambdasinaction.chap7.ParallelStreamBenchmark.parallelRangedSum
lambdasinaction.chap7.ParallelStreamBenchmark.parallelSum
lambdasinaction.chap7.ParallelStreamBenchmark.rangedSum
lambdasinaction.chap7.ParallelStreamBenchmark.sequentialSum

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

Status Commit
⚪ Not started —

Run Devin Review

Open in Devin Review (Staging)
Open in Devin Review

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
@tobydrinkall tobydrinkall self-assigned this Aug 7, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 5 potential issues.

Open in Devin Review

Comment thread pom.xml
<configuration>
<source>1.9</source>
<target>1.9</target>
<release>17</release>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread pom.xml
Comment on lines 27 to 30
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.2</version>
</dependency>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.)

Comment thread pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.2</version>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread pom.xml
<configuration>
<source>1.9</source>
<target>1.9</target>
<release>17</release>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread .gitignore
# Eclipse, Netbeans and IntelliJ files
/.*
!.gitignore
!/.github

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

@devin-ai-integration

Copy link
Copy Markdown

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant