From 3430709d9572acbe41f00a6fe4c8484be3846a09 Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Wed, 7 Aug 2024 21:32:39 -0400 Subject: [PATCH 1/8] JDK23: Upgrade to JDK 23, Gradle 8.9 --- app/build.gradle.kts | 6 +++--- .../app/build))/cargo/.rustc_info.json | 1 + .../app/build))/cargo/CACHEDIR.TAG | 3 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json create mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1171363..bffa839 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,7 +16,7 @@ repositories { // https://doc.rust-lang.org/cargo/getting-started/installation.html val osName = System.getProperty("os.name").lowercase() -val cargoBuildDir = file("${buildDir}/cargo") +val cargoBuildDir = file("${layout.buildDirectory}/cargo") val libPath = when { osName.contains("win") -> "${cargoBuildDir}/debug" @@ -103,7 +103,7 @@ testing { // Apply a specific Java toolchain to ease working on different environments. java { toolchain { - languageVersion = JavaLanguageVersion.of(22) + languageVersion = JavaLanguageVersion.of(23) } } @@ -123,7 +123,7 @@ graalvmNative { javaLauncher = javaToolchains.launcherFor { // NB: On MacOS ARM ARCH the native-image implementation is not available // for the versions of GRAAL_VM Community edition - selecting Oracle - languageVersion = JavaLanguageVersion.of(22) + languageVersion = JavaLanguageVersion.of(23) vendor = JvmVendorSpec.matching("Oracle") // languageVersion = JavaLanguageVersion.of(17) // vendor = JvmVendorSpec.GRAAL_VM diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json new file mode 100644 index 0000000..ff044f3 --- /dev/null +++ b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":8700508722116620401,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/briancorbin/.rustup/toolchains/stable-aarch64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.80.0 (051478957 2024-07-21)\nbinary: rustc\ncommit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9\ncommit-date: 2024-07-21\nhost: aarch64-apple-darwin\nrelease: 1.80.0\nLLVM version: 18.1.7\n","stderr":""},"16495917692426387086":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 336b700edf8f215497678b27c5bcbb8ec4ce8f45 Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Wed, 7 Aug 2024 22:34:14 -0400 Subject: [PATCH 2/8] JDK23: Markdown Documentation Comments: Initial replacement of some key javadoc comments --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 3 ++ app/.DS_Store | Bin 6148 -> 8196 bytes .../app/build))/cargo/.rustc_info.json | 1 - .../app/build))/cargo/CACHEDIR.TAG | 3 -- app/src/main/java/org/example/GameBoard.java | 17 ++++++----- .../java/org/example/JsonSerializable.java | 5 ++++ app/src/main/java/org/example/Player.java | 28 ++++++++++-------- .../org/example/SecureMessageHandler.java | 1 - 9 files changed, 33 insertions(+), 25 deletions(-) delete mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json delete mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG diff --git a/.DS_Store b/.DS_Store index fadd49af93a07740151b4698fdea46e28fdbf625..3e9311032ef11f87d602f4b85d974733085d3588 100644 GIT binary patch literal 6148 zcmeHK%Wl&^6ur}=jnfDSqDZhnvcxuoL=6v#O_HXIN`*yT!2(dQ<0zQAb`(2g5k<-# zzJXt0&5!Uetl-?4DYD&k3kc1X=AL=n*Br;53=xU`+;0=riO51@Ebl^X5MJkYNw)ON z4WQr{@yH8f4Mh$W3S~Z;?#(TmH?PhC!0H zTHnQ1sl2^Yu_{*0dh5K87f$M?^Q7<2Ui0WQjzjOF?|LtT@nTrtJBXvy4WjW(It2b0 zCU0H^ksmMm@jUVq>FcNkt7=t;^}EaEeyh{4_dAbP4SU&cKYh}$JC8f7Rn@wE|KYQf z;aPYd#h(=G0v{zQ*EC+hXLR&-{A3h*D349`)JJC)g>f{&49{+pM{^1&B)`DWSFC0k z+Mx-}z@-n{ao$$kE7;!5+ENqz&nSi-15;!hQ&Nb)o62UZw}{MJANQ{K7w|MHP10K z5lsqpf_ZU0Q)iV$_Adzkx*=9gq0xo`!+>GnHv{~Au+bR18rKTtrvpk} z0f1#pOF>`$`3KrO0qkmAE5r;$C|96z75a)H^xZ)ycdU1{{aT@NCm}N)tn>MQc=i21?_@@X0mHz5#egUeoIxL3(r4?X&GA`lqrF38 qVY{_L=>nyXW7*-O_zs#Btl8WFb~UaQVg_RV2uK=?G7S7t27Un*>Gzlb delta 90 zcmZoMXfc=|#>AjHu~3+iaWW&Tm@ESbFo8)121Xza!~zV-IZ65XIgFbHImB2tD{xF= i-ptOy&jHj36#33PnO{T^sNGaVd9ptb$L1K370dvYOAuiI diff --git a/.gitignore b/.gitignore index ecfdcb4..f170865 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,9 @@ build debug/ target/ +# BC: in our gradle build we changed the target directory to be build/cargo +build/cargo + # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html Cargo.lock diff --git a/app/.DS_Store b/app/.DS_Store index 16d875f048b003f89438f610b00ecfc05d69253a..b1306020c713426bd43bbffd743b9446679c3ce0 100644 GIT binary patch literal 8196 zcmeHMO>fgM7=FFAEY*b614!j&2@W7t(5_{GxKv%YGopMP0F|T(B_hOCl2WFsQqRDh zzXE@R-^1e%pj%r3mx+njll|E5m+dERtT!Vf(Vc`%q8br-s2Z!gXx0?1*L9_AIY}8P z;7=3=(|jBxDp;{)0W-i1Fayj0Gr$b|8w}vi*2UX!?^`Xm%m6d+UoxQI4-!>l$Kk@F zd3B&MDFCnpu_@>y4=_H`VaMUZqH#q`n>`5UDqM;otUL5ln*%!z7Z$BM3F}V6%`9Ao zBFyaYlg6Ax$0E1P05h=4fX>~^6wriXN>1eOUxING=S8FOO>AwK$`^LL9dFlr(SNO` z{lYIMdDqXL>Cq#llHf<*51z!)bWpu?pwhyR(}*kCu#KWAq^2}2w$Ia{K?-$jVVPGy@nJX$Eq&(sdgjOE%52tZ zwCl3fzO9c*vw8Q0m{a6@(D_Q?0@yxPyJ{F-~Z-_al;IpM+Ua-qH8+;KivHN z|2%Gu*USts1AoYXDE0ciE{t)ZuPr*)mZ&dLb43tkvDNfEw z%FoYX+*mk`ePRROVs;J=L1wTj1_5p$?Fz)I8w}2V_3TN`}qx HJad= Date: Wed, 7 Aug 2024 22:42:23 -0400 Subject: [PATCH 3/8] JDK23: Markdown Documentation Comments: Update README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b59913d..100979a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ Pairs with the ongoing blog post: [Road to JDK 25 - Over-Engineering Tic-Tac-Toe ### Features +https://openjdk.org/projects/jdk/23/ + +- **JEP467**: Markdown Documentation Comments + https://openjdk.org/projects/jdk/22/ - **JEP454**: Foreign Function & Memory API From a3535c38a6191533676f2706feaf3a35b367f47a Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Thu, 8 Aug 2024 15:53:41 -0400 Subject: [PATCH 4/8] JDK23: ZGC: Generational Mode by Default - Update launch configurations --- .DS_Store | Bin 6148 -> 6148 bytes .vscode/launch.json | 4 ++-- app/.DS_Store | Bin 8196 -> 6148 bytes app/build.gradle.kts | 6 +++--- .../app/build))/cargo/.rustc_info.json | 1 + .../app/build))/cargo/CACHEDIR.TAG | 3 +++ 6 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json create mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG diff --git a/.DS_Store b/.DS_Store index 3e9311032ef11f87d602f4b85d974733085d3588..9adf56a28c1b3959c47f013f16e0020143f7d543 100644 GIT binary patch delta 309 zcmZoMXfc=|#>B`mu~2NHo}vgV0|Nsi1A_oVa!yiyeh!ewz(28YMLkHInIVy(fT19z z7)g$ylp&9ygdr1%a~M(?QWz8%(irlA>=YocC@0-8I5|JJ0Avgl@Z;B!oA2V1l#`zX zRL$Y)nb5Y(=$Ipr9ZOJK3N~#7bQNSkoVQt!LyTo(0~ga~b`E|HU|;|RzB5ne7qJuo Rxf&QAOi-F-bA-qmW&o{6K*j(7 literal 6148 zcmeHK%Wl&^6ur}=jnfDSqDZhnvcxuoL=6v#O_HXIN`*yT!2(dQ<0zQAb`(2g5k<-# zzJXt0&5!Uetl-?4DYD&k3kc1X=AL=n*Br;53=xU`+;0=riO51@Ebl^X5MJkYNw)ON z4WQr{@yH8f4Mh$W3S~Z;?#(TmH?PhC!0H zTHnQ1sl2^Yu_{*0dh5K87f$M?^Q7<2Ui0WQjzjOF?|LtT@nTrtJBXvy4WjW(It2b0 zCU0H^ksmMm@jUVq>FcNkt7=t;^}EaEeyh{4_dAbP4SU&cKYh}$JC8f7Rn@wE|KYQf z;aPYd#h(=G0v{zQ*EC+hXLR&-{A3h*D349`)JJC)g>f{&49{+pM{^1&B)`DWSFC0k z+Mx-}z@-n{ao$$kE7;!5+ENqz&nSi-15;!hQ&Nb)o62UZw}{MJANQ{K7w|MHP10K z5lsqpf_ZU0Q)iV$_Adzkx*=9gq0xo`!+>GnHv{~Au+bR18rKTtrvpk} z0f1#pOF>`$`3KrO0qkmAE5r;$C|96z75a)H^xZ)ycdU1{{aT@NCm}N)tn>MQc=i21?_@@X0mHz5#egUeoIxL3(r4?X&GA`lqrF38 qVY{_L=>nyXW7*-O_zs#Btl8WFb~UaQVg_RV2uK=?G7S7t27Un*>Gzlb diff --git a/.vscode/launch.json b/.vscode/launch.json index f015e2f..8916aa6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -108,7 +108,7 @@ "type": "java", "name": "GameClient (on ZGC)", "request": "launch", - "vmArgs": "-XX:+UseZGC -XX:+ZGenerational", + "vmArgs": "-XX:+UseZGC", "mainClass": "org.example.GameClient", "projectName": "app", "env": { @@ -135,7 +135,7 @@ "type": "java", "name": "GameServer (on ZGC)", "request": "launch", - "vmArgs": "-XX:+UseZGC -XX:+ZGenerational", + "vmArgs": "-XX:+UseZGC", "mainClass": "org.example.GameServer", "projectName": "app", "env": { diff --git a/app/.DS_Store b/app/.DS_Store index b1306020c713426bd43bbffd743b9446679c3ce0..501021eefdf0aa17941afb942b86753be74e07c2 100644 GIT binary patch delta 112 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50$jH1gU^gQp^JX3aHpY!5Us)Ej ub8rYU162Tl05_0u1u5QG_?>w&zl4l@AYmJkvE literal 8196 zcmeHMO>fgM7=FFAEY*b614!j&2@W7t(5_{GxKv%YGopMP0F|T(B_hOCl2WFsQqRDh zzXE@R-^1e%pj%r3mx+njll|E5m+dERtT!Vf(Vc`%q8br-s2Z!gXx0?1*L9_AIY}8P z;7=3=(|jBxDp;{)0W-i1Fayj0Gr$b|8w}vi*2UX!?^`Xm%m6d+UoxQI4-!>l$Kk@F zd3B&MDFCnpu_@>y4=_H`VaMUZqH#q`n>`5UDqM;otUL5ln*%!z7Z$BM3F}V6%`9Ao zBFyaYlg6Ax$0E1P05h=4fX>~^6wriXN>1eOUxING=S8FOO>AwK$`^LL9dFlr(SNO` z{lYIMdDqXL>Cq#llHf<*51z!)bWpu?pwhyR(}*kCu#KWAq^2}2w$Ia{K?-$jVVPGy@nJX$Eq&(sdgjOE%52tZ zwCl3fzO9c*vw8Q0m{a6@(D_Q?0@yxPyJ{F-~Z-_al;IpM+Ua-qH8+;KivHN z|2%Gu*USts1AoYXDE0ciE{t)ZuPr*)mZ&dLb().all { // WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module // WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module // WARNING: Restricted methods will be blocked in a future release unless native access is enabled - jvmArgs = listOf("--enable-native-access=ALL-UNNAMED") + applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") environment("PATH", libPath) // For Windows environment("LD_LIBRARY_PATH", libPath) // For Linux environment("DYLD_LIBRARY_PATH", libPath) // For macOS @@ -177,7 +177,7 @@ tasks.named("run") { // WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module // WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module // WARNING: Restricted methods will be blocked in a future release unless native access is enabled - jvmArgs = listOf("--enable-native-access=ALL-UNNAMED") + applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") environment("PATH", libPath) // For Windows environment("LD_LIBRARY_PATH", libPath) // For Linux environment("DYLD_LIBRARY_PATH", libPath) // For macOS diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json new file mode 100644 index 0000000..a819320 --- /dev/null +++ b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":2030252408025272600,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/briancorbin/.rustup/toolchains/stable-aarch64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.80.0 (051478957 2024-07-21)\nbinary: rustc\ncommit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9\ncommit-date: 2024-07-21\nhost: aarch64-apple-darwin\nrelease: 1.80.0\nLLVM version: 18.1.7\n","stderr":""},"16495917692426387086":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ From 33585fe7ea3fd46bbae5ad2792f3fc1e26beb78f Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Thu, 8 Aug 2024 16:55:09 -0400 Subject: [PATCH 5/8] JDK23: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal --- app/build.gradle.kts | 4 +- .../java/org/example/interop/PlayerIds.java | 31 ++++++++++++++++ .../example/interop/TicTacToeGameBoard.java | 11 +++--- .../org/example/interop/PlayerIdsTest.java | 37 +++++++++++++++++++ 4 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/org/example/interop/PlayerIds.java create mode 100644 app/src/test/java/org/example/interop/PlayerIdsTest.java diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c08ba61..0662254 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -160,7 +160,7 @@ tasks.withType().all { // WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module // WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module // WARNING: Restricted methods will be blocked in a future release unless native access is enabled - applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") + jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") environment("PATH", libPath) // For Windows environment("LD_LIBRARY_PATH", libPath) // For Linux environment("DYLD_LIBRARY_PATH", libPath) // For macOS @@ -177,7 +177,7 @@ tasks.named("run") { // WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module // WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module // WARNING: Restricted methods will be blocked in a future release unless native access is enabled - applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") + jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC") environment("PATH", libPath) // For Windows environment("LD_LIBRARY_PATH", libPath) // For Linux environment("DYLD_LIBRARY_PATH", libPath) // For macOS diff --git a/app/src/main/java/org/example/interop/PlayerIds.java b/app/src/main/java/org/example/interop/PlayerIds.java new file mode 100644 index 0000000..747a031 --- /dev/null +++ b/app/src/main/java/org/example/interop/PlayerIds.java @@ -0,0 +1,31 @@ +package org.example.interop; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + +public class PlayerIds { + + private volatile int nextId; + + private static final VarHandle NEXT_ID_VH; + + static { + try { + NEXT_ID_VH = MethodHandles.lookup().findVarHandle(PlayerIds.class, "nextId", int.class); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new ExceptionInInitializerError(e); + } + } + + public PlayerIds(int initialValue) { + this.nextId = initialValue; + } + + public int getNextId() { + return nextId; + } + + public int getNextIdAndIncrement() { + return (int) NEXT_ID_VH.getAndAdd(this, 1); + } +} diff --git a/app/src/main/java/org/example/interop/TicTacToeGameBoard.java b/app/src/main/java/org/example/interop/TicTacToeGameBoard.java index e5a320d..95e4990 100644 --- a/app/src/main/java/org/example/interop/TicTacToeGameBoard.java +++ b/app/src/main/java/org/example/interop/TicTacToeGameBoard.java @@ -12,7 +12,6 @@ import java.lang.ref.Cleaner; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; import org.example.GameBoard; @@ -28,7 +27,7 @@ class TicTacToeGameBoard implements GameBoard { private final SymbolLookup libTicTacToe; - private final AtomicInteger nextId; + private final PlayerIds playerIds; private final Map playerMarkerToId; private final Map idToPlayerMarker; @@ -48,7 +47,7 @@ public TicTacToeGameBoard(int dimension, SymbolLookup libTicTacToe, Cleaner clea this.libTicTacToe = libTicTacToe; this.playerMarkerToId = new HashMap<>(); this.idToPlayerMarker = new HashMap<>(); - this.nextId = new AtomicInteger(1); + this.playerIds = new PlayerIds(1); this.initGameBoardMethods(); this.board = newGameBoard(dimension); this.cleaner = cleaner; @@ -73,7 +72,7 @@ public TicTacToeGameBoard(int dimension, SymbolLookup libTicTacToe, Cleaner clea this.libTicTacToe = libTicTacToe; this.playerMarkerToId = new HashMap<>(playerMarkerToId); this.idToPlayerMarker = new HashMap<>(idToPlayerMarker); - this.nextId = new AtomicInteger(initialValue); + this.playerIds = new PlayerIds(initialValue); this.initGameBoardMethods(); this.board = board; this.cleaner = cleaner; @@ -109,7 +108,7 @@ public boolean hasMovesAvailable() { @Override public GameBoard withMove(String playerMarker, int location) { if (!playerMarkerToId.containsKey(playerMarker)) { - int id = nextId.getAndIncrement(); + int id = playerIds.getNextIdAndIncrement(); playerMarkerToId.put(playerMarker, id); idToPlayerMarker.put(id, playerMarker); } @@ -121,7 +120,7 @@ public GameBoard withMove(String playerMarker, int location) { newBoard, playerMarkerToId, idToPlayerMarker, - nextId.get(), + playerIds.getNextId(), libTicTacToe, cleaner); } catch (Throwable e) { diff --git a/app/src/test/java/org/example/interop/PlayerIdsTest.java b/app/src/test/java/org/example/interop/PlayerIdsTest.java new file mode 100644 index 0000000..089a6e4 --- /dev/null +++ b/app/src/test/java/org/example/interop/PlayerIdsTest.java @@ -0,0 +1,37 @@ +package org.example.interop; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +public class PlayerIdsTest { + + @Test + public void test_should_be_able_to_create_player_ids_with_an_initial_value() { + PlayerIds playerIds = new PlayerIds(1); + assertEquals(1, playerIds.getNextId()); + } + + @Test + public void test_should_be_able_to_get_current_id() { + PlayerIds playerIds = new PlayerIds(5); + assertEquals(5, playerIds.getNextId()); + } + + @Test + public void test_should_be_able_to_atomically_get_current_id_and_increment_it() { + PlayerIds playerIds = new PlayerIds(1); + assertEquals(1, playerIds.getNextIdAndIncrement()); + assertEquals(2, playerIds.getNextId()); + } + + @Test + public void test_should_be_able_to_atomically_get_current_id_and_increment_it_multiple_times() { + PlayerIds playerIds = new PlayerIds(1); + assertEquals(1, playerIds.getNextIdAndIncrement()); + assertEquals(2, playerIds.getNextIdAndIncrement()); + assertEquals(3, playerIds.getNextIdAndIncrement()); + assertEquals(4, playerIds.getNextIdAndIncrement()); + assertEquals(5, playerIds.getNextIdAndIncrement()); + } +} From e371609f014a85a0e76e32759112a2f05c722612 Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Thu, 8 Aug 2024 17:01:19 -0400 Subject: [PATCH 6/8] JDK23: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 100979a..071a0c2 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Pairs with the ongoing blog post: [Road to JDK 25 - Over-Engineering Tic-Tac-Toe https://openjdk.org/projects/jdk/23/ - **JEP467**: Markdown Documentation Comments +- **JEP474**: ZGC: Generational Mode by Default +- **JEP471**: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal https://openjdk.org/projects/jdk/22/ From 91571c051446ab85a127b2e3faba619f8528e303 Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Thu, 8 Aug 2024 18:43:06 -0400 Subject: [PATCH 7/8] JDK23: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal: Add a JMH microbenchmark for the Player Id Generator --- .DS_Store | Bin 6148 -> 6148 bytes app/build.gradle.kts | 14 +++ .../interop/benchmark/PlayerIdsBenchmark.java | 104 ++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java diff --git a/.DS_Store b/.DS_Store index 9adf56a28c1b3959c47f013f16e0020143f7d543..c6f8a19e592f01bd6e790aea9ebbb39a5d560899 100644 GIT binary patch delta 206 zcmZoMXfc@JFT%#az`)4BAi$8Ela!yI1LQHVPyWcb!Vx6F%#g@Xz)+Aez`)4BAi$8Ela!yI1LQIAPrk^wA_FAB%#g@Xz)+AX$<*5b_$SJl#^~4oSdIq05S&(`0?wQoX04xL_ke$e#+!RMiF@e Q$~Ny})L`4p&heKY0I$?8e*gdg diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0662254..b3cf7d3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -88,6 +88,20 @@ dependencies { runtimeOnly("ch.qos.logback:logback-classic:1.5.6") runtimeOnly("org.slf4j:slf4j-api:2.0.13") runtimeOnly("org.slf4j:slf4j-jdk-platform-logging:2.0.13") + + + // JDK23: JMH (Third-Party) Not required, added for benchmarking + // https://github.com/openjdk/jmh + implementation("org.openjdk.jmh:jmh-core:1.37") + annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.37") +} + +// Run JMH benchmark +// ./gradlew jmh +tasks.register("jmh") { + mainClass.set("org.openjdk.jmh.Main") + classpath = sourceSets["main"].runtimeClasspath + args = listOf("org.example.interop.benchmark.PlayerIdsBenchmark") } testing { diff --git a/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java b/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java new file mode 100644 index 0000000..0caf8d5 --- /dev/null +++ b/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java @@ -0,0 +1,104 @@ +package org.example.interop.benchmark; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReentrantLock; +import org.example.interop.PlayerIds; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; + +public class PlayerIdsBenchmark { + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testPlayerIdsGetId() { + PlayerIds ids = new PlayerIds(1); + for (int i = 0; i < 1000; i++) { + var id = ids.getNextId(); + } + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testPlayerIdsGetAndIncrementId() { + PlayerIds ids = new PlayerIds(1); + for (int i = 0; i < 1000; i++) { + var id = ids.getNextIdAndIncrement(); + } + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testAtomicIntegerGetId() { + AtomicInteger ids = new AtomicInteger(1); + for (int i = 0; i < 1000; i++) { + var id = ids.get(); + } + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testAtomicIntegerGetAndIncrement() { + AtomicInteger ids = new AtomicInteger(1); + for (int i = 0; i < 1000; i++) { + var id = ids.getAndIncrement(); + } + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testLockGetId() { + Control ids = new Control(1); + for (int i = 0; i < 1000; i++) { + var id = ids.getId(); + } + } + + @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + public void testLockGetAndIncrement() { + Control ids = new Control(1); + for (int i = 0; i < 1000; i++) { + var id = ids.getAndIncrement(); + } + } + + /// Naive implementation of an id generator. + private static class Control { + private final ReentrantLock lock = new ReentrantLock(); + + private int id = 1; + + private Control(int initialValue) { + this.id = initialValue; + } + + private int getId() { + lock.lock(); + try { + return id; + } finally { + lock.unlock(); + } + } + + private int getAndIncrement() { + lock.lock(); + try { + int oldId = id; + id = id + 1; + return oldId; + } finally { + lock.unlock(); + } + } + } +} From fa28496255c4c5621773dfd2462875ce54edf713 Mon Sep 17 00:00:00 2001 From: Brian Corbin Date: Thu, 8 Aug 2024 18:53:45 -0400 Subject: [PATCH 8/8] JDK23: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal: Fix warnings/breaks --- .DS_Store | Bin 6148 -> 6148 bytes app/build.gradle.kts | 2 +- .../app/build))/cargo/.rustc_info.json | 1 - .../app/build))/cargo/CACHEDIR.TAG | 3 --- .../example/interop/TicTacToeGameBoard.java | 2 ++ .../interop/benchmark/PlayerIdsBenchmark.java | 1 + 6 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json delete mode 100644 app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG diff --git a/.DS_Store b/.DS_Store index c6f8a19e592f01bd6e790aea9ebbb39a5d560899..62b390c87c33e835c9c2ffbdf3c2afd17f62f3a8 100644 GIT binary patch delta 80 zcmZoMXfc@JFT&2iz`)4BAi$8Ela!yI17tF=PQJ*vLJ1_n%#g@Xz)+A@m#mE3H`c#&;l LgZO54j=%f>+=38! diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b3cf7d3..6ee199f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,7 +16,7 @@ repositories { // https://doc.rust-lang.org/cargo/getting-started/installation.html val osName = System.getProperty("os.name").lowercase() -val cargoBuildDir = file("${layout.buildDirectory}/cargo") +val cargoBuildDir = file("${layout.buildDirectory.get()}/cargo") val libPath = when { osName.contains("win") -> "${cargoBuildDir}/debug" diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json deleted file mode 100644 index a819320..0000000 --- a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/.rustc_info.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc_fingerprint":2030252408025272600,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/briancorbin/.rustup/toolchains/stable-aarch64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.80.0 (051478957 2024-07-21)\nbinary: rustc\ncommit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9\ncommit-date: 2024-07-21\nhost: aarch64-apple-darwin\nrelease: 1.80.0\nLLVM version: 18.1.7\n","stderr":""},"16495917692426387086":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG b/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG deleted file mode 100644 index 20d7c31..0000000 --- a/app/property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/briancorbin/Documents/GitHub/overengineering-tictactoe/app/build))/cargo/CACHEDIR.TAG +++ /dev/null @@ -1,3 +0,0 @@ -Signature: 8a477f597d28d172789f06886806bc55 -# This file is a cache directory tag created by cargo. -# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/app/src/main/java/org/example/interop/TicTacToeGameBoard.java b/app/src/main/java/org/example/interop/TicTacToeGameBoard.java index 95e4990..5a037e3 100644 --- a/app/src/main/java/org/example/interop/TicTacToeGameBoard.java +++ b/app/src/main/java/org/example/interop/TicTacToeGameBoard.java @@ -33,6 +33,8 @@ class TicTacToeGameBoard implements GameBoard { private final Map idToPlayerMarker; private final Cleaner cleaner; + + @SuppressWarnings("unused") private final Cleaner.Cleanable cleanable; private MethodHandle newGameBoard; diff --git a/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java b/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java index 0caf8d5..8229876 100644 --- a/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java +++ b/app/src/main/java/org/example/interop/benchmark/PlayerIdsBenchmark.java @@ -9,6 +9,7 @@ import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; +@SuppressWarnings("unused") public class PlayerIdsBenchmark { @Benchmark