Skip to content

Commit

Permalink
chore: java 23-ea support
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshg committed Dec 11, 2023
1 parent 80837ec commit 9b76d96
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 47 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

```bash
$ curl -s "https://get.sdkman.io" | bash
$ sdk i java openjdk-ea-22
$ sdk i java openjdk-ea-23
```

#### Build
Expand Down Expand Up @@ -59,7 +59,7 @@ $ docker run \
--publish 8000:8000 \
--name openjdk-playground \
--mount type=bind,source=$(pwd),destination=/app,readonly \
openjdk:22-slim /bin/bash -c "./build/openjdk-playground && printenv && jwebserver -b 0.0.0.0 -p 8000 -d /"
openjdk:23-slim /bin/bash -c "./build/openjdk-playground && printenv && jwebserver -b 0.0.0.0 -p 8000 -d /"

# Download the JFR files
$ wget http://localhost:8000/tmp/openjdk-playground.jfr
Expand Down Expand Up @@ -166,7 +166,7 @@ $ ./gradlew -q javaToolchains

[java_url]: https://jdk.java.net/

[java_img]: https://img.shields.io/badge/OpenJDK-22--ea-ea791d?logo=java&logoColor=ea791d
[java_img]: https://img.shields.io/badge/OpenJDK-23--ea-ea791d?logo=java&logoColor=ea791d

[kt_url]: https://github.com/JetBrains/kotlin/releases/latest

Expand Down
4 changes: 2 additions & 2 deletions docs/Writerside/topics/Containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $ docker pull cgr.dev/chainguard/jdk:latest

# Openjdk
# https://github.com/docker-library/openjdk
$ docker pull openjdk:22-slim
$ docker pull openjdk:22-jdk-oracle
$ docker pull openjdk:23-slim
$ docker pull openjdk:23-jdk-oracle
$ docker pull openjdk:19-alpine

# Eclipse Temurin
Expand Down
16 changes: 8 additions & 8 deletions docs/Writerside/topics/OpenJDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $ mkdir -p src/{main,test}/{java,resources}
##### 2. Preview features

```bash
$ javac --enable-preview -release 22 Foo.java
$ javac --enable-preview -release 23 Foo.java
$ java --enable-preview Foo
```

Expand Down Expand Up @@ -179,10 +179,10 @@ $ jlink --list-plugins
$ jdeps --generate-module-info ./ app.jar

# List all deprecated APIs for a release
$ jdeprscan --for-removal --release 22 --list
$ jdeprscan --for-removal --release 23 --list

# Scan deprecated APIs
$ jdeprscan --for-removal --release 22 app.jar
$ jdeprscan --for-removal --release 23 app.jar
```

- [Java EE Maven artifacts](https://openjdk.java.net/jeps/320)
Expand All @@ -195,7 +195,7 @@ $ java -m jdk.httpserver -b 127.0.0.1

# Compile all modules at once (Start from the main module)
$ javac --enable-preview \
--release 22 \
--release 23 \
-parameters \ // Optional, Generate metadata for reflection on method parameters
--add-modules ALL-MODULE-PATH \ // Optional, Root modules to resolve in addition to the initial modules
--module-path ... \ // Optional, where to find application modules
Expand All @@ -222,12 +222,12 @@ $ native-image \
-p base-module.jar:main-module.jar \
-m dev.suresh.Main

# JavaFX 22 using jlink & jpackage
# JavaFX 23 using jlink & jpackage
$ wget "https://download.java.net/java/early_access/.../openjfx-xxx_macos-aarch64_bin-jmods.tar.gz"
$ tar -xvzf openjfx-xxx_macos-aarch64_bin-jmods.tar.gz

$ jlink --output javafx-jdk \
--module-path $JAVA_HOME/jmods:javafx-jmods-22 \
--module-path $JAVA_HOME/jmods:javafx-jmods-23 \
--add-modules javafx.controls,java.desktop,java.logging
# --add-modules ALL-MODULE-PATH

Expand Down Expand Up @@ -908,7 +908,7 @@ $ mvn archetype:generate -DgroupId=dev.suresh -DartifactId=my-app -DarchetypeArt
### [OpenJDK Build](https://openjdk.java.net/groups/build/doc/building.html)
```bash
$ sdk install java 22-open
$ sdk install java 23-open
$ git clone https://github.com/openjdk/jdk.git
$ cd jdk
# $ make clean
Expand All @@ -932,7 +932,7 @@ $ sudo yum upgrade -y
$ sudo yum install curl wget tree docker git zsh -y
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
$ curl -s "https://get.sdkman.io" | bash
$ sdk i java 22.ea-open
$ sdk i java 23.ea-open

