Skip to content

Commit 7150f54

Browse files
Merge pull request #14 from briancorbinxyz/jdk23
Jdk23
2 parents 662a80e + fa28496 commit 7150f54

File tree

15 files changed

+242
-36
lines changed

15 files changed

+242
-36
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ build
1515
debug/
1616
target/
1717

18+
# BC: in our gradle build we changed the target directory to be build/cargo
19+
build/cargo
20+
1821
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
1922
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
2023
Cargo.lock

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"type": "java",
109109
"name": "GameClient (on ZGC)",
110110
"request": "launch",
111-
"vmArgs": "-XX:+UseZGC -XX:+ZGenerational",
111+
"vmArgs": "-XX:+UseZGC",
112112
"mainClass": "org.example.GameClient",
113113
"projectName": "app",
114114
"env": {
@@ -135,7 +135,7 @@
135135
"type": "java",
136136
"name": "GameServer (on ZGC)",
137137
"request": "launch",
138-
"vmArgs": "-XX:+UseZGC -XX:+ZGenerational",
138+
"vmArgs": "-XX:+UseZGC",
139139
"mainClass": "org.example.GameServer",
140140
"projectName": "app",
141141
"env": {

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Pairs with the ongoing blog post: [Road to JDK 25 - Over-Engineering Tic-Tac-Toe
99

1010
### Features
1111

12+
https://openjdk.org/projects/jdk/23/
13+
14+
- **JEP467**: Markdown Documentation Comments
15+
- **JEP474**: ZGC: Generational Mode by Default
16+
- **JEP471**: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
17+
1218
https://openjdk.org/projects/jdk/22/
1319

1420
- **JEP454**: Foreign Function & Memory API

app/.DS_Store

0 Bytes
Binary file not shown.

app/build.gradle.kts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
// https://doc.rust-lang.org/cargo/getting-started/installation.html
1717
val osName = System.getProperty("os.name").lowercase()
1818

19-
val cargoBuildDir = file("${buildDir}/cargo")
19+
val cargoBuildDir = file("${layout.buildDirectory.get()}/cargo")
2020

2121
val libPath = when {
2222
osName.contains("win") -> "${cargoBuildDir}/debug"
@@ -88,6 +88,20 @@ dependencies {
8888
runtimeOnly("ch.qos.logback:logback-classic:1.5.6")
8989
runtimeOnly("org.slf4j:slf4j-api:2.0.13")
9090
runtimeOnly("org.slf4j:slf4j-jdk-platform-logging:2.0.13")
91+
92+
93+
// JDK23: JMH (Third-Party) Not required, added for benchmarking
94+
// https://github.com/openjdk/jmh
95+
implementation("org.openjdk.jmh:jmh-core:1.37")
96+
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.37")
97+
}
98+
99+
// Run JMH benchmark
100+
// ./gradlew jmh
101+
tasks.register<JavaExec>("jmh") {
102+
mainClass.set("org.openjdk.jmh.Main")
103+
classpath = sourceSets["main"].runtimeClasspath
104+
args = listOf("org.example.interop.benchmark.PlayerIdsBenchmark")
91105
}
92106

93107
testing {
@@ -103,7 +117,7 @@ testing {
103117
// Apply a specific Java toolchain to ease working on different environments.
104118
java {
105119
toolchain {
106-
languageVersion = JavaLanguageVersion.of(22)
120+
languageVersion = JavaLanguageVersion.of(23)
107121
}
108122
}
109123

@@ -123,7 +137,7 @@ graalvmNative {
123137
javaLauncher = javaToolchains.launcherFor {
124138
// NB: On MacOS ARM ARCH the native-image implementation is not available
125139
// for the versions of GRAAL_VM Community edition - selecting Oracle
126-
languageVersion = JavaLanguageVersion.of(22)
140+
languageVersion = JavaLanguageVersion.of(23)
127141
vendor = JvmVendorSpec.matching("Oracle")
128142
// languageVersion = JavaLanguageVersion.of(17)
129143
// vendor = JvmVendorSpec.GRAAL_VM
@@ -141,7 +155,7 @@ application {
141155
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
142156
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
143157
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
144-
applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
158+
applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")
145159
}
146160

147161
tasks.run.configure {
@@ -160,7 +174,7 @@ tasks.withType<Test>().all {
160174
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
161175
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
162176
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
163-
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
177+
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")
164178
environment("PATH", libPath) // For Windows
165179
environment("LD_LIBRARY_PATH", libPath) // For Linux
166180
environment("DYLD_LIBRARY_PATH", libPath) // For macOS
@@ -177,7 +191,7 @@ tasks.named<JavaExec>("run") {
177191
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
178192
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
179193
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
180-
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
194+
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")
181195
environment("PATH", libPath) // For Windows
182196
environment("LD_LIBRARY_PATH", libPath) // For Linux
183197
environment("DYLD_LIBRARY_PATH", libPath) // For macOS

app/src/main/java/org/example/GameBoard.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ public interface GameBoard extends JsonSerializable {
4646
*/
4747
int getDimension();
4848

49-
/**
50-
* Converts the game board to a JSON string representation for serialization. Format corresponds
51-
* to the following JSON schema with content as a 1D array of strings of size dimension x
52-
* dimension: {@snippet : { "dimension": int, "content": [ string, ... ] } }
53-
*
54-
* @return the game board as a JSON string
55-
*/
49+
///
50+
/// Converts the game board to a JSON string representation for serialization. Format
51+
/// corresponds to the following JSON schema with content as a 1D array of strings of size
52+
/// dimension x dimension.
53+
///
54+
/// ```javascript
55+
/// { "dimension": int, "content": [ string, string, ..., string ] } }
56+
/// ```
57+
/// @return the game board as a JSON string
58+
/// @see JsonSerializable
5659
String asJsonString();
5760

5861
/**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package org.example;
22

3+
/// This interface defines a contract for classes that can be serialized to JSON strings.
4+
/// Any class that implements this interface must provide an implementation of the `asJsonString()`
5+
/// method, which returns the JSON representation of the object.
36
public interface JsonSerializable {
47

8+
/// Returns the JSON representation of the object.
9+
/// @return the JSON string representation of the object.
510
String asJsonString();
611
}
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package org.example;
22

3-
/**
4-
* Tic-tac-toe player interface for all players
5-
* {@snippet :
6-
* // Create a human player
7-
* Player player = new HumanPlayer("X"); // @highlight region="player" substring="player"
8-
*
9-
* // Choose the next valid move on the game board
10-
* int validBoardLocation = player.nextMove(gameBoard); // @end
11-
* }
12-
*/
3+
/// Tic-tac-toe player interface for all players
4+
/// {@snippet :
5+
/// // Create a human player
6+
/// Player player = new HumanPlayer("X"); // @highlight region="player" substring="player"
7+
///
8+
/// // Choose the next valid move on the game board
9+
/// int validBoardLocation = player.nextMove(gameBoard); // @end
10+
/// }
1311
public sealed interface Player permits HumanPlayer, BotPlayer, RemoteBotPlayer {
14-
12+
13+
/// Returns the marker (e.g. "X" or "O") used by this player.
14+
/// @return the player's marker
1515
String getPlayerMarker();
1616

17+
/// Chooses the next valid move on the game board.
18+
/// @param board the current state of the game board
19+
/// @return the index of the next valid move on the board
1720
int nextMove(GameBoard board);
18-
19-
}
21+
}

app/src/main/java/org/example/SecureMessageHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ private void registerSecurityProviders() {
7474
* @throws InvalidParameterSpecException if the received Kyber parameters are invalid
7575
* @throws InvalidAlgorithmParameterException if the Kyber parameters are invalid
7676
* @throws InvalidKeyException if the public/private key is invalid
77-
* @throws EncapsulateException if the encapsulation of the shared secret fails
7877
* @throws DecapsulateException if the decapsulation of the shared secret fails
7978
* @throws ClassNotFoundException
8079
*/

0 commit comments

Comments
 (0)