# HG changeset patch # User Doug Simon # Date 1433945426 -7200 # Node ID 91b861398ad60733b663baf885362bdd69b3e018 # Parent db885c930362b0e545c61f56e64458da3a1775c5 removed dependency from NFI to JVMCI diff -r db885c930362 -r 91b861398ad6 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterfaceAccess.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterfaceAccess.java Wed Jun 10 12:07:31 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterfaceAccess.java Wed Jun 10 16:10:26 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.nfi.api.*; @ServiceProvider(NativeFunctionInterfaceAccess.class) -public class HotSpotNativeFunctionInterfaceAccess implements NativeFunctionInterfaceAccess { +public class HotSpotNativeFunctionInterfaceAccess implements NativeFunctionInterfaceAccess, Service { private final NativeFunctionInterface instance = HotSpotTruffleRuntime.createNativeFunctionInterface(); public NativeFunctionInterface getNativeFunctionInterface() { diff -r db885c930362 -r 91b861398ad6 graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java --- a/graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java Wed Jun 10 12:07:31 2015 +0200 +++ b/graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java Wed Jun 10 16:10:26 2015 +0200 @@ -22,7 +22,8 @@ */ package com.oracle.nfi; -import com.oracle.jvmci.service.*; +import java.lang.reflect.*; + import com.oracle.nfi.api.*; /** @@ -43,7 +44,24 @@ static { NativeFunctionInterface instance = null; - NativeFunctionInterfaceAccess access = Services.loadSingle(NativeFunctionInterfaceAccess.class, false); + + NativeFunctionInterfaceAccess access = null; + Class servicesClass = null; + try { + servicesClass = Class.forName("com.oracle.jvmci.service.Services"); + } catch (ClassNotFoundException e) { + // JVMCI is unavailable + } + if (servicesClass != null) { + try { + Method m = servicesClass.getDeclaredMethod("loadSingle", Class.class, boolean.class); + access = (NativeFunctionInterfaceAccess) m.invoke(null, NativeFunctionInterfaceAccess.class, false); + } catch (Throwable e) { + // Fail fast for other errors + throw (InternalError) new InternalError().initCause(e); + } + } + // TODO: try standard ServiceLoader? if (access != null) { instance = access.getNativeFunctionInterface(); } diff -r db885c930362 -r 91b861398ad6 graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterface.java --- a/graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterface.java Wed Jun 10 12:07:31 2015 +0200 +++ b/graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterface.java Wed Jun 10 16:10:26 2015 +0200 @@ -22,14 +22,12 @@ */ package com.oracle.nfi.api; -import com.oracle.jvmci.service.*; - /** * Interface to get a {@linkplain NativeFunctionHandle handle} or {@linkplain NativeFunctionPointer * pointer} to a native function or a {@linkplain NativeLibraryHandle handle} to an open native * library. */ -public interface NativeFunctionInterface extends Service { +public interface NativeFunctionInterface { /** * Resolves and returns a handle to an open native library. This method will open the library diff -r db885c930362 -r 91b861398ad6 graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterfaceAccess.java --- a/graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterfaceAccess.java Wed Jun 10 12:07:31 2015 +0200 +++ b/graal/com.oracle.nfi/src/com/oracle/nfi/api/NativeFunctionInterfaceAccess.java Wed Jun 10 16:10:26 2015 +0200 @@ -22,13 +22,10 @@ */ package com.oracle.nfi.api; -import com.oracle.jvmci.service.*; - /** - * A {@linkplain Service JVMCI service} that provides access to a {@link NativeFunctionInterface} - * implementation. + * A service that provides access to a {@link NativeFunctionInterface} implementation. */ -public interface NativeFunctionInterfaceAccess extends Service { +public interface NativeFunctionInterfaceAccess { /** * Gets the {@link NativeFunctionInterface} implementation available via this access object. diff -r db885c930362 -r 91b861398ad6 mx/suite.py --- a/mx/suite.py Wed Jun 10 12:07:31 2015 +0200 +++ b/mx/suite.py Wed Jun 10 16:10:26 2015 +0200 @@ -398,7 +398,6 @@ "com.oracle.nfi" : { "subDir" : "graal", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.jvmci.service"], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.7", }, @@ -1359,6 +1358,7 @@ ], "exclude" : ["FINDBUGS"], "distDependencies" : [ + "JVMCI_SERVICE", "JVMCI_HOTSPOT", "TRUFFLE", ], @@ -1375,9 +1375,6 @@ "com.oracle.truffle.object.basic", "com.oracle.truffle.tools" ], - "distDependencies" : [ - "JVMCI_SERVICE", - ], }, "GRAAL_TRUFFLE" : {