You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2020/07/22 19:46:30 UTC
[tomcat] branch master updated: Revert "Simpler way to determine
Graal runtime"
This is an automated email from the ASF dual-hosted git repository.
fhanik 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 cb5eaa3 Revert "Simpler way to determine Graal runtime"
cb5eaa3 is described below
commit cb5eaa3925bb4649a74a3872a9fda76fc9d102b1
Author: Filip Hanik <fh...@pivotal.io>
AuthorDate: Wed Jul 22 11:43:43 2020 -0700
Revert "Simpler way to determine Graal runtime"
This reverts commit 098c4c81602ba1e8d5f33b0795d7caf55f70d573.
https://tomcat.markmail.org/search/?q=#query:%20list%3Aorg.apache.tomcat.dev+page:1+mid:7vo7ugmqjz2z7x5f+state:results
---
java/org/apache/jasper/runtime/JspRuntimeLibrary.java | 16 +++++++++++++++-
java/org/apache/naming/NamingContext.java | 15 ++++++++++++++-
java/org/apache/tomcat/util/compat/GraalCompat.java | 15 ++++++++++++++-
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index f27ce3b..cfb6e75 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -56,7 +56,21 @@ import org.apache.tomcat.InstanceManager;
*/
public class JspRuntimeLibrary {
- public static final boolean GRAAL = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+ public static final boolean GRAAL;
+
+ static {
+ boolean result = false;
+ try {
+ Class<?> nativeImageClazz = Class.forName("org.graalvm.nativeimage.ImageInfo");
+ result = nativeImageClazz.getMethod("inImageCode").invoke(null) != null;
+ // Note: This will also be true for the Graal substrate VM
+ } catch (ClassNotFoundException e) {
+ // Must be Graal
+ } catch (ReflectiveOperationException | IllegalArgumentException e) {
+ // Should never happen
+ }
+ GRAAL = result;
+ }
/**
* Returns the value of the jakarta.servlet.error.exception request
diff --git a/java/org/apache/naming/NamingContext.java b/java/org/apache/naming/NamingContext.java
index 40f4085..0471279 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -792,7 +792,20 @@ public class NamingContext implements Context {
// ------------------------------------------------------ Protected Methods
- private static final boolean GRAAL = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+ private static final boolean GRAAL;
+
+ static {
+ boolean result = false;
+ try {
+ Class<?> nativeImageClazz = Class.forName("org.graalvm.nativeimage.ImageInfo");
+ result = Boolean.TRUE.equals(nativeImageClazz.getMethod("inImageCode").invoke(null));
+ } catch (ClassNotFoundException e) {
+ // Must be Graal
+ } catch (ReflectiveOperationException | IllegalArgumentException e) {
+ // Should never happen
+ }
+ GRAAL = result;
+ }
/**
* Retrieves the named object.
diff --git a/java/org/apache/tomcat/util/compat/GraalCompat.java b/java/org/apache/tomcat/util/compat/GraalCompat.java
index e3cb09d..9fb835a 100644
--- a/java/org/apache/tomcat/util/compat/GraalCompat.java
+++ b/java/org/apache/tomcat/util/compat/GraalCompat.java
@@ -20,7 +20,20 @@ import java.io.IOException;
class GraalCompat extends Jre9Compat {
- private static final boolean GRAAL = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+ private static final boolean GRAAL;
+
+ static {
+ boolean result = false;
+ try {
+ Class<?> nativeImageClazz = Class.forName("org.graalvm.nativeimage.ImageInfo");
+ result = Boolean.TRUE.equals(nativeImageClazz.getMethod("inImageCode").invoke(null));
+ } catch (ClassNotFoundException e) {
+ // Must be Graal
+ } catch (ReflectiveOperationException | IllegalArgumentException e) {
+ // Should never happen
+ }
+ GRAAL = result;
+ }
static boolean isSupported() {
// This property does not exist for a native image
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org