Issue #5492 - Changing from "java.feature.*" to "runtime.feature.*"

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2021-02-15 13:09:24 -06:00
parent de5b8bc84a
commit 1b15c1e4a3
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 31 additions and 4 deletions

View File

@ -5,7 +5,7 @@ Enables the ALPN (Application Layer Protocol Negotiation) TLS extension.
[depend]
ssl
alpn-impl/alpn-available-${java.feature.alpn}
alpn-impl/alpn-available-${runtime.feature.alpn}
[lib]
lib/jetty-alpn-client-${jetty.version}.jar

View File

@ -1507,9 +1507,10 @@ public class StartArgs
properties.setProperty("java.version.platform", Integer.toString(ver.getPlatform()), source);
// features built into java.
properties.setProperty("java.feature.alpn", Boolean.toString(ver.getPlatform() >= 9), source);
properties.setProperty("java.feature.jpms", Boolean.toString(ver.getPlatform() >= 9), source);
properties.setProperty("java.feature.loom", Boolean.toString(ver.getPlatform() >= 16), source);
// TODO: Remove in Jetty 10+
properties.setProperty("runtime.feature.alpn", Boolean.toString(isMethodAvailable(javax.net.ssl.SSLParameters.class, "getApplicationProtocols", null)), source);
// TODO: Remove in Jetty 10+
properties.setProperty("runtime.feature.jpms", Boolean.toString(isClassAvailable("java.lang.ModuleLayer")), source);
// @deprecated - below will be removed in Jetty 10.x
properties.setProperty("java.version.major", Integer.toString(ver.getMajor()), "Deprecated");
@ -1531,6 +1532,32 @@ public class StartArgs
}
}
private boolean isMethodAvailable(Class<?> clazz, String methodName, Class<?>[] params)
{
try
{
clazz.getMethod(methodName, params);
return true;
}
catch (NoSuchMethodException e)
{
return false;
}
}
private boolean isClassAvailable(String clazzname)
{
try
{
Class.forName(clazzname, false, this.getClass().getClassLoader());
return true;
}
catch (ClassNotFoundException e)
{
return false;
}
}
public void setRun(boolean run)
{
this.run = run;