You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2019/05/07 19:00:18 UTC
[tomcat] branch master updated: Use the Graal API
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new e6c8f8a Use the Graal API
e6c8f8a is described below
commit e6c8f8ac932750f05a767084b85b11b4b8a5f490
Author: remm <re...@apache.org>
AuthorDate: Tue May 7 21:00:01 2019 +0200
Use the Graal API
Also update instructions.
---
java/org/apache/tomcat/util/compat/GraalCompat.java | 12 ++++++++++--
res/tomcat-maven/README.md | 8 +++++---
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/tomcat/util/compat/GraalCompat.java b/java/org/apache/tomcat/util/compat/GraalCompat.java
index f6a7fce..f6636c7 100644
--- a/java/org/apache/tomcat/util/compat/GraalCompat.java
+++ b/java/org/apache/tomcat/util/compat/GraalCompat.java
@@ -23,8 +23,16 @@ class GraalCompat extends JreCompat {
private static final boolean GRAAL;
static {
- String runtime = System.getProperty("java.runtime.version");
- GRAAL = (runtime != null && (runtime.indexOf(".buildslave.jdk8u") != -1));
+ boolean result = false;
+ try {
+ Class<?> nativeImageClazz = Class.forName("org.graalvm.nativeimage");
+ result = (nativeImageClazz.getMethod("inImageCode").invoke(null) == Boolean.TRUE);
+ } catch (ClassNotFoundException e) {
+ // Must be Java 8
+ } catch (ReflectiveOperationException | IllegalArgumentException e) {
+ // Should never happen
+ }
+ GRAAL = result;
}
diff --git a/res/tomcat-maven/README.md b/res/tomcat-maven/README.md
index 12389a2..095c3fd 100644
--- a/res/tomcat-maven/README.md
+++ b/res/tomcat-maven/README.md
@@ -96,7 +96,9 @@ Then exercise necessary paths of your service with the Tomcat configuration.
Generate the final json using native-image-configuration then use native image using the generated reflection metadata.
```
-cd target
-$JAVA_HOME/jre/tools/native-image-configure/native-image-configure generate --trace-input=trace-file.json --output-dir=.
-$JAVA_HOME/bin/native-image -H:+ReportUnsupportedElementsAtRuntime -H:ConfigurationFileDirectories=./ -H:ReflectionConfigurationFiles=../tomcat-reflection.json -jar tomcat-maven-1.0.jar
+$JAVA_HOME/jre/tools/native-image-configure/native-image-configure generate --trace-input=./target/trace-file.json --output-dir=./target
+$JAVA_HOME/bin/native-image -H:+ReportUnsupportedElementsAtRuntime -H:ConfigurationFileDirectories=./target/ -H:ReflectionConfigurationFiles=./tomcat-reflection.json -jar target/tomcat-maven-1.0.jar
+./tomcat-maven-1.0 -Dcatalina.base=. -Djava.util.logging.config.file=conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
```
+Note: -H:ConfigurationFileDirectories does not appear to work properly, so it could be needed to add the content of reflect-config.json
+ to tomcat-reflection.json.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org