Mercurial > hg > graal-jvmci-8
changeset 5522:1319b704541d
Return GraalRuntime with no capabilities if VM does not support creation of GraalRuntime instance.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 08 Jun 2012 16:07:32 +0200 |
parents | 13321732f85c |
children | 861f8d5a5153 |
files | graal/com.oracle.graal.api/src/com/oracle/graal/api/Graal.java |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api/src/com/oracle/graal/api/Graal.java Fri Jun 08 15:42:16 2012 +0200 +++ b/graal/com.oracle.graal.api/src/com/oracle/graal/api/Graal.java Fri Jun 08 16:07:32 2012 +0200 @@ -25,8 +25,7 @@ public class Graal { - private static GraalRuntime runtime; - private static volatile boolean initialized; + private static volatile GraalRuntime runtime; private static native GraalRuntime initializeRuntime(); @@ -35,21 +34,25 @@ return runtime; } - public static boolean hasRuntime() { - return getRuntime() != null; - } - private static void ensureInitialized() { - boolean wasInitialized = initialized; - if (!wasInitialized) { + GraalRuntime oldValue = runtime; + if (oldValue == null) { synchronized (Graal.class) { - if (!initialized) { + if (runtime == null) { try { runtime = initializeRuntime(); } catch (UnsatisfiedLinkError e) { - runtime = null; + runtime = new GraalRuntime() { + @Override + public String getName() { + return ""; + } + @Override + public <T> T getCapability(Class<T> clazz) { + return null; + } + }; } - initialized = true; } } }