Skip to content

Commit 1d6afcc

Browse files
authored
Merge pull request #36 from hhandoko/feature/graal_21
Feature - Graal 21.0.0.2
2 parents cf91581 + 938f597 commit 1d6afcc

14 files changed

+84
-27
lines changed

.sdkmanrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
3-
java=20.2.0.r11-grl
3+
java=21.0.0.2.r11-grl

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For more information on how to this works with other frontends/backends, head ov
1515

1616
Ensure the following dependencies are installed and configured:
1717

18-
- [Java SDK] 8 or 11 or [GraalVM] 20.2.x (both Java 8 and 11 variants)
18+
- [Java SDK] 8 or 11 or [GraalVM] 21.0.x (both Java 8 and 11 variants)
1919
- [sbt] 1.5.x
2020

2121
### Setup Steps
@@ -45,6 +45,7 @@ To package and run it as an uber-jar:
4545
Ensure Graal is downloaded and its binaries folder added to `PATH`. The most convenient way is to use [sdkman] to switch between different Java SDK versions (Graal included).
4646

4747
- Run `sdk env` to initialise the shell session using [sdkman]
48+
- Run `gu install native-image` to configure the native-image binary (incl. agent)
4849

4950
To generate assisted configuration for native image:
5051

@@ -83,17 +84,16 @@ Backend API implementation:
8384

8485
Please read [PROGRESS] for more details.
8586

87+
# Notes
88+
89+
Scalameta substitutions ([svm-subs]) are copied over into the repository as the library has not had any updates for a while.
90+
8691
# Issues
8792

8893
- Native image generation sometimes fail with non-initialized charset issue error message (simply retry until succeeds)
8994
- Native image generation with `jwt-scala` fails ([oracle/graal/#1152](https://github.com/oracle/graal/issues/1152))
9095
- JWT token decoding in native image fails ([oracle/graal/#1240](https://github.com/oracle/graal/issues/1240))
9196

92-
# Pending Updates
93-
94-
- GraalVM `21.0.0.2`:
95-
- Pending `org.scalameta %% svm-subs` support
96-
9797
# Contributing
9898

9999
We follow the "[feature-branch]" Git workflow.
@@ -137,4 +137,5 @@ Please read [CONTRIBUTING] for more details.
137137
[newman]: https://github.com/postmanlabs/newman
138138
[PROGRESS]: https://github.com/hhandoko/scala-http4s-realworld-example-app/blob/master/PROGRESS.md
139139
[sbt]: https://www.scala-sbt.org/
140+
[svm-subs]: https://github.com/scalameta/svm-subs
140141
[sdkman]: https://sdkman.io/

project/Common.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ object Common {
3232
private val kindProjectorVersion = "0.11.3"
3333

3434
// Graal native-image compiler dependency versions
35-
private val graalVmVersion = "20.2.0"
36-
private val jnaVersion = "5.7.0"
35+
private val graalVmVersion = "21.0.0.2"
36+
private val jnaVersion = "5.8.0"
3737

3838
final val settings: Seq[Setting[_]] =
3939
projectSettings ++ dependencySettings ++ flywaySettings ++ compilerPlugins
@@ -62,7 +62,6 @@ object Common {
6262
"org.http4s" %% "http4s-circe" % http4sVersion,
6363
"org.http4s" %% "http4s-dsl" % http4sVersion,
6464
"org.postgresql" % "postgresql" % postgresVersion,
65-
"org.scalameta" %% "svm-subs" % graalVmVersion,
6665
"org.specs2" %% "specs2-core" % specs2Version % Test,
6766
"org.tpolecat" %% "doobie-core" % doobieVersion,
6867
"org.tpolecat" %% "doobie-h2" % doobieVersion % Test,

scripts/docker/Graal.Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM oracle/graalvm-ce:20.2.0-java11 as assembler
1+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as assembler
22
LABEL maintainer="Herdy Handoko <[email protected]>"
33
LABEL description="http4s GraalVM assembler"
44

@@ -18,7 +18,7 @@ RUN ./sbt/bin/sbt -mem 4096 clean stage
1818

1919
# ~~~~~~
2020

21-
FROM oracle/graalvm-ce:20.2.0-java11 as packager_graal
21+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as packager_graal
2222
LABEL maintainer="Herdy Handoko <[email protected]>"
2323
LABEL description="http4s GraalVM packager"
2424

@@ -33,7 +33,7 @@ RUN mkdir -p app \
3333

3434
# ~~~~~~
3535

36-
FROM oracle/graalvm-ce:20.2.0-java11
36+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2
3737
LABEL maintainer="Herdy Handoko <[email protected]>"
3838
LABEL description="http4s GraalVM (JIT) runtime container"
3939

scripts/docker/Native.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM oracle/graalvm-ce:20.2.0-java11 as assembler
1+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as assembler
22
LABEL maintainer="Herdy Handoko <[email protected]>"
33
LABEL description="http4s GraalVM assembler"
44

@@ -18,7 +18,7 @@ RUN ./sbt/bin/sbt -mem 4096 clean stage
1818

1919
# ~~~~~~
2020

21-
FROM oracle/graalvm-ce:20.2.0-java11 as packager_native
21+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as packager_native
2222
LABEL maintainer="Herdy Handoko <[email protected]>"
2323
LABEL description="http4s GraalVM native-image packager"
2424

scripts/graal/VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.2.0
1+
21.0.0.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package scala.meta.internal.svm_subs;
2+
3+
import java.util.function.Predicate;
4+
5+
final class HasReleaseFenceMethod implements Predicate<String> {
6+
@Override
7+
public boolean test(String className) {
8+
try {
9+
final Class<?> classForName = Class.forName(className);
10+
classForName.getMethod("releaseFence");
11+
return true;
12+
} catch (Exception cnfe) {
13+
return false;
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package scala.meta.internal.svm_subs;
2+
3+
import com.oracle.svm.core.annotate.Substitute;
4+
import com.oracle.svm.core.annotate.TargetClass;
5+
6+
@TargetClass(className = "scala.collection.immutable.VM", onlyWith = HasReleaseFenceMethod.class)
7+
final class Target_scala_collection_immutable_VM {
8+
9+
@Substitute
10+
public static void releaseFence() {
11+
UnsafeUtils.UNSAFE.storeFence();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package scala.meta.internal.svm_subs;
2+
3+
import com.oracle.svm.core.annotate.Substitute;
4+
import com.oracle.svm.core.annotate.TargetClass;
5+
6+
@TargetClass(className = "scala.runtime.Statics", onlyWith = HasReleaseFenceMethod.class)
7+
final class Target_scala_runtime_Statics {
8+
9+
@Substitute
10+
public static void releaseFence() {
11+
UnsafeUtils.UNSAFE.storeFence();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package scala.meta.internal.svm_subs;
2+
3+
import java.lang.reflect.Field;
4+
5+
class UnsafeUtils {
6+
static final sun.misc.Unsafe UNSAFE;
7+
static {
8+
try {
9+
Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
10+
field.setAccessible(true);
11+
UNSAFE = (sun.misc.Unsafe) field.get(null);
12+
} catch (Throwable ex) {
13+
throw new ExceptionInInitializerError(ex);
14+
}
15+
}
16+
}

src/main/resources/graal/jni-config.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
[
22
{
33
"name":"java.lang.ClassLoader",
4-
"methods":[
5-
{"name":"getPlatformClassLoader","parameterTypes":[] },
6-
{"name":"loadClass","parameterTypes":["java.lang.String"] }
7-
]
8-
},
9-
{
10-
"name":"java.lang.ClassNotFoundException"
4+
"methods":[{"name":"getPlatformClassLoader","parameterTypes":[] }]
115
},
126
{
137
"name":"java.lang.NoSuchMethodError"

src/main/resources/graal/reflect-config.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
"name":"java.lang.String[]"
118118
},
119119
{
120-
"name":"java.lang.invoke.VarHandle"
120+
"name":"java.lang.invoke.VarHandle",
121+
"methods":[{"name":"releaseFence","parameterTypes":[] }]
121122
},
122123
{
123124
"name":"java.net.NetPermission"
@@ -160,7 +161,8 @@
160161
"name":"org.postgresql.Driver"
161162
},
162163
{
163-
"name":"scala.Symbol"
164+
"name":"scala.Symbol",
165+
"methods":[{"name":"apply","parameterTypes":["java.lang.String"] }]
164166
},
165167
{
166168
"name":"scala.util.Either[]"
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"resources":[
2+
"resources":{
3+
"includes":[
34
{"pattern":"\\Qapplication.conf\\E"},
45
{"pattern":"\\Qlogback.xml\\E"},
56
{"pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"},
67
{"pattern":"\\Qreference.conf\\E"}
7-
],
8+
]},
89
"bundles":[]
910
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[
2+
]

0 commit comments

Comments
 (0)