61
61
import static com .oracle .truffle .api .CompilerDirectives .injectBranchProbability ;
62
62
import static com .oracle .truffle .api .CompilerDirectives .shouldNotReachHere ;
63
63
64
- import java .lang .reflect .Field ;
65
64
import java .util .ArrayList ;
66
65
import java .util .Arrays ;
67
66
import java .util .List ;
@@ -132,24 +131,10 @@ public final class NFIPosixSupport extends PosixSupport {
132
131
133
132
private static final TruffleLogger LOGGER = PythonLanguage .getLogger (NFIPosixSupport .class );
134
133
135
- private static final Unsafe UNSAFE = initUnsafe ();
134
+ private static final Unsafe UNSAFE = PythonUtils . initUnsafe ();
136
135
137
136
private static final Object CRYPT_LOCK = new Object ();
138
137
139
- private static Unsafe initUnsafe () {
140
- try {
141
- return Unsafe .getUnsafe ();
142
- } catch (SecurityException se ) {
143
- try {
144
- Field theUnsafe = Unsafe .class .getDeclaredField ("theUnsafe" );
145
- theUnsafe .setAccessible (true );
146
- return (Unsafe ) theUnsafe .get (Unsafe .class );
147
- } catch (Exception e ) {
148
- throw new UnsupportedOperationException ("Cannot initialize Unsafe for the native POSIX backend" , e );
149
- }
150
- }
151
- }
152
-
153
138
private enum PosixNativeFunction {
154
139
get_errno ("():sint32" ),
155
140
set_errno ("(sint32):void" ),
@@ -1666,7 +1651,7 @@ private String gai_strerror(int errorCode,
1666
1651
* Provides access to {@code struct addrinfo}.
1667
1652
*
1668
1653
* The layout of native {@code struct addrinfo} is as follows:
1669
- *
1654
+ *
1670
1655
* <pre>
1671
1656
* {@code
1672
1657
* struct addrinfo {
@@ -1681,7 +1666,7 @@ private String gai_strerror(int errorCode,
1681
1666
* };
1682
1667
* }
1683
1668
* </pre>
1684
- *
1669
+ *
1685
1670
* To avoid multiple NFI calls, we transfer the data in batch using arrays of {@code int}s and
1686
1671
* {@code long}s - int values are stored in {@code intData}, the {@code ai_canonname} and
1687
1672
* {@code ai_next} pointers are stored in {@code longData} and the socket address pointed to by
0 commit comments