Closed nhenneaux closed 6 years ago
You need to include the dependency for jetty-alpn-java-[client|server]
only when using JDK 9.
This is easily done with a Maven profile.
The jar cannot be built with JDK 8 because it uses JDK 9 specific APIs.
This means it is not possible to build a library that can be used for both versions :-( it's a big limitation.
On 9 Nov 2017 12:15 pm, "Simone Bordet" notifications@github.com wrote:
You need to include the dependency for jetty-alpn-java-[client|server] only when using JDK 9. This is easily done with a Maven profile.
The jar cannot be built with JDK 8 because it uses JDK 9 specific APIs.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jetty-project/jetty-alpn/issues/15#issuecomment-343124066, or mute the thread https://github.com/notifications/unsubscribe-auth/AJOnRiKvr5QKeANkCmfuEYzzsboW6FCjks5s0t60gaJpZM4QXufH .
Typically we have used either the jetty start.jar modules or Maven profiles to assemble the correct jars.
Unfortunately we can't make this jar a Multi release jar because it users the service loader which cannot be version Ed. Perhaps we can put a dummy java 8 version in the jar that is a noop. I've reopened to consider this.
Also you can now use conscript for ssl which has the same alpn for Java 8 and java 9.
Right Maven profile can be used but only if you directly use Jetty library not if you are building a library that uses Jetty.
What about using a condition just like the NegotiatingServerConnectionFactory
class (see https://github.com/eclipse/jetty.project/blob/jetty-9.4.x-1200/jetty-server/src/main/java/org/eclipse/jetty/server/NegotiatingServerConnectionFactory.java#L41) to determine the JVM version and use the service loader only when it is Java 9?
I managed to find a workaround but I don't think it is a recommended way.
Using Jetty 9.4.8, with the following dependencies (in this order I suppose) and build with Java 9. I just have to add alpn-boot (-Xbootclasspath/p:/path/to/alpn-boot.jar) for running with Java 8 and the modules for Java 9 (--add-modules java.activation,java.xml.bind
).
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-client</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-client</artifactId>
<version>${jetty.version}</version>
</dependency>
Yes this is the correct way.
Artifacts jetty-alpn-java-[client|server]
are built by Jetty with target JDK 9, while artifacts jetty-alpn-openjdk8-[client|server]
are built with target JDK 8.
A library may ship all artifacts, and Jetty will use the ServiceLoader
to load the right implementation at runtime, preferring jetty-alpn-openjdk8-*
when the runtime is JDK 8 and jetty-alpn-java-*
when the runtime is JDK 9.
Unfortunately you still need the bootclasspath for JDK 8 only, so it's not a completely transparent solution, as you have to change the command line depending on the JDK version.
Note that you may wish to consider using the conscrypt SSL provider with jetty. Not only is it much faster than native SSL, but it supports ALPN in both java8 and java9 without the need to modify the boot path.
https://www.eclipse.org/jetty/documentation/9.4.x/jetty-ssl-distribution.html
Documentation has also been updated for the next release: https://github.com/eclipse/jetty.project/commit/904acea9feb0d8d432a16462e696c8cb0f755124
no more warning, after I excluded JDK 9 version Alpn in Gradle
configurations.forEach {
it.exclude("org.eclipse.jetty", "jetty-alpn-java-server")
it.exclude("org.eclipse.jetty", "jetty-alpn-server")
}
I have updated my dependencies to use the following Maven dependencies to work with Java 9.
It works well with Java 9. However, it does not work with Java 8 since the classes has been compile with target 9 (see the following snippet from the pom.xml of jetty-alpn-java-server).
I got the following error using Java 8.
I use Java 8_144 and 9.0.1 with Jetty 9.4.7.
Could you build the jar with target 1.8 such that it also works with Java 8 projects?