Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.nfi/src/com/oracle/nfi/NativeFunctionInterfaceRuntime.java @ 21894:91b861398ad6
removed dependency from NFI to JVMCI
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 10 Jun 2015 16:10:26 +0200 |
parents | 2f92172fa320 |
children | 3e7ab72bac96 |
comparison
equal
deleted
inserted
replaced
21893:db885c930362 | 21894:91b861398ad6 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.nfi; | 23 package com.oracle.nfi; |
24 | 24 |
25 import com.oracle.jvmci.service.*; | 25 import java.lang.reflect.*; |
26 | |
26 import com.oracle.nfi.api.*; | 27 import com.oracle.nfi.api.*; |
27 | 28 |
28 /** | 29 /** |
29 * Class for obtaining the {@link NativeFunctionInterface} (if any) provided by the VM. | 30 * Class for obtaining the {@link NativeFunctionInterface} (if any) provided by the VM. |
30 */ | 31 */ |
41 } | 42 } |
42 | 43 |
43 static { | 44 static { |
44 | 45 |
45 NativeFunctionInterface instance = null; | 46 NativeFunctionInterface instance = null; |
46 NativeFunctionInterfaceAccess access = Services.loadSingle(NativeFunctionInterfaceAccess.class, false); | 47 |
48 NativeFunctionInterfaceAccess access = null; | |
49 Class<?> servicesClass = null; | |
50 try { | |
51 servicesClass = Class.forName("com.oracle.jvmci.service.Services"); | |
52 } catch (ClassNotFoundException e) { | |
53 // JVMCI is unavailable | |
54 } | |
55 if (servicesClass != null) { | |
56 try { | |
57 Method m = servicesClass.getDeclaredMethod("loadSingle", Class.class, boolean.class); | |
58 access = (NativeFunctionInterfaceAccess) m.invoke(null, NativeFunctionInterfaceAccess.class, false); | |
59 } catch (Throwable e) { | |
60 // Fail fast for other errors | |
61 throw (InternalError) new InternalError().initCause(e); | |
62 } | |
63 } | |
64 // TODO: try standard ServiceLoader? | |
47 if (access != null) { | 65 if (access != null) { |
48 instance = access.getNativeFunctionInterface(); | 66 instance = access.getNativeFunctionInterface(); |
49 } | 67 } |
50 INSTANCE = instance; | 68 INSTANCE = instance; |
51 } | 69 } |