comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java @ 21887:543f150e7fa0

com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 22:44:34 +0200
parents ffe693cc427f
children 0a6e10379b9b
comparison
equal deleted inserted replaced
21886:b1234c06ea49 21887:543f150e7fa0
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api; 25 package com.oracle.truffle.api;
26 26
27 import java.lang.reflect.*;
27 import java.security.*; 28 import java.security.*;
28 29
29 import com.oracle.jvmci.service.*;
30 import com.oracle.truffle.api.impl.*; 30 import com.oracle.truffle.api.impl.*;
31 31
32 /** 32 /**
33 * Class for obtaining the Truffle runtime singleton object of this virtual machine. 33 * Class for obtaining the Truffle runtime singleton object of this virtual machine.
34 */ 34 */
53 } 53 }
54 54
55 return AccessController.doPrivileged(new PrivilegedAction<TruffleRuntime>() { 55 return AccessController.doPrivileged(new PrivilegedAction<TruffleRuntime>() {
56 public TruffleRuntime run() { 56 public TruffleRuntime run() {
57 TruffleRuntimeAccess access = null; 57 TruffleRuntimeAccess access = null;
58 Class<?> servicesClass = null;
58 try { 59 try {
59 access = Services.loadSingle(TruffleRuntimeAccess.class, false); 60 servicesClass = Class.forName("com.oracle.jvmci.service.Services");
60 } catch (NoClassDefFoundError e) { 61 } catch (ClassNotFoundException e) {
61 // JVMCI is unavailable 62 // JVMCI is unavailable
62 } 63 }
64 if (servicesClass != null) {
65 try {
66 Method m = servicesClass.getDeclaredMethod("loadSingle", Class.class, boolean.class);
67 access = (TruffleRuntimeAccess) m.invoke(null, TruffleRuntimeAccess.class, false);
68 } catch (Throwable e) {
69 // Fail fast for other errors
70 throw (InternalError) new InternalError().initCause(e);
71 }
72 }
73 // TODO: try standard ServiceLoader?
63 if (access != null) { 74 if (access != null) {
64 return access.getRuntime(); 75 return access.getRuntime();
65 } 76 }
66 return new DefaultTruffleRuntime(); 77 return new DefaultTruffleRuntime();
67 } 78 }