# For Github self hosted runners on Aarch64
export LD_LIBRARY_PATH=/opt/oracle/oracle-armtoolset-8/root/usr/lib64:/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
java = "22"
java = "23"
kotlin = "2.0.0-Beta1"
kotlin-ksp = "2.0.0-Beta1-1.0.15"
kotlin-jvmtarget = "21"
Expand Down
29 changes: 14 additions & 15 deletions script.main.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env -S kotlin -Xplugin=/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-serialization-compiler-plugin.jar

// @file:Repository("https://maven.google.com")
@file:DependsOn("io.ktor:ktor-client-core:2.3.3")
@file:DependsOn("io.ktor:ktor-client-cio:2.3.3")
@file:DependsOn("io.ktor:ktor-client-java:2.3.3")
@file:DependsOn("io.ktor:ktor-client-auth:2.3.3")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0-RC")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
@file:DependsOn("org.slf4j:slf4j-simple:2.0.7")
@file:DependsOn("com.microsoft.playwright:playwright:1.36.0")
@file:DependsOn("io.ktor:ktor-client-core:2.3.7")
@file:DependsOn("io.ktor:ktor-client-cio:2.3.7")
@file:DependsOn("io.ktor:ktor-client-java:2.3.7")
@file:DependsOn("io.ktor:ktor-client-auth:2.3.7")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
@file:DependsOn("org.slf4j:slf4j-simple:2.0.9")
@file:DependsOn("com.microsoft.playwright:playwright:1.40.0")
// @file:Import("common.main.kts")

@file:CompilerOptions("-jvm-target", "1.8")
Expand All @@ -19,17 +18,19 @@ import kotlinx.coroutines.*
import kotlinx.serialization.*
import kotlinx.serialization.json.*

@Serializable
data class Lang(val name: String, val version: String)
@Serializable data class Lang(val name: String, val version: String)

val arg = args.firstOrNull() ?: "Kotlin"

println("Hello $arg!")

val serialized = Json.encodeToString(Lang("Kotlin", KotlinVersion.CURRENT.toString()))

println(serialized)

val javaVer: String = System.getProperty("java.version")
val deserialized = Json.decodeFromString<Lang>("""{"name" : "Java", "version": "$javaVer"}""")

println(deserialized)

runBlocking {
Expand All @@ -43,9 +44,7 @@ fun recordBrowser() {

fun playbackBrowser() {
Playwright.create().use { playwright ->
val browser = playwright.chromium().launch(
BrowserType.LaunchOptions().setHeadless(true)
)
val browser = playwright.chromium().launch(BrowserType.LaunchOptions().setHeadless(true))

browser.newContext().newPage().apply {
navigate("https://www.google.com/search?q=kotlinlang&oq=kotlinlang")
Expand Down
5 changes: 5 additions & 0 deletions scripts/JavaSingleFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env java --enable-preview --source 23

void main() {
System.out.println(STR."Hello Java \{System.getProperty("java.version")}");
}
8 changes: 0 additions & 8 deletions scripts/java-single-file

This file was deleted.

17 changes: 8 additions & 9 deletions scripts/jrtserver
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/env java --enable-preview --source 22
#!/usr/bin/env java --enable-preview --source 23

import com.sun.net.httpserver.SimpleFileServer;
import com.sun.net.httpserver.SimpleFileServer.OutputLevel;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.file.FileSystems;

public class Main {

void main() {
void main() {
var jrtFS = FileSystems.getFileSystem(URI.create("jrt:/"));
// Paths.get(URI.create("jrt:/"))
var modules = jrtFS.getPath("/modules");
var fileServer = SimpleFileServer.createFileServer(new InetSocketAddress(8080), modules,
OutputLevel.VERBOSE);
System.out.println("Visit http://localhost:8080/ to see the file server!");
var fileServer = SimpleFileServer.createFileServer(
new InetSocketAddress(8080),
modules,
OutputLevel.VERBOSE);
System.out.println(STR."Visit http://localhost:\{fileServer.getAddress().getPort()}/ to see the file server!");
fileServer.start();
}
}
}
2 changes: 1 addition & 1 deletion scripts/openjdk-ea.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# set -u won't work for sdkman
set -e

jdk_version=${1:-22}
jdk_version=${1:-23}

# Find OS type
case "$OSTYPE" in
Expand Down

0 comments on commit 9b76d96

Please sign in to comment.