Mercurial > hg > truffle
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java @ 16779:e52ad0d3b7d6
put some security sensitive actions into a privileged action
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 12 Aug 2014 00:08:19 +0200 |
parents | b7fb36e57da8 |
children | afa70d3e8159 |
comparison
equal
deleted
inserted
replaced
16778:8a05a498ab76 | 16779:e52ad0d3b7d6 |
---|---|
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.security.*; | |
28 | |
27 import com.oracle.truffle.api.impl.*; | 29 import com.oracle.truffle.api.impl.*; |
28 | 30 |
29 /** | 31 /** |
30 * Class for obtaining the Truffle runtime singleton object of this virtual machine. | 32 * Class for obtaining the Truffle runtime singleton object of this virtual machine. |
31 */ | 33 */ |
32 public class Truffle { | 34 public class Truffle { |
33 | 35 |
34 private static final TruffleRuntime RUNTIME; | 36 private static final TruffleRuntime RUNTIME = initRuntime(); |
35 | 37 |
36 /** | 38 /** |
37 * Creates a new {@link TruffleRuntime} instance if the runtime has a specialized | 39 * Creates a new {@link TruffleRuntime} instance if the runtime has a specialized |
38 * implementation. | 40 * implementation. |
39 * | 41 * |
44 | 46 |
45 public static TruffleRuntime getRuntime() { | 47 public static TruffleRuntime getRuntime() { |
46 return RUNTIME; | 48 return RUNTIME; |
47 } | 49 } |
48 | 50 |
49 static { | 51 private static TruffleRuntime initRuntime() { |
50 TruffleRuntime runtime; | |
51 try { | 52 try { |
52 runtime = createRuntime(); | 53 return AccessController.doPrivileged(new PrivilegedAction<TruffleRuntime>() { |
54 public TruffleRuntime run() { | |
55 return createRuntime(); | |
56 } | |
57 }); | |
53 } catch (UnsatisfiedLinkError e) { | 58 } catch (UnsatisfiedLinkError e) { |
54 runtime = new DefaultTruffleRuntime(); | 59 return new DefaultTruffleRuntime(); |
55 } | 60 } |
56 RUNTIME = runtime; | |
57 } | 61 } |
58 } | 62 } |