Skip to content

Commit f0caaee

Browse files
chore: migrate from Java 9 to Java 11
- Update maven-compiler-plugin to 3.11.0 with <release>11</release> - Add maven-surefire-plugin 3.2.5 - Add maven-enforcer-plugin 3.5.0 requiring JDK [11,) - Add maven-javadoc-plugin 3.6.3 with -Xdoclint:none - Upgrade JUnit from 4.11 to 4.13.2 - Upgrade JMH from 1.17.4 to 1.37 - Add GitHub Actions CI workflow for JDK 11 - Add MIGRATION_NOTES.md documenting all changes - Update README.md to state JDK 11 requirement - Update .gitignore to allow .github directory Co-Authored-By: Lukas Burger <lukas.burger@cognition.ai>
1 parent 4786c46 commit f0caaee

5 files changed

Lines changed: 126 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [ master, 'devin/**' ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '11'
20+
distribution: 'temurin'
21+
cache: maven
22+
23+
- name: Build with Maven
24+
run: mvn -B compile --file pom.xml
25+
26+
- name: Run tests
27+
run: mvn -B test --file pom.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Eclipse, Netbeans and IntelliJ files
55
/.*
66
!.gitignore
7+
!.github
78
/nbproject
89
/*.ipr
910
/*.iws

MIGRATION_NOTES.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Migration Notes: Java 9 to Java 11
2+
3+
## Overview
4+
5+
This document describes the changes made to migrate the Java8InAction codebase from Java 9 (source/target 1.9) to Java 11.
6+
7+
## Build Tool Changes (`pom.xml`)
8+
9+
### Compiler Configuration
10+
- **Before**: `maven-compiler-plugin` 3.1 with `<source>1.9</source>` / `<target>1.9</target>`
11+
- **After**: `maven-compiler-plugin` 3.11.0 with `<release>11</release>`
12+
- Added `<maven.compiler.release>11</maven.compiler.release>` property for IDE tooling
13+
14+
### Plugin Additions
15+
| Plugin | Version | Purpose |
16+
|--------|---------|---------|
17+
| `maven-compiler-plugin` | 3.11.0 | Upgraded from 3.1; uses `<release>` instead of source/target |
18+
| `maven-surefire-plugin` | 3.2.5 | Test runner compatible with Java 11+ |
19+
| `maven-enforcer-plugin` | 3.5.0 | Enforces minimum JDK 11 at build time |
20+
| `maven-javadoc-plugin` | 3.6.3 | Configured with `-Xdoclint:none` for lenient Javadoc |
21+
22+
### Dependency Updates
23+
| Dependency | Old Version | New Version | Notes |
24+
|-----------|-------------|-------------|-------|
25+
| JUnit | 4.11 | 4.13.2 | Latest 4.x release; security and bug fixes |
26+
| JMH (jmh-core) | 1.17.4 | 1.37 | Latest release; full Java 11+ support |
27+
| JMH (jmh-generator-annprocess) | 1.17.4 | 1.37 | Kept in sync with jmh-core |
28+
29+
### Encoding
30+
- `<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>` was already present (retained)
31+
32+
## CI/CD
33+
- Added `.github/workflows/build.yml` — GitHub Actions workflow running `mvn compile` and `mvn test` on JDK 11 (Temurin) with Maven dependency caching
34+
35+
## Source Code Changes
36+
- **None required.** The codebase compiled cleanly on Java 11 without any source modifications.
37+
- No JAXB, JavaFX, JAX-WS, CORBA, or Nashorn APIs are used, so no removals were necessary.
38+
- No module-info.java was added; the project continues to use the classpath (no JPMS).
39+
40+
## Build Warnings (informational, not errors)
41+
- `maven-shade-plugin` missing explicit version (pre-existing, not introduced by this migration)
42+
- Deprecation warning in `lambdasinaction/chap11/Util.java` (pre-existing)
43+
- Unchecked operations warning in `lambdasinaction/appc/StreamForker.java` (pre-existing)
44+
45+
## Testing
46+
- No test sources exist in the repository (`src/test/` directory absent)
47+
- `mvn test` succeeds with "No tests to run"
48+
49+
## Compatibility
50+
- **Minimum JDK**: 11 (enforced by `maven-enforcer-plugin`)
51+
- **Build system**: Maven 3.6+
52+
- **No breaking changes** to the educational examples

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ The source code for all examples can be found in the directory [src/main/java/la
2929
* Appendix D: Lambdas and JVM bytecode
3030
We will update the repository as we update the book. Stay tuned!
3131

32-
### Make sure to have JDK8 installed
33-
The latest binary can be found here: http://www.oracle.com/technetwork/java/javase/overview/java8-2100321.html
32+
### Requirements
3433

35-
$ java -version
34+
**JDK 11** or later is required to build and run the examples.
3635

37-
java version "1.8.0_05"
38-
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
39-
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
36+
You can install it via [Adoptium (Eclipse Temurin)](https://adoptium.net/) or your system package manager.
4037

38+
$ java -version
39+
openjdk version "11.0.x" ...
4140

42-
You can download a preview version here: https://jdk8.java.net/
41+
See [MIGRATION_NOTES.md](MIGRATION_NOTES.md) for details on the Java 9 to 11 migration.
4342

4443
### Compile/Run the examples
4544
Using maven:

pom.xml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.release>11</maven.compiler.release>
1314
</properties>
1415

1516
<dependencies>
1617
<dependency>
1718
<groupId>org.openjdk.jmh</groupId>
1819
<artifactId>jmh-core</artifactId>
19-
<version>1.17.4</version>
20+
<version>1.37</version>
2021
</dependency>
2122
<dependency>
2223
<groupId>org.openjdk.jmh</groupId>
2324
<artifactId>jmh-generator-annprocess</artifactId>
24-
<version>1.17.4</version>
25+
<version>1.37</version>
2526
</dependency>
2627
<dependency>
2728
<groupId>junit</groupId>
2829
<artifactId>junit</artifactId>
29-
<version>4.11</version>
30+
<version>4.13.2</version>
3031
</dependency>
3132
</dependencies>
3233

@@ -35,10 +36,42 @@
3536
<plugin>
3637
<groupId>org.apache.maven.plugins</groupId>
3738
<artifactId>maven-compiler-plugin</artifactId>
38-
<version>3.1</version>
39+
<version>3.11.0</version>
3940
<configuration>
40-
<source>1.9</source>
41-
<target>1.9</target>
41+
<release>11</release>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-surefire-plugin</artifactId>
47+
<version>3.2.5</version>
48+
</plugin>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-enforcer-plugin</artifactId>
52+
<version>3.5.0</version>
53+
<executions>
54+
<execution>
55+
<id>enforce-java</id>
56+
<goals>
57+
<goal>enforce</goal>
58+
</goals>
59+
<configuration>
60+
<rules>
61+
<requireJavaVersion>
62+
<version>[11,)</version>
63+
</requireJavaVersion>
64+
</rules>
65+
</configuration>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-javadoc-plugin</artifactId>
72+
<version>3.6.3</version>
73+
<configuration>
74+
<additionalJOption>-Xdoclint:none</additionalJOption>
4275
</configuration>
4376
</plugin>
4477
<plugin>
@@ -63,4 +96,4 @@
6396
</plugin>
6497
</plugins>
6598
</build>
66-
</project>
99+
</project>

0 commit comments

Comments
 (0)