Skip to content

Commit 38cec8c

Browse files
committed
Fixes and improvements to JPMS
1 parent eedc4b2 commit 38cec8c

2 files changed

Lines changed: 65 additions & 14 deletions

File tree

jpms-examples/README.adoc

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ You can run tests from IDE or from an application image generated by https://dev
77
An application image is generated by the https://maven.apache.org/plugins/maven-jlink-plugin/[Apache Maven JLink Plugin] when
88
packaging the project with Maven (notice the jlink package in `pom.xml`), you can find the image in `target/maven-jlink/default`
99

10-
NOTE: the `io.netty.resolver.dns.classes.macos` and `io.netty.resolver.dns.macos.osx.aarch_64` are only useful on Mac/M1
11-
1210
WARNING: Running these examples from your IDE might not work sometimes due to JPMS / IDE discrepancies. We recommend loading this Maven module `io.vertx:jpms-examples` directly in your IDE instead of `io.vertx:vertx-examples`.
1311

1412
== HTTP/1.1 Server
@@ -17,24 +15,58 @@ A simple link:src/main/java/io/vertx/example/jpms/http/Server.java[HTTP/1.1 serv
1715

1816
You can run the server in your IDE and then `curl http://localhost:8080`.
1917

20-
You can also run the application image (Mac/M1):
18+
You can also run the application image:
19+
20+
[source,shell]
21+
----
22+
./target/maven-jlink/default/bin/java --module jpms.examples/io.vertx.example.jpms.http.Server
23+
----
24+
25+
The Maven JLink plugin creates a launcher
26+
27+
[source,shell]
28+
----
29+
./target/maven-jlink/default/bin/http-server
30+
----
31+
32+
=== OSX native dns resolver
33+
34+
OSX can use an optional native DNS resolver that improves DNS resolution.
35+
36+
This is visible when running jlink with the following log:
37+
38+
```shell
39+
Mar 24, 2026 11:17:36 AM io.netty.resolver.dns.DnsServerAddressStreamProviders <clinit>
40+
WARNING: Can not find io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider in the classpath, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS. Check whether you have a dependency on 'io.netty:netty-resolver-dns-native-macos'
41+
```
42+
43+
This can be resolved by adding the following runtime option `-add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64`, here is an example for M1 architecture:
2144

2245
[source,shell]
2346
----
24-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.http.Server
47+
/target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.http.Server
2548
----
2649

50+
NOTE: you can add this to your `module-info.java` declaration and omit the `--add-modules` declaration
51+
2752
== HTTP/2 Server
2853

2954
A simple link:src/main/java/io/vertx/example/jpms/http2/Server.java[HTTP/2 server]
3055

3156
You can run the server in your IDE and then `curl -k https://localhost:8443`.
3257

33-
You can also run the application image (Mac/M1):
58+
You can also run the application image:
3459

3560
[source,shell]
3661
----
37-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.http2.Server
62+
./target/maven-jlink/default/bin/java ---module jpms.examples/io.vertx.example.jpms.http2.Server
63+
----
64+
65+
Or use the launcher:
66+
67+
[source,shell]
68+
----
69+
./target/maven-jlink/default/bin/http2-server
3870
----
3971

4072
== HTTP compression
@@ -48,11 +80,18 @@ You can test the server with:
4880
> curl -sH 'Accept-encoding: br' http://localhost:8080 | brotli -c -d
4981
----
5082

51-
You can also run the application image (Mac/M1):
83+
You can also run the application image:
5284

5385
[source,shell]
5486
----
55-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.compression.Server
87+
./target/maven-jlink/default/bin/java --module jpms.examples/io.vertx.example.jpms.compression.Server
88+
----
89+
90+
Or use the launcher:
91+
92+
[source,shell]
93+
----
94+
./target/maven-jlink/default/bin/http-server-with-compression
5695
----
5796

5897
== gRPC Service
@@ -63,14 +102,21 @@ To run this example, you need to set the env variable `TEMPORARILY_DISABLE_PROTO
63102

64103
You can run the server in your IDE and then `grpcurl -plaintext -d '{"name":"Julien"}' -proto src/main/proto/helloworld.proto localhost:8080 helloworld.Greeter/SayHello`.
65104

66-
You can also run the application image (Mac/M1):
105+
You can also run the application image:
67106

68107
[source,shell]
69108
----
70109
# Required because we use 4.26.1-jpms dependency
71-
export TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true # yes there is a typo ...
110+
export TEMORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true # yes there is a typo ...
111+
112+
./target/maven-jlink/default/bin/java --module jpms.examples/io.vertx.example.jpms.grpc.Server
113+
----
114+
115+
Or use the launcher:
72116

73-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.grpc.Server
117+
[source,shell]
118+
----
119+
./target/maven-jlink/default/bin/grpc-server
74120
----
75121

76122
== Native transports
@@ -97,7 +143,7 @@ Or launch the JVM with `--add-modules io.netty.transport.classes.kqueue,io.netty
97143

98144
[source,shell]
99145
----
100-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64,io.netty.transport.classes.kqueue,io.netty.transport.kqueue.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.native_transport.Server
146+
./target/maven-jlink/default/bin/java --add-modules io.netty.transport.classes.kqueue,io.netty.transport.kqueue.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.native_transport.Server
101147
----
102148

103149
== Open SSL
@@ -124,7 +170,7 @@ Or launch a JVM with `--add-modules io.netty.tcnative.classes.openssl,io.netty.i
124170

125171
[source,shell]
126172
----
127-
./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64,io.netty.tcnative.classes.openssl,io.netty.internal.tcnative.openssl.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.openssl.Server
173+
./target/maven-jlink/default/bin/java --add-modules io.netty.tcnative.classes.openssl,io.netty.internal.tcnative.openssl.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.openssl.Server
128174
----
129175

130176
== Sql Client

jpms-examples/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,12 @@
302302
<version>3.3.0</version>
303303
<extensions>true</extensions>
304304
<configuration>
305-
<launcher>http=jpms.examples/io.vertx.example.jpms.http.Server</launcher>
305+
<launchers>
306+
<launcher>http-server=jpms.examples/io.vertx.example.jpms.http.Server</launcher>
307+
<launcher>http2-server=jpms.examples/io.vertx.example.jpms.http2.Server</launcher>
308+
<launcher>http-server-with-compression=jpms.examples/io.vertx.example.jpms.compression.Server</launcher>
309+
<launcher>grpc-server=jpms.examples/io.vertx.example.jpms.grpc.Server</launcher>
310+
</launchers>
306311
<addModules>
307312
<addModule>jdk.jdwp.agent</addModule>
308313
<addModule>io.netty.transport.classes.${native.transport}</addModule>

0 commit comments

Comments
 (0)