diff graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java @ 21614:2f92172fa320

Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
author Doug Simon <doug.simon@oracle.com>
date Sun, 31 May 2015 13:42:47 +0200
parents 13f8c249edb8
children 91b861398ad6
line wrap: on
line diff
--- a/graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java	Sun May 31 12:32:15 2015 +0200
+++ b/graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java	Sun May 31 13:42:47 2015 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.nfi;
 
+import com.oracle.jvmci.service.*;
 import com.oracle.nfi.api.*;
 
 /**
@@ -31,14 +32,6 @@
     private static final NativeFunctionInterface INSTANCE;
 
     /**
-     * Creates a new {@link NativeFunctionInterface}.
-     *
-     * @throws UnsatisfiedLinkError if not running on a VM that provides a
-     *             {@link NativeFunctionInterface}
-     */
-    private static native NativeFunctionInterface createInterface();
-
-    /**
      * Gets the {@link NativeFunctionInterface} (if any) provided by the VM.
      *
      * @return null if the VM does not provide a {@link NativeFunctionInterface}
@@ -48,11 +41,11 @@
     }
 
     static {
-        NativeFunctionInterface instance;
-        try {
-            instance = createInterface();
-        } catch (UnsatisfiedLinkError e) {
-            instance = null;
+
+        NativeFunctionInterface instance = null;
+        NativeFunctionInterfaceAccess access = Services.loadSingle(NativeFunctionInterfaceAccess.class, false);
+        if (access != null) {
+            instance = access.getNativeFunctionInterface();
         }
         INSTANCE = instance;
     }