IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Java.Externs.sun.misc.Unsafe Class Reference

Static Public Member Functions

static void registerNatives ()
 Implementation of native method 'registerNatives'.
 
static object getObject (object self, object o, long offset)
 Implementation of native method 'getObject'.
 
static void putObject (object self, object o, long offset, object x)
 Implementation of native method 'putObject'.
 
static bool getBoolean (object self, object o, long offset)
 Implementation of native method 'getBoolean'.
 
static void putBoolean (object self, object o, long offset, bool x)
 Implementation of native method 'putBoolean'.
 
static byte getByte (object self, object o, long offset)
 Implementation of native method 'getByte'.
 
static void putByte (object self, object o, long offset, byte x)
 Implementation of native method 'putByte'.
 
static short getShort (object self, object o, long offset)
 Implementation of native method 'getShort'.
 
static void putShort (object self, object o, long offset, short x)
 Implementation of native method 'putShort'.
 
static char getChar (object self, object o, long offset)
 Implementation of native method 'getChar'.
 
static void putChar (object self, object o, long offset, char x)
 Implementation of native method 'putChar'.
 
static int getInt (object self, object o, long offset)
 Implementation of native method 'getInt'.
 
static void putInt (object self, object o, long offset, int x)
 Implementation of native method 'putInt'.
 
static long getLong (object self, object o, long offset)
 Implementation of native method 'getLong'.
 
static void putLong (object self, object o, long offset, long x)
 Implementation of native method 'putLong'.
 
static float getFloat (object self, object o, long offset)
 Implementation of native method 'getFloat'.
 
static void putFloat (object self, object o, long offset, float x)
 Implementation of native method 'putFloat'.
 
static double getDouble (object self, object o, long offset)
 Implementation of native method 'getDouble'.
 
static void putDouble (object self, object o, long offset, double x)
 Implementation of native method 'putDouble'.
 
static byte getByte (object self, long address)
 Implementation of native method 'getByte'.
 
static void putByte (object self, long address, byte x)
 Implementation of native method 'putByte'.
 
static short getShort (object self, long address)
 Implementation of native method 'getShort'.
 
static void putShort (object self, long address, short x)
 Implementation of native method 'putShort'.
 
static char getChar (object self, long address)
 Implementation of native method 'getChar'.
 
static void putChar (object self, long address, char x)
 Implementation of native method 'putChar'.
 
static int getInt (object self, long address)
 Implementation of native method 'getInt'.
 
static void putInt (object self, long address, int x)
 Implementation of native method 'putInt'.
 
static long getLong (object self, long address)
 Implementation of native method 'getLong'.
 
static void putLong (object self, long address, long x)
 Implementation of native method 'putLong'.
 
static float getFloat (object self, long address)
 Implementation of native method 'getFloat'.
 
static void putFloat (object self, long address, float x)
 Implementation of native method 'putFloat'.
 
static double getDouble (object self, long address)
 Implementation of native method 'getDouble'.
 
static void putDouble (object self, long address, double x)
 Implementation of native method 'putDouble'.
 
static long getAddress (object self, long address)
 Implementation of native method 'getAddress'.
 
static void putAddress (object self, long address, long x)
 Implementation of native method 'putAddress'.
 
static unsafe long allocateMemory (object self, long bytes)
 Implementation of native method 'allocateMemory'.
 
static unsafe long reallocateMemory (object self, long address, long bytes)
 Implementation of native method 'reallocateMemory'.
 
static unsafe void setMemory (object self, object o, long offset, long bytes, byte value)
 Implementation of native method 'setMemory'.
 
static unsafe void copyMemory (object self, object srcBase, long srcOffset, object destBase, long destOffset, long bytes)
 Implementation of native method 'copyMemory'.
 
static unsafe void freeMemory (object self, long address)
 Implementation of native method 'freeMemory'.
 
static object staticFieldBase (object self, global::java.lang.reflect.Field f)
 Implementation of native method 'staticFieldBase'.
 
static long staticFieldOffset (object self, global::java.lang.reflect.Field f)
 Implementation of native method 'staticFieldOffset'.
 
static long objectFieldOffset (object self, global::java.lang.reflect.Field f)
 Implementation of native method 'objectFieldOffset'.
 
static bool shouldBeInitialized (object self, global::java.lang.Class c)
 Implementation of native method 'shouldBeInitialized'.
 
static void ensureClassInitialized (object self, global::java.lang.Class c)
 Implementation of native method 'ensureClassInitialized'.
 
static int arrayBaseOffset (object self, global::java.lang.Class arrayClass)
 Implementation of native method 'arrayBaseOffset'.
 
static int arrayIndexScale (object self, global::java.lang.Class arrayClass)
 Implementation of native method 'arrayIndexScale'.
 
static int addressSize (object self)
 Implementation of native method 'addressSize'.
 
static int pageSize (object self)
 Implementation of native method 'pageSize'.
 
static global::java.lang.Class defineClass (object self, string name, byte[] b, int off, int len, global::java.lang.ClassLoader loader, global::java.security.ProtectionDomain protectionDomain)
 Implementation of native method 'defineClass'.
 
static global::java.lang.Class defineAnonymousClass (object self, global::java.lang.Class hostClass, byte[] data, object[] cpPatches)
 Implementation of native method 'defineAnonymousClass'.
 
static object allocateInstance (object self, global::java.lang.Class cls)
 Implementation of native method 'allocateInstance'.
 
static void monitorEnter (object self, object o)
 Implementation of native method 'monitorEnter'.
 
static void monitorExit (object self, object o)
 Implementation of native method 'monitorExit'.
 
static bool tryMonitorEnter (object self, object o)
 Implementation of native method 'tryMonitorEnter'.
 
static void throwException (object self, Exception ee)
 Implementation of native method 'throwException'.
 
static object getObjectVolatile (object self, object o, long offset)
 Implementation of native method 'getObjectVolatile'.
 
static void putObjectVolatile (object self, object o, long offset, object x)
 Implementation of native method 'putObjectVolatile'.
 
static unsafe int getIntVolatile (object self, object o, long offset)
 Implementation of native method 'getIntVolatile'.
 
static unsafe void putIntVolatile (object self, object o, long offset, int x)
 Implementation of native method 'putIntVolatile'.
 
static unsafe bool getBooleanVolatile (object self, object o, long offset)
 Implementation of native method 'getBooleanVolatile'.
 
static unsafe void putBooleanVolatile (object self, object o, long offset, bool x)
 Implementation of native method 'putBooleanVolatile'.
 
static unsafe byte getByteVolatile (object self, object o, long offset)
 Implementation of native method 'getByteVolatile'.
 
static unsafe void putByteVolatile (object self, object o, long offset, byte x)
 Implementation of native method 'putByteVolatile'.
 
static short getShortVolatile (object self, object o, long offset)
 Implementation of native method 'getShortVolatile'.
 
static unsafe void putShortVolatile (object self, object o, long offset, short x)
 Implementation of native method 'putShortVolatile'.
 
static char getCharVolatile (object self, object o, long offset)
 Implementation of native method 'getCharVolatile'.
 
static unsafe void putCharVolatile (object self, object o, long offset, char x)
 Implementation of native method 'putCharVolatile'.
 
static long getLongVolatile (object self, object o, long offset)
 Implementation of native method 'getLongVolatile'.
 
static unsafe void putLongVolatile (object self, object o, long offset, long x)
 Implementation of native method 'putLongVolatile'.
 
static float getFloatVolatile (object self, object o, long offset)
 Implementation of native method 'getFloatVolatile'.
 
static unsafe void putFloatVolatile (object self, object o, long offset, float x)
 Implementation of native method 'putFloatVolatile'.
 
static double getDoubleVolatile (object self, object o, long offset)
 Implementation of native method 'getDoubleVolatile'.
 
static unsafe void putDoubleVolatile (object self, object o, long offset, double x)
 Implementation of native method 'putDoubleVolatile'.
 
static void putOrderedObject (object self, object o, long offset, object x)
 
static void putOrderedInt (object self, object o, long offset, int x)
 
static void putOrderedLong (object self, object o, long offset, long x)
 
static bool compareAndSwapObject (object self, object o, long offset, object expected, object x)
 Implementation of native method 'compareAndSwapObject'.
 
static bool compareAndSwapInt (object self, object o, long offset, int expected, int x)
 Implementation of native method 'compareAndSwapInt'.
 
static bool compareAndSwapLong (object self, object o, long offset, long expected, long x)
 Implementation of native method 'compareAndSwapLong'.
 
static void unpark (object self, object thread)
 Implements the native method 'unpark'.
 
static void park (object self, bool isAbsolute, long time)
 Implements the native method 'park'.
 
static int getLoadAverage (object self, double[] loadavg, int nelems)
 
static void loadFence (object self)
 
static void storeFence (object self)
 
static void fullFence (object self)
 

Detailed Description

Definition at line 17 of file Unsafe.cs.

Member Function Documentation

◆ addressSize()

static int IKVM.Java.Externs.sun.misc.Unsafe.addressSize ( object self)
static

Implementation of native method 'addressSize'.

Parameters
self
Returns

Definition at line 1509 of file Unsafe.cs.

1510 {
1511 return IntPtr.Size;
1512 }

◆ allocateInstance()

static object IKVM.Java.Externs.sun.misc.Unsafe.allocateInstance ( object self,
global.java.lang.Class cls )
static

Implementation of native method 'allocateInstance'.

Parameters
self
cls
Returns

Definition at line 1605 of file Unsafe.cs.

1606 {
1607 var wrapper = RuntimeJavaType.FromClass(cls);
1608 try
1609 {
1610 wrapper.Finish();
1611 }
1613 {
1614 throw x.ToJava();
1615 }
1616
1617#if NETFRAMEWORK
1618 return FormatterServices.GetUninitializedObject(wrapper.TypeAsBaseType);
1619#else
1620 return RuntimeHelpers.GetUninitializedObject(wrapper.TypeAsBaseType);
1621#endif
1622 }
.NET exception that corresponds to a Java exception.

◆ allocateMemory()

static unsafe long IKVM.Java.Externs.sun.misc.Unsafe.allocateMemory ( object self,
long bytes )
static

Implementation of native method 'allocateMemory'.

Parameters
self
bytes
Returns
Exceptions
global::java.lang.OutOfMemoryError

Definition at line 1125 of file Unsafe.cs.

1126 {
1127#if FIRST_PASS
1128 throw new NotImplementedException();
1129#else
1130 try
1131 {
1132 if (bytes == 0)
1133 return 0;
1134
1135 var len = (IntPtr)bytes + sizeof(IntPtr);
1136 var ptr = Marshal.AllocHGlobal(len);
1137 Marshal.WriteIntPtr(ptr, len);
1138 System.GC.AddMemoryPressure((long)len);
1139 return (long)ptr + sizeof(IntPtr);
1140 }
1141 catch (OutOfMemoryException e)
1142 {
1143 throw new global::java.lang.OutOfMemoryError(e.Message).initCause(e);
1144 }
1145 catch (Exception e) when (e is not global::java.lang.Throwable)
1146 {
1147 throw new global::java.lang.InternalError(e);
1148 }
1149#endif
1150 }

◆ arrayBaseOffset()

static int IKVM.Java.Externs.sun.misc.Unsafe.arrayBaseOffset ( object self,
global.java.lang.Class arrayClass )
static

Implementation of native method 'arrayBaseOffset'.

Parameters
self
arrayClass
Returns

Definition at line 1458 of file Unsafe.cs.

1459 {
1460 return 0;
1461 }

◆ arrayIndexScale()

static int IKVM.Java.Externs.sun.misc.Unsafe.arrayIndexScale ( object self,
global.java.lang.Class arrayClass )
static

Implementation of native method 'arrayIndexScale'.

Parameters
self
arrayClass
Returns

Definition at line 1499 of file Unsafe.cs.

1500 {
1501 return ArrayIndexScale(RuntimeJavaType.FromClass(arrayClass));
1502 }

◆ compareAndSwapInt()

static bool IKVM.Java.Externs.sun.misc.Unsafe.compareAndSwapInt ( object self,
object o,
long offset,
int expected,
int x )
static

Implementation of native method 'compareAndSwapInt'.

Parameters
self
o
offset
expected
x
Returns

Definition at line 2544 of file Unsafe.cs.

2545 {
2546#if FIRST_PASS
2547 throw new NotImplementedException();
2548#else
2549 try
2550 {
2551 if (o is int[] array && (offset % sizeof(int)) == 0)
2552 {
2553 return Interlocked.CompareExchange(ref array[offset / sizeof(int)], x, expected) == expected;
2554 }
2555 else if (o is Array array1 && (offset % sizeof(int)) == 0)
2556 {
2557 return CompareExchangeInt32(array1, offset, x, expected) == expected;
2558 }
2559 else if (o is Array array2)
2560 {
2561 return CompareExchangeInt32Unaligned(array2, offset, x, expected) == expected;
2562 }
2563 else
2564 {
2565 return CompareAndSwapField(o, offset, expected, x);
2566 }
2567 }
2568 catch (Exception e) when (e is not global::java.lang.Throwable)
2569 {
2570 throw new global::java.lang.InternalError(e);
2571 }
2572#endif
2573 }
System.Threading.Interlocked Interlocked

◆ compareAndSwapLong()

static bool IKVM.Java.Externs.sun.misc.Unsafe.compareAndSwapLong ( object self,
object o,
long offset,
long expected,
long x )
static

Implementation of native method 'compareAndSwapLong'.

Parameters
self
o
offset
expected
x
Returns

Definition at line 2584 of file Unsafe.cs.

2585 {
2586#if FIRST_PASS
2587 throw new NotImplementedException();
2588#else
2589 try
2590 {
2591 if (o is long[] array && (offset % sizeof(long)) == 0)
2592 {
2593 return Interlocked.CompareExchange(ref array[offset / sizeof(long)], x, expected) == expected;
2594 }
2595 else if (o is Array array1 && (offset % sizeof(long)) == 0)
2596 {
2597 return CompareExchangeInt64(array1, offset, x, expected) == expected;
2598 }
2599 else if (o is Array array2)
2600 {
2601 return CompareExchangeInt64Unaligned(array2, offset, x, expected) == expected;
2602 }
2603 else
2604 {
2605 return CompareAndSwapField(o, offset, expected, x);
2606 }
2607 }
2608 catch (Exception e) when (e is not global::java.lang.Throwable)
2609 {
2610 throw new global::java.lang.InternalError(e);
2611 }
2612#endif
2613 }

◆ compareAndSwapObject()

static bool IKVM.Java.Externs.sun.misc.Unsafe.compareAndSwapObject ( object self,
object o,
long offset,
object expected,
object x )
static

Implementation of native method 'compareAndSwapObject'.

Parameters
self
o
offset
expected
x
Returns

Definition at line 2514 of file Unsafe.cs.

2515 {
2516#if FIRST_PASS
2517 throw new NotImplementedException();
2518#else
2519 try
2520 {
2521 return o switch
2522 {
2523 object[] array when array.GetType() == typeof(object[]) => Interlocked.CompareExchange(ref array[offset / IntPtr.Size], x, expected) == expected,
2524 object[] array => CompareAndSwapObjectArray(array, offset, x, expected) == expected,
2525 _ => CompareAndSwapField(o, offset, expected, x)
2526 };
2527 }
2528 catch (Exception e) when (e is not global::java.lang.Throwable)
2529 {
2530 throw new global::java.lang.InternalError(e);
2531 }
2532#endif
2533 }

◆ copyMemory()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.copyMemory ( object self,
object srcBase,
long srcOffset,
object destBase,
long destOffset,
long bytes )
static

Implementation of native method 'copyMemory'.

Parameters
self
srcBase
srcOffset
destBase
destOffset
bytes
Exceptions
global::java.lang.IllegalArgumentException

Definition at line 1251 of file Unsafe.cs.

1252 {
1253#if FIRST_PASS
1254 throw new NotImplementedException();
1255#else
1256 try
1257 {
1258 if (srcBase == null)
1259 {
1260 if (destBase is byte[] byteArray)
1261 {
1262 Marshal.Copy((IntPtr)srcOffset, byteArray, (int)destOffset, (int)bytes);
1263 }
1264 else if (destBase is bool[])
1265 {
1266 var tmp = new byte[(int)bytes];
1267 copyMemory(self, srcBase, srcOffset, tmp, 0, bytes);
1268 copyMemory(self, tmp, 0, destBase, destOffset, bytes);
1269 }
1270 else if (destBase is short[] shortArray)
1271 {
1272 Marshal.Copy((IntPtr)srcOffset, shortArray, (int)(destOffset >> 1), (int)(bytes >> 1));
1273 }
1274 else if (destBase is char[] charArray)
1275 {
1276 Marshal.Copy((IntPtr)srcOffset, charArray, (int)(destOffset >> 1), (int)(bytes >> 1));
1277 }
1278 else if (destBase is int[] intArray)
1279 {
1280 Marshal.Copy((IntPtr)srcOffset, intArray, (int)(destOffset >> 2), (int)(bytes >> 2));
1281 }
1282 else if (destBase is float[] floatArray)
1283 {
1284 Marshal.Copy((IntPtr)srcOffset, floatArray, (int)(destOffset >> 2), (int)(bytes >> 2));
1285 }
1286 else if (destBase is long[] longArray)
1287 {
1288 Marshal.Copy((IntPtr)srcOffset, longArray, (int)(destOffset >> 3), (int)(bytes >> 3));
1289 }
1290 else if (destBase is double[] doubleArray)
1291 {
1292 Marshal.Copy((IntPtr)srcOffset, doubleArray, (int)(destOffset >> 3), (int)(bytes >> 3));
1293 }
1294 else if (destBase == null)
1295 {
1296 Buffer.MemoryCopy((void*)(IntPtr)srcOffset, (void*)(IntPtr)destOffset, long.MaxValue, bytes);
1297 }
1298 else
1299 {
1300 throw new global::java.lang.IllegalArgumentException();
1301 }
1302 }
1303 else if (srcBase is Array && destBase is Array)
1304 {
1305 Buffer.BlockCopy((Array)srcBase, (int)srcOffset, (Array)destBase, (int)destOffset, (int)bytes);
1306 }
1307 else
1308 {
1309 if (srcBase is byte[] byteArray)
1310 {
1311 Marshal.Copy(byteArray, (int)srcOffset, (IntPtr)destOffset, (int)bytes);
1312 }
1313 else if (srcBase is bool[])
1314 {
1315 var tmp = new byte[(int)bytes];
1316 copyMemory(self, srcBase, srcOffset, tmp, 0, bytes);
1317 copyMemory(self, tmp, 0, destBase, destOffset, bytes);
1318 }
1319 else if (srcBase is short[] shortArray)
1320 {
1321 Marshal.Copy(shortArray, (int)(srcOffset >> 1), (IntPtr)(destOffset), (int)(bytes >> 1));
1322 }
1323 else if (srcBase is char[] charArray)
1324 {
1325 Marshal.Copy(charArray, (int)(srcOffset >> 1), (IntPtr)(destOffset), (int)(bytes >> 1));
1326 }
1327 else if (srcBase is int[] intArray)
1328 {
1329 Marshal.Copy(intArray, (int)(srcOffset >> 2), (IntPtr)(destOffset), (int)(bytes >> 2));
1330 }
1331 else if (srcBase is float[] floatArray)
1332 {
1333 Marshal.Copy(floatArray, (int)(srcOffset >> 2), (IntPtr)(destOffset), (int)(bytes >> 2));
1334 }
1335 else if (srcBase is long[] longArray)
1336 {
1337 Marshal.Copy(longArray, (int)(srcOffset >> 3), (IntPtr)(destOffset), (int)(bytes >> 3));
1338 }
1339 else if (srcBase is double[] doubleArray)
1340 {
1341 Marshal.Copy(doubleArray, (int)(srcOffset >> 3), (IntPtr)(destOffset), (int)(bytes >> 3));
1342 }
1343 else
1344 {
1345 throw new global::java.lang.IllegalArgumentException();
1346 }
1347 }
1348 }
1349 catch (Exception e) when (e is not global::java.lang.Throwable)
1350 {
1351 throw new global::java.lang.InternalError(e);
1352 }
1353#endif
1354 }
static unsafe void copyMemory(object self, object srcBase, long srcOffset, object destBase, long destOffset, long bytes)
Implementation of native method 'copyMemory'.
Definition Unsafe.cs:1251

◆ defineAnonymousClass()

static global.java.lang.Class IKVM.Java.Externs.sun.misc.Unsafe.defineAnonymousClass ( object self,
global.java.lang.Class hostClass,
byte[] data,
object[] cpPatches )
static

Implementation of native method 'defineAnonymousClass'.

Parameters
self
hostClass
data
cpPatches
Returns
Exceptions
global::java.lang.ClassFormatError

Definition at line 1549 of file Unsafe.cs.

1550 {
1551#if FIRST_PASS
1552 throw new NotImplementedException();
1553#else
1554 try
1555 {
1556 var tw = RuntimeJavaType.FromClass(hostClass);
1557 var cl = tw.ClassLoader;
1558 var cf = new IKVM.Runtime.ClassFile(JVM.Context, JVM.Context.Diagnostics, ReadClass(data), "<Unknown>", cl.ClassFileParseOptions, cpPatches);
1559
1560 // if this happens, the OpenJDK is probably trying to load an OpenJDK class file as a resource,
1561 // make sure the build process includes the original class file as a resource in that case
1562 if (cf.IKVMAssemblyAttribute != null)
1563 throw new global::java.lang.ClassFormatError("Trying to define anonymous class based on stub class: " + cf.Name);
1564
1565 return cl.GetTypeWrapperFactory().DefineClassImpl(null, tw, cf, cl, hostClass.pd).ClassObject;
1566 }
1568 {
1569 throw e.ToJava();
1570 }
1571#endif
1572 }
Main state of the running JVM.
IDiagnosticHandler Diagnostics
Gets the IDiagnosticHandler where events should be sent.

◆ defineClass()

static global.java.lang.Class IKVM.Java.Externs.sun.misc.Unsafe.defineClass ( object self,
string name,
byte[] b,
int off,
int len,
global.java.lang.ClassLoader loader,
global.java.security.ProtectionDomain protectionDomain )
static

Implementation of native method 'defineClass'.

Parameters
self
name
b
off
len
loader
protectionDomain
Returns

Definition at line 1535 of file Unsafe.cs.

1536 {
1537 return IKVM.Java.Externs.java.lang.ClassLoader.defineClass1(loader, name.Replace('/', '.'), b, off, len, protectionDomain, null);
1538 }
static global::java.lang.Class defineClass1(global::java.lang.ClassLoader self, string name, byte[] b, int off, int len, global::java.security.ProtectionDomain pd, string source)
Implements the native method 'defineClass1'.

◆ ensureClassInitialized()

static void IKVM.Java.Externs.sun.misc.Unsafe.ensureClassInitialized ( object self,
global.java.lang.Class c )
static

Implementation of native method 'ensureClassInitialized'.

Parameters
self
c

Definition at line 1434 of file Unsafe.cs.

1435 {
1436 var tw = RuntimeJavaType.FromClass(c);
1437 if (tw.IsArray == false)
1438 {
1439 try
1440 {
1441 tw.Finish();
1442 }
1444 {
1445 throw x.ToJava();
1446 }
1447
1448 tw.RunClassInit();
1449 }
1450 }

◆ freeMemory()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.freeMemory ( object self,
long address )
static

Implementation of native method 'freeMemory'.

Parameters
self
address

Definition at line 1361 of file Unsafe.cs.

1362 {
1363 var adr = (nint)address;
1364 if (adr == 0)
1365 return;
1366
1367 var ptr = adr - sizeof(nint);
1368 var len = Marshal.ReadIntPtr(ptr);
1369 Marshal.FreeHGlobal(ptr);
1370 System.GC.RemoveMemoryPressure((long)len);
1371 }

◆ fullFence()

static void IKVM.Java.Externs.sun.misc.Unsafe.fullFence ( object self)
static

Definition at line 2719 of file Unsafe.cs.

2720 {
2721 Thread.MemoryBarrier();
2722 }

◆ getAddress()

static long IKVM.Java.Externs.sun.misc.Unsafe.getAddress ( object self,
long address )
static

Implementation of native method 'getAddress'.

Parameters
self
address
Returns

Definition at line 1080 of file Unsafe.cs.

1081 {
1082#if FIRST_PASS
1083 throw new NotImplementedException();
1084#else
1085 try
1086 {
1087 return Marshal.ReadIntPtr((IntPtr)address).ToInt64();
1088 }
1089 catch (Exception e) when (e is not global::java.lang.Throwable)
1090 {
1091 throw new global::java.lang.InternalError(e);
1092 }
1093#endif
1094 }

◆ getBoolean()

static bool IKVM.Java.Externs.sun.misc.Unsafe.getBoolean ( object self,
object o,
long offset )
static

Implementation of native method 'getBoolean'.

Parameters
self
o
offset
Returns

Definition at line 259 of file Unsafe.cs.

260 {
261#if FIRST_PASS
262 throw new NotImplementedException();
263#else
264 try
265 {
266 return o switch
267 {
268 null => Marshal.ReadByte((IntPtr)offset) != 0,
269 RuntimeJavaType w => GetField<bool>(null, offset),
270 Array array => Buffer.GetByte(array, (int)offset) != 0,
271 _ => GetField<bool>(o, offset)
272 };
273 }
274 catch (Exception e) when (e is not global::java.lang.Throwable)
275 {
276 throw new global::java.lang.InternalError(e);
277 }
278#endif
279 }

◆ getBooleanVolatile()

static unsafe bool IKVM.Java.Externs.sun.misc.Unsafe.getBooleanVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getBooleanVolatile'.

Parameters
self
o
offset
Returns

Definition at line 1964 of file Unsafe.cs.

1965 {
1966#if FIRST_PASS
1967 throw new NotImplementedException();
1968#else
1969 try
1970 {
1971 return o switch
1972 {
1973 null => Volatile.Read(ref System.Runtime.CompilerServices.Unsafe.AsRef<byte>((void*)(IntPtr)offset)) != 0,
1974 RuntimeJavaType w => GetFieldVolatile<bool>(null, offset),
1975 Array array => ReadByteVolatile(array, offset) != 0,
1976 _ => GetFieldVolatile<bool>(o, offset)
1977 };
1978 }
1979 catch (Exception e) when (e is not global::java.lang.Throwable)
1980 {
1981 throw new global::java.lang.InternalError(e);
1982 }
1983#endif
1984 }

◆ getByte() [1/2]

static byte IKVM.Java.Externs.sun.misc.Unsafe.getByte ( object self,
long address )
static

Implementation of native method 'getByte'.

Parameters
self
address
Returns

Definition at line 786 of file Unsafe.cs.

787 {
788#if FIRST_PASS
789 throw new NotImplementedException();
790#else
791 try
792 {
793 return Marshal.ReadByte((IntPtr)address);
794 }
795 catch (Exception e) when (e is not global::java.lang.Throwable)
796 {
797 throw new global::java.lang.InternalError(e);
798 }
799#endif
800 }

◆ getByte() [2/2]

static byte IKVM.Java.Externs.sun.misc.Unsafe.getByte ( object self,
object o,
long offset )
static

Implementation of native method 'getByte'.

Parameters
self
o
offset
Returns

Definition at line 325 of file Unsafe.cs.

326 {
327#if FIRST_PASS
328 throw new NotImplementedException();
329#else
330 try
331 {
332 return o switch
333 {
334 null => Marshal.ReadByte((IntPtr)offset),
335 RuntimeJavaType w => GetField<byte>(null, offset),
336 Array array => Buffer.GetByte(array, (int)offset),
337 _ => GetField<byte>(o, offset)
338 };
339 }
340 catch (Exception e) when (e is not global::java.lang.Throwable)
341 {
342 throw new global::java.lang.InternalError(e);
343 }
344#endif
345 }

◆ getByteVolatile()

static unsafe byte IKVM.Java.Externs.sun.misc.Unsafe.getByteVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getByteVolatile'.

Parameters
self
o
offset
Returns

Definition at line 2030 of file Unsafe.cs.

2031 {
2032#if FIRST_PASS
2033 throw new NotImplementedException();
2034#else
2035 try
2036 {
2037 return o switch
2038 {
2039 null => Volatile.Read(ref System.Runtime.CompilerServices.Unsafe.AsRef<byte>((void*)(IntPtr)offset)),
2040 RuntimeJavaType w => GetFieldVolatile<byte>(null, offset),
2041 Array array => ReadByteVolatile(array, offset),
2042 _ => GetFieldVolatile<byte>(o, offset)
2043 };
2044 }
2045 catch (Exception e) when (e is not global::java.lang.Throwable)
2046 {
2047 throw new global::java.lang.InternalError(e);
2048 }
2049#endif
2050 }

◆ getChar() [1/2]

static char IKVM.Java.Externs.sun.misc.Unsafe.getChar ( object self,
long address )
static

Implementation of native method 'getChar'.

Parameters
self
address
Returns

Definition at line 874 of file Unsafe.cs.

875 {
876#if FIRST_PASS
877 throw new NotImplementedException();
878#else
879 try
880 {
881 return (char)Marshal.ReadInt16((IntPtr)address);
882 }
883 catch (Exception e) when (e is not global::java.lang.Throwable)
884 {
885 throw new global::java.lang.InternalError(e);
886 }
887#endif
888 }

◆ getChar() [2/2]

static char IKVM.Java.Externs.sun.misc.Unsafe.getChar ( object self,
object o,
long offset )
static

Implementation of native method 'getChar'.

Parameters
self
o
offset
Returns

Definition at line 457 of file Unsafe.cs.

458 {
459#if FIRST_PASS
460 throw new NotImplementedException();
461#else
462 try
463 {
464 return o switch
465 {
466 null => (char)Marshal.ReadInt16((IntPtr)offset),
467 RuntimeJavaType w => GetField<char>(null, offset),
468 Array array => (char)ReadInt16(array, offset),
469 _ => GetField<char>(o, offset)
470 };
471 }
472 catch (Exception e) when (e is not global::java.lang.Throwable)
473 {
474 throw new global::java.lang.InternalError(e);
475 }
476#endif
477 }

◆ getCharVolatile()

static char IKVM.Java.Externs.sun.misc.Unsafe.getCharVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getCharVolatile'.

Parameters
self
o
offset
Returns

Definition at line 2160 of file Unsafe.cs.

2161 {
2162#if FIRST_PASS
2163 throw new NotImplementedException();
2164#else
2165 try
2166 {
2167 return o switch
2168 {
2169 Array array => (char)ReadInt16Volatile(array, offset),
2170 _ => GetFieldVolatile<char>(o, offset)
2171 };
2172 }
2173 catch (Exception e) when (e is not global::java.lang.Throwable)
2174 {
2175 throw new global::java.lang.InternalError(e);
2176 }
2177#endif
2178 }

◆ getDouble() [1/2]

static double IKVM.Java.Externs.sun.misc.Unsafe.getDouble ( object self,
long address )
static

Implementation of native method 'getDouble'.

Parameters
self
address
Returns

Definition at line 1043 of file Unsafe.cs.

1044 {
1045#if FIRST_PASS
1046 throw new NotImplementedException();
1047#else
1048 try
1049 {
1050 return global::java.lang.Double.longBitsToDouble(getLong(self, address));
1051 }
1052 catch (Exception e) when (e is not global::java.lang.Throwable)
1053 {
1054 throw new global::java.lang.InternalError(e);
1055 }
1056#endif
1057 }
static long getLong(object self, object o, long offset)
Implementation of native method 'getLong'.
Definition Unsafe.cs:589

◆ getDouble() [2/2]

static double IKVM.Java.Externs.sun.misc.Unsafe.getDouble ( object self,
object o,
long offset )
static

Implementation of native method 'getDouble'.

Parameters
self
o
offset
Returns

Definition at line 721 of file Unsafe.cs.

722 {
723#if FIRST_PASS
724 throw new NotImplementedException();
725#else
726 try
727 {
728 return o switch
729 {
730 null => global::java.lang.Double.longBitsToDouble(Marshal.ReadInt64((IntPtr)offset)),
731 RuntimeJavaType w => GetField<double>(null, offset),
732 Array array => global::java.lang.Double.longBitsToDouble(ReadInt64(array, offset)),
733 _ => GetField<double>(o, offset)
734 };
735 }
736 catch (Exception e) when (e is not global::java.lang.Throwable)
737 {
738 throw new global::java.lang.InternalError(e);
739 }
740#endif
741 }

◆ getDoubleVolatile()

static double IKVM.Java.Externs.sun.misc.Unsafe.getDoubleVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getDoubleVolatile'.

Parameters
self
o
offset
Returns
Exceptions
global::java.lang.NullPointerException

Definition at line 2354 of file Unsafe.cs.

2355 {
2356#if FIRST_PASS
2357 throw new NotImplementedException();
2358#else
2359 try
2360 {
2361 return o switch
2362 {
2363 Array array => global::java.lang.Double.longBitsToDouble(ReadInt64Volatile(array, offset)),
2364 _ => GetFieldVolatile<double>(o, offset)
2365 };
2366 }
2367 catch (Exception e) when (e is not global::java.lang.Throwable)
2368 {
2369 throw new global::java.lang.InternalError(e);
2370 }
2371#endif
2372 }

◆ getFloat() [1/2]

static float IKVM.Java.Externs.sun.misc.Unsafe.getFloat ( object self,
long address )
static

Implementation of native method 'getFloat'.

Parameters
self
address
Returns

Definition at line 1006 of file Unsafe.cs.

1007 {
1008#if FIRST_PASS
1009 throw new NotImplementedException();
1010#else
1011 try
1012 {
1013 return global::java.lang.Float.intBitsToFloat(getInt(self, address));
1014 }
1015 catch (Exception e) when (e is not global::java.lang.Throwable)
1016 {
1017 throw new global::java.lang.InternalError(e);
1018 }
1019#endif
1020 }
static int getInt(object self, object o, long offset)
Implementation of native method 'getInt'.
Definition Unsafe.cs:523

◆ getFloat() [2/2]

static float IKVM.Java.Externs.sun.misc.Unsafe.getFloat ( object self,
object o,
long offset )
static

Implementation of native method 'getFloat'.

Parameters
self
o
offset
Returns

Definition at line 655 of file Unsafe.cs.

656 {
657#if FIRST_PASS
658 throw new NotImplementedException();
659#else
660 try
661 {
662 return o switch
663 {
664 null => global::java.lang.Float.intBitsToFloat(Marshal.ReadInt32((IntPtr)offset)),
665 RuntimeJavaType w => GetField<float>(null, offset),
666 Array array => global::java.lang.Float.intBitsToFloat(ReadInt32(array, offset)),
667 _ => GetField<float>(o, offset)
668 };
669 }
670 catch (Exception e) when (e is not global::java.lang.Throwable)
671 {
672 throw new global::java.lang.InternalError(e);
673 }
674#endif
675 }

◆ getFloatVolatile()

static float IKVM.Java.Externs.sun.misc.Unsafe.getFloatVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getFloatVolatile'.

Parameters
self
o
offset
Returns
Exceptions
global::java.lang.NullPointerException

Definition at line 2289 of file Unsafe.cs.

2290 {
2291#if FIRST_PASS
2292 throw new NotImplementedException();
2293#else
2294 try
2295 {
2296 return o switch
2297 {
2298 Array array => global::java.lang.Float.intBitsToFloat(ReadInt32Volatile(array, offset)),
2299 _ => GetFieldVolatile<float>(o, offset)
2300 };
2301 }
2302 catch (Exception e) when (e is not global::java.lang.Throwable)
2303 {
2304 throw new global::java.lang.InternalError(e);
2305 }
2306#endif
2307 }

◆ getInt() [1/2]

static int IKVM.Java.Externs.sun.misc.Unsafe.getInt ( object self,
long address )
static

Implementation of native method 'getInt'.

Parameters
self
address
Returns

Definition at line 918 of file Unsafe.cs.

919 {
920#if FIRST_PASS
921 throw new NotImplementedException();
922#else
923 try
924 {
925 return Marshal.ReadInt32((IntPtr)address);
926 }
927 catch (Exception e) when (e is not global::java.lang.Throwable)
928 {
929 throw new global::java.lang.InternalError(e);
930 }
931#endif
932 }

◆ getInt() [2/2]

static int IKVM.Java.Externs.sun.misc.Unsafe.getInt ( object self,
object o,
long offset )
static

Implementation of native method 'getInt'.

Parameters
self
o
offset
Returns

Definition at line 523 of file Unsafe.cs.

524 {
525#if FIRST_PASS
526 throw new NotImplementedException();
527#else
528 try
529 {
530 return o switch
531 {
532 null => Marshal.ReadInt32((IntPtr)offset),
533 RuntimeJavaType w => GetField<int>(null, offset),
534 Array array => ReadInt32(array, offset),
535 _ => GetField<int>(o, offset)
536 };
537 }
538 catch (Exception e) when (e is not global::java.lang.Throwable)
539 {
540 throw new global::java.lang.InternalError(e);
541 }
542#endif
543 }

◆ getIntVolatile()

static unsafe int IKVM.Java.Externs.sun.misc.Unsafe.getIntVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getIntVolatile'.

Parameters
self
o
offset
Returns

Definition at line 1898 of file Unsafe.cs.

1899 {
1900#if FIRST_PASS
1901 throw new NotImplementedException();
1902#else
1903 try
1904 {
1905 return o switch
1906 {
1907 null => Volatile.Read(ref System.Runtime.CompilerServices.Unsafe.AsRef<int>((void*)(IntPtr)offset)),
1908 RuntimeJavaType w => GetFieldVolatile<int>(null, offset),
1909 Array array => ReadInt32Volatile(array, offset),
1910 _ => GetFieldVolatile<int>(o, offset)
1911 };
1912 }
1913 catch (Exception e) when (e is not global::java.lang.Throwable)
1914 {
1915 throw new global::java.lang.InternalError(e);
1916 }
1917#endif
1918 }

◆ getLoadAverage()

static int IKVM.Java.Externs.sun.misc.Unsafe.getLoadAverage ( object self,
double[] loadavg,
int nelems )
static

Definition at line 2704 of file Unsafe.cs.

2705 {
2706 return -1;
2707 }

◆ getLong() [1/2]

static long IKVM.Java.Externs.sun.misc.Unsafe.getLong ( object self,
long address )
static

Implementation of native method 'getLong'.

Parameters
self
address
Returns

Definition at line 962 of file Unsafe.cs.

963 {
964#if FIRST_PASS
965 throw new NotImplementedException();
966#else
967 try
968 {
969 return Marshal.ReadInt64((IntPtr)address);
970 }
971 catch (Exception e) when (e is not global::java.lang.Throwable)
972 {
973 throw new global::java.lang.InternalError(e);
974 }
975#endif
976 }

◆ getLong() [2/2]

static long IKVM.Java.Externs.sun.misc.Unsafe.getLong ( object self,
object o,
long offset )
static

Implementation of native method 'getLong'.

Parameters
self
o
offset
Returns

Definition at line 589 of file Unsafe.cs.

590 {
591#if FIRST_PASS
592 throw new NotImplementedException();
593#else
594 try
595 {
596 return o switch
597 {
598 null => Marshal.ReadInt64((IntPtr)offset),
599 RuntimeJavaType w => GetField<long>(null, offset),
600 Array array => ReadInt64(array, offset),
601 _ => GetField<long>(o, offset)
602 };
603 }
604 catch (Exception e) when (e is not global::java.lang.Throwable)
605 {
606 throw new global::java.lang.InternalError(e);
607 }
608#endif
609 }

◆ getLongVolatile()

static long IKVM.Java.Externs.sun.misc.Unsafe.getLongVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getLongVolatile'.

Parameters
self
o
offset
Returns

Definition at line 2224 of file Unsafe.cs.

2225 {
2226#if FIRST_PASS
2227 throw new NotImplementedException();
2228#else
2229 try
2230 {
2231 return o switch
2232 {
2233 Array array => ReadInt64Volatile(array, offset),
2234 _ => GetFieldVolatile<long>(o, offset)
2235 };
2236 }
2237 catch (Exception e) when (e is not global::java.lang.Throwable)
2238 {
2239 throw new global::java.lang.InternalError(e);
2240 }
2241#endif
2242 }

◆ getObject()

static object IKVM.Java.Externs.sun.misc.Unsafe.getObject ( object self,
object o,
long offset )
static

Implementation of native method 'getObject'.

Parameters
self
o
offset
Returns

Definition at line 194 of file Unsafe.cs.

195 {
196#if FIRST_PASS
197 throw new NotImplementedException();
198#else
199 try
200 {
201 return o switch
202 {
203 RuntimeJavaType w => GetField<object>(null, offset),
204 object[] array => array[offset / IntPtr.Size],
205 object obj => GetField<object>(obj, offset),
206 _ => throw new global::java.lang.IllegalArgumentException(),
207 };
208 }
209 catch (Exception e) when (e is not global::java.lang.Throwable)
210 {
211 throw new global::java.lang.InternalError(e);
212 }
213#endif
214 }

◆ getObjectVolatile()

static object IKVM.Java.Externs.sun.misc.Unsafe.getObjectVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getObjectVolatile'.

Parameters
self
o
offset
Returns

Definition at line 1829 of file Unsafe.cs.

1830 {
1831#if FIRST_PASS
1832 throw new NotImplementedException();
1833#else
1834 try
1835 {
1836 return o switch
1837 {
1838 RuntimeJavaType w => GetField<object>(null, offset),
1839 object[] array when array.GetType() == typeof(object[]) => Volatile.Read(ref array[offset / IntPtr.Size]),
1840 object[] array => GetArrayObjectVolatile(array, offset),
1841 object obj => GetFieldVolatile<object>(obj, offset),
1842 _ => throw new global::java.lang.IllegalArgumentException(),
1843 };
1844 }
1845 catch (Exception e) when (e is not global::java.lang.Throwable)
1846 {
1847 throw new global::java.lang.InternalError(e);
1848 }
1849#endif
1850 }

◆ getShort() [1/2]

static short IKVM.Java.Externs.sun.misc.Unsafe.getShort ( object self,
long address )
static

Implementation of native method 'getShort'.

Parameters
self
address
Returns

Definition at line 830 of file Unsafe.cs.

831 {
832#if FIRST_PASS
833 throw new NotImplementedException();
834#else
835 try
836 {
837 return Marshal.ReadInt16((IntPtr)address);
838 }
839 catch (Exception e) when (e is not global::java.lang.Throwable)
840 {
841 throw new global::java.lang.InternalError(e);
842 }
843#endif
844 }

◆ getShort() [2/2]

static short IKVM.Java.Externs.sun.misc.Unsafe.getShort ( object self,
object o,
long offset )
static

Implementation of native method 'getShort'.

Parameters
self
o
offset
Returns

Definition at line 391 of file Unsafe.cs.

392 {
393#if FIRST_PASS
394 throw new NotImplementedException();
395#else
396 try
397 {
398 return o switch
399 {
400 null => Marshal.ReadInt16((IntPtr)offset),
401 RuntimeJavaType w => GetField<short>(null, offset),
402 Array array => ReadInt16(array, offset),
403 _ => GetField<short>(o, offset)
404 };
405 }
406 catch (Exception e) when (e is not global::java.lang.Throwable)
407 {
408 throw new global::java.lang.InternalError(e);
409 }
410#endif
411 }

◆ getShortVolatile()

static short IKVM.Java.Externs.sun.misc.Unsafe.getShortVolatile ( object self,
object o,
long offset )
static

Implementation of native method 'getShortVolatile'.

Parameters
self
o
offset
Returns

Definition at line 2096 of file Unsafe.cs.

2097 {
2098#if FIRST_PASS
2099 throw new NotImplementedException();
2100#else
2101 try
2102 {
2103 return o switch
2104 {
2105 Array array => ReadInt16Volatile(array, offset),
2106 _ => GetFieldVolatile<short>(o, offset)
2107 };
2108 }
2109 catch (Exception e) when (e is not global::java.lang.Throwable)
2110 {
2111 throw new global::java.lang.InternalError(e);
2112 }
2113#endif
2114 }

◆ loadFence()

static void IKVM.Java.Externs.sun.misc.Unsafe.loadFence ( object self)
static

Definition at line 2709 of file Unsafe.cs.

2710 {
2711 Thread.MemoryBarrier();
2712 }

◆ monitorEnter()

static void IKVM.Java.Externs.sun.misc.Unsafe.monitorEnter ( object self,
object o )
static

Implementation of native method 'monitorEnter'.

Parameters
self
o

Definition at line 1629 of file Unsafe.cs.

1630 {
1631 Monitor.Enter(o);
1632 }

◆ monitorExit()

static void IKVM.Java.Externs.sun.misc.Unsafe.monitorExit ( object self,
object o )
static

Implementation of native method 'monitorExit'.

Parameters
self
o

Definition at line 1639 of file Unsafe.cs.

1640 {
1641 Monitor.Exit(o);
1642 }

◆ objectFieldOffset()

static long IKVM.Java.Externs.sun.misc.Unsafe.objectFieldOffset ( object self,
global.java.lang.reflect.Field f )
static

Implementation of native method 'objectFieldOffset'.

Parameters
self
f
Returns

Definition at line 1409 of file Unsafe.cs.

1410 {
1411 var w = RuntimeJavaField.FromField(f);
1412 if (w.IsStatic)
1413 throw new global::java.lang.IllegalArgumentException();
1414
1415 return (long)w.Cookie;
1416 }

◆ pageSize()

static int IKVM.Java.Externs.sun.misc.Unsafe.pageSize ( object self)
static

Implementation of native method 'pageSize'.

Parameters
self
Returns

Definition at line 1519 of file Unsafe.cs.

1520 {
1521 return Environment.SystemPageSize;
1522 }

◆ park()

static void IKVM.Java.Externs.sun.misc.Unsafe.park ( object self,
bool isAbsolute,
long time )
static

Implements the native method 'park'.

Parameters
self
isAbsolute
time

Definition at line 2657 of file Unsafe.cs.

2658 {
2659#if FIRST_PASS
2660 throw new NotImplementedException();
2661#else
2662 var currentThread = global::java.lang.Thread.currentThread();
2663 if (currentThread == null)
2664 throw new global::java.lang.IllegalStateException();
2665
2666 if (Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_RUNNING, PARK_STATE_PERMIT) == PARK_STATE_PERMIT)
2667 return;
2668
2669 // initialize lock
2670 Interlocked.CompareExchange(ref currentThread.parkLock, new global::java.lang.Object(), null);
2671
2672 // lock thread
2673 lock (currentThread.parkLock)
2674 {
2675 if (Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_PARKED, PARK_STATE_RUNNING) == PARK_STATE_PERMIT)
2676 {
2677 Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_RUNNING, PARK_STATE_PERMIT);
2678 return;
2679 }
2680
2681 if (isAbsolute)
2682 {
2683 time *= 1000000;
2684 time -= global::java.lang.System.currentTimeMillis() * 1000000;
2685 }
2686
2687 if (time >= 0)
2688 {
2689 try
2690 {
2691 ((global::java.lang.Object)currentThread.parkLock).wait(time / 1000000, (int)(time % 1000000));
2692 }
2693 catch (global::java.lang.InterruptedException)
2694 {
2695 currentThread.interrupt();
2696 }
2697 }
2698
2699 Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_RUNNING, PARK_STATE_PARKED);
2700 }
2701#endif
2702 }

◆ putAddress()

static void IKVM.Java.Externs.sun.misc.Unsafe.putAddress ( object self,
long address,
long x )
static

Implementation of native method 'putAddress'.

Parameters
self
address
x

Definition at line 1102 of file Unsafe.cs.

1103 {
1104#if FIRST_PASS
1105 throw new NotImplementedException();
1106#else
1107 try
1108 {
1109 Marshal.WriteIntPtr((IntPtr)address, (IntPtr)x);
1110 }
1111 catch (Exception e) when (e is not global::java.lang.Throwable)
1112 {
1113 throw new global::java.lang.InternalError(e);
1114 }
1115#endif
1116 }

◆ putBoolean()

static void IKVM.Java.Externs.sun.misc.Unsafe.putBoolean ( object self,
object o,
long offset,
bool x )
static

Implementation of native method 'putBoolean'.

Parameters
self
o
offset
x

Definition at line 288 of file Unsafe.cs.

289 {
290#if FIRST_PASS
291 throw new NotImplementedException();
292#else
293 try
294 {
295 switch (o)
296 {
297 case null:
298 Marshal.WriteByte((IntPtr)offset, x ? (byte)1 : (byte)0);
299 break;
300 case RuntimeJavaType w:
301 PutField(w, offset, x);
302 break;
303 case Array array:
304 Buffer.SetByte(array, (int)offset, x ? (byte)1 : (byte)0);
305 break;
306 default:
307 PutField(o, offset, x);
308 break;
309 }
310 }
311 catch (Exception e) when (e is not global::java.lang.Throwable)
312 {
313 throw new global::java.lang.InternalError(e);
314 }
315#endif
316 }

◆ putBooleanVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putBooleanVolatile ( object self,
object o,
long offset,
bool x )
static

Implementation of native method 'putBooleanVolatile'.

Parameters
self
o
offset
x

Definition at line 1993 of file Unsafe.cs.

1994 {
1995#if FIRST_PASS
1996 throw new NotImplementedException();
1997#else
1998 try
1999 {
2000 switch (o)
2001 {
2002 case null:
2003 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<byte>((void*)(IntPtr)offset), x ? (byte)1 : (byte)0);
2004 break;
2005 case RuntimeJavaType w:
2006 PutFieldVolatile(w, offset, x);
2007 break;
2008 case Array array:
2009 WriteByteVolatile(array, offset, x ? (byte)1 : (byte)0);
2010 break;
2011 default:
2012 PutFieldVolatile(o, offset, x);
2013 break;
2014 }
2015 }
2016 catch (Exception e) when (e is not global::java.lang.Throwable)
2017 {
2018 throw new global::java.lang.InternalError(e);
2019 }
2020#endif
2021 }

◆ putByte() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putByte ( object self,
long address,
byte x )
static

Implementation of native method 'putByte'.

Parameters
self
address
x

Definition at line 808 of file Unsafe.cs.

809 {
810#if FIRST_PASS
811 throw new NotImplementedException();
812#else
813 try
814 {
815 Marshal.WriteByte((IntPtr)address, x);
816 }
817 catch (Exception e) when (e is not global::java.lang.Throwable)
818 {
819 throw new global::java.lang.InternalError(e);
820 }
821#endif
822 }

◆ putByte() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putByte ( object self,
object o,
long offset,
byte x )
static

Implementation of native method 'putByte'.

Parameters
self
o
offset
x

Definition at line 354 of file Unsafe.cs.

355 {
356#if FIRST_PASS
357 throw new NotImplementedException();
358#else
359 try
360 {
361 switch (o)
362 {
363 case null:
364 Marshal.WriteByte((IntPtr)offset, x);
365 break;
366 case RuntimeJavaType w:
367 PutField(w, offset, x);
368 break;
369 case Array array:
370 Buffer.SetByte(array, (int)offset, x);
371 break;
372 default:
373 PutField(o, offset, x);
374 break;
375 }
376 }
377 catch (Exception e) when (e is not global::java.lang.Throwable)
378 {
379 throw new global::java.lang.InternalError(e);
380 }
381#endif
382 }

◆ putByteVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putByteVolatile ( object self,
object o,
long offset,
byte x )
static

Implementation of native method 'putByteVolatile'.

Parameters
self
o
offset
x

Definition at line 2059 of file Unsafe.cs.

2060 {
2061#if FIRST_PASS
2062 throw new NotImplementedException();
2063#else
2064 try
2065 {
2066 switch (o)
2067 {
2068 case null:
2069 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<byte>((void*)(IntPtr)offset), x);
2070 break;
2071 case RuntimeJavaType w:
2072 PutFieldVolatile(w, offset, x);
2073 break;
2074 case Array array:
2075 WriteByteVolatile(array, offset, x);
2076 break;
2077 default:
2078 PutFieldVolatile(o, offset, x);
2079 break;
2080 }
2081 }
2082 catch (Exception e) when (e is not global::java.lang.Throwable)
2083 {
2084 throw new global::java.lang.InternalError(e);
2085 }
2086#endif
2087 }

◆ putChar() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putChar ( object self,
long address,
char x )
static

Implementation of native method 'putChar'.

Parameters
self
address
x

Definition at line 896 of file Unsafe.cs.

897 {
898#if FIRST_PASS
899 throw new NotImplementedException();
900#else
901 try
902 {
903 Marshal.WriteInt16((IntPtr)address, (short)x);
904 }
905 catch (Exception e) when (e is not global::java.lang.Throwable)
906 {
907 throw new global::java.lang.InternalError(e);
908 }
909#endif
910 }

◆ putChar() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putChar ( object self,
object o,
long offset,
char x )
static

Implementation of native method 'putChar'.

Parameters
self
o
offset
x

Definition at line 486 of file Unsafe.cs.

487 {
488#if FIRST_PASS
489 throw new NotImplementedException();
490#else
491 try
492 {
493 switch (o)
494 {
495 case null:
496 Marshal.WriteInt16((IntPtr)offset, (short)x);
497 break;
498 case RuntimeJavaType w:
499 PutField(w, offset, x);
500 break;
501 case Array array:
502 WriteInt16(array, offset, (short)x);
503 break;
504 default:
505 PutField(o, offset, x);
506 break;
507 }
508 }
509 catch (Exception e) when (e is not global::java.lang.Throwable)
510 {
511 throw new global::java.lang.InternalError(e);
512 }
513#endif
514 }

◆ putCharVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putCharVolatile ( object self,
object o,
long offset,
char x )
static

Implementation of native method 'putCharVolatile'.

Parameters
self
o
offset
x

Definition at line 2187 of file Unsafe.cs.

2188 {
2189#if FIRST_PASS
2190 throw new NotImplementedException();
2191#else
2192 try
2193 {
2194 switch (o)
2195 {
2196 case null:
2197 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<short>((void*)(IntPtr)offset), (short)x);
2198 break;
2199 case RuntimeJavaType w:
2200 PutFieldVolatile(w, offset, x);
2201 break;
2202 case Array array:
2203 WriteInt16Volatile(array, offset, (short)x);
2204 break;
2205 default:
2206 PutFieldVolatile(o, offset, x);
2207 break;
2208 }
2209 }
2210 catch (Exception e) when (e is not global::java.lang.Throwable)
2211 {
2212 throw new global::java.lang.InternalError(e);
2213 }
2214#endif
2215 }

◆ putDouble() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putDouble ( object self,
long address,
double x )
static

Implementation of native method 'putDouble'.

Parameters
self
address
x

Definition at line 1065 of file Unsafe.cs.

1066 {
1067#if FIRST_PASS
1068 throw new NotImplementedException();
1069#else
1070 putLong(self, address, global::java.lang.Double.doubleToLongBits(x));
1071#endif
1072 }
static void putLong(object self, object o, long offset, long x)
Implementation of native method 'putLong'.
Definition Unsafe.cs:618

◆ putDouble() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putDouble ( object self,
object o,
long offset,
double x )
static

Implementation of native method 'putDouble'.

Parameters
self
o
offset
x

Definition at line 750 of file Unsafe.cs.

751 {
752#if FIRST_PASS
753 throw new NotImplementedException();
754#else
755 try
756 {
757 switch (o)
758 {
759 case null:
760 Marshal.WriteInt64((IntPtr)offset, global::java.lang.Double.doubleToRawLongBits(x));
761 break;
762 case RuntimeJavaType w:
763 PutField(w, offset, x);
764 break;
765 case Array array:
766 WriteInt64(array, offset, global::java.lang.Double.doubleToRawLongBits(x));
767 break;
768 default:
769 PutField(o, offset, x);
770 break;
771 }
772 }
773 catch (Exception e) when (e is not global::java.lang.Throwable)
774 {
775 throw new global::java.lang.InternalError(e);
776 }
777#endif
778 }

◆ putDoubleVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putDoubleVolatile ( object self,
object o,
long offset,
double x )
static

Implementation of native method 'putDoubleVolatile'.

Parameters
self
o
offset
x

Definition at line 2381 of file Unsafe.cs.

2382 {
2383#if FIRST_PASS
2384 throw new NotImplementedException();
2385#else
2386 try
2387 {
2388 switch (o)
2389 {
2390 case null:
2391 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<double>((void*)(IntPtr)offset), x);
2392 break;
2393 case RuntimeJavaType w:
2394 PutFieldVolatile(w, offset, x);
2395 break;
2396 case Array array:
2397 WriteInt64Volatile(array, offset, global::java.lang.Double.doubleToRawLongBits(x));
2398 break;
2399 default:
2400 PutFieldVolatile(o, offset, x);
2401 break;
2402 }
2403 }
2404 catch (Exception e) when (e is not global::java.lang.Throwable)
2405 {
2406 throw new global::java.lang.InternalError(e);
2407 }
2408#endif
2409 }

◆ putFloat() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putFloat ( object self,
long address,
float x )
static

Implementation of native method 'putFloat'.

Parameters
self
address
x

Definition at line 1028 of file Unsafe.cs.

1029 {
1030#if FIRST_PASS
1031 throw new NotImplementedException();
1032#else
1033 putInt(self, address, global::java.lang.Float.floatToIntBits(x));
1034#endif
1035 }
static void putInt(object self, object o, long offset, int x)
Implementation of native method 'putInt'.
Definition Unsafe.cs:552

◆ putFloat() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putFloat ( object self,
object o,
long offset,
float x )
static

Implementation of native method 'putFloat'.

Parameters
self
o
offset
x

Definition at line 684 of file Unsafe.cs.

685 {
686#if FIRST_PASS
687 throw new NotImplementedException();
688#else
689 try
690 {
691 switch (o)
692 {
693 case null:
694 Marshal.WriteInt32((IntPtr)offset, global::java.lang.Float.floatToRawIntBits(x));
695 break;
696 case RuntimeJavaType w:
697 PutField(w, offset, x);
698 break;
699 case Array array:
700 WriteInt32(array, offset, global::java.lang.Float.floatToRawIntBits(x));
701 break;
702 default:
703 PutField(o, offset, x);
704 break;
705 }
706 }
707 catch (Exception e) when (e is not global::java.lang.Throwable)
708 {
709 throw new global::java.lang.InternalError(e);
710 }
711#endif
712 }

◆ putFloatVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putFloatVolatile ( object self,
object o,
long offset,
float x )
static

Implementation of native method 'putFloatVolatile'.

Parameters
self
o
offset
x

Definition at line 2316 of file Unsafe.cs.

2317 {
2318#if FIRST_PASS
2319 throw new NotImplementedException();
2320#else
2321 try
2322 {
2323 switch (o)
2324 {
2325 case null:
2326 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<float>((void*)(IntPtr)offset), x);
2327 break;
2328 case RuntimeJavaType w:
2329 PutFieldVolatile(w, offset, x);
2330 break;
2331 case Array array:
2332 WriteInt32Volatile(array, offset, global::java.lang.Float.floatToRawIntBits(x));
2333 break;
2334 default:
2335 PutFieldVolatile(o, offset, x);
2336 break;
2337 }
2338 }
2339 catch (Exception e) when (e is not global::java.lang.Throwable)
2340 {
2341 throw new global::java.lang.InternalError(e);
2342 }
2343#endif
2344 }

◆ putInt() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putInt ( object self,
long address,
int x )
static

Implementation of native method 'putInt'.

Parameters
self
address
x

Definition at line 940 of file Unsafe.cs.

941 {
942#if FIRST_PASS
943 throw new NotImplementedException();
944#else
945 try
946 {
947 Marshal.WriteInt32((IntPtr)address, x);
948 }
949 catch (Exception e) when (e is not global::java.lang.Throwable)
950 {
951 throw new global::java.lang.InternalError(e);
952 }
953#endif
954 }

◆ putInt() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putInt ( object self,
object o,
long offset,
int x )
static

Implementation of native method 'putInt'.

Parameters
self
o
offset
x

Definition at line 552 of file Unsafe.cs.

553 {
554#if FIRST_PASS
555 throw new NotImplementedException();
556#else
557 try
558 {
559 switch (o)
560 {
561 case null:
562 Marshal.WriteInt32((IntPtr)offset, x);
563 break;
564 case RuntimeJavaType w:
565 PutField(w, offset, x);
566 break;
567 case Array array:
568 WriteInt32(array, offset, x);
569 break;
570 default:
571 PutField(o, offset, x);
572 break;
573 }
574 }
575 catch (Exception e) when (e is not global::java.lang.Throwable)
576 {
577 throw new global::java.lang.InternalError(e);
578 }
579#endif
580 }

◆ putIntVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putIntVolatile ( object self,
object o,
long offset,
int x )
static

Implementation of native method 'putIntVolatile'.

Parameters
self
o
offset
x

Definition at line 1927 of file Unsafe.cs.

1928 {
1929#if FIRST_PASS
1930 throw new NotImplementedException();
1931#else
1932 try
1933 {
1934 switch (o)
1935 {
1936 case null:
1937 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<int>((void*)(IntPtr)offset), x);
1938 break;
1939 case RuntimeJavaType w:
1940 PutFieldVolatile(w, offset, x);
1941 break;
1942 case Array array:
1943 WriteInt32Volatile(array, offset, x);
1944 break;
1945 default:
1946 PutFieldVolatile(o, offset, x);
1947 break;
1948 }
1949 }
1950 catch (Exception e) when (e is not global::java.lang.Throwable)
1951 {
1952 throw new global::java.lang.InternalError(e);
1953 }
1954#endif
1955 }

◆ putLong() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putLong ( object self,
long address,
long x )
static

Implementation of native method 'putLong'.

Parameters
self
address
x

Definition at line 984 of file Unsafe.cs.

985 {
986#if FIRST_PASS
987 throw new NotImplementedException();
988#else
989 try
990 {
991 Marshal.WriteInt64((IntPtr)address, x);
992 }
993 catch (Exception e) when (e is not global::java.lang.Throwable)
994 {
995 throw new global::java.lang.InternalError(e);
996 }
997#endif
998 }

◆ putLong() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putLong ( object self,
object o,
long offset,
long x )
static

Implementation of native method 'putLong'.

Parameters
self
o
offset
x

Definition at line 618 of file Unsafe.cs.

619 {
620#if FIRST_PASS
621 throw new NotImplementedException();
622#else
623 try
624 {
625 switch (o)
626 {
627 case null:
628 Marshal.WriteInt64((IntPtr)offset, x);
629 break;
630 case RuntimeJavaType w:
631 PutField(w, offset, x);
632 break;
633 case Array array:
634 WriteInt64(array, offset, x);
635 break;
636 default:
637 PutField(o, offset, x);
638 break;
639 }
640 }
641 catch (Exception e) when (e is not global::java.lang.Throwable)
642 {
643 throw new global::java.lang.InternalError(e);
644 }
645#endif
646 }

◆ putLongVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putLongVolatile ( object self,
object o,
long offset,
long x )
static

Implementation of native method 'putLongVolatile'.

Parameters
self
o
offset
x

Definition at line 2251 of file Unsafe.cs.

2252 {
2253#if FIRST_PASS
2254 throw new NotImplementedException();
2255#else
2256 try
2257 {
2258 switch (o)
2259 {
2260 case null:
2261 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<long>((void*)(IntPtr)offset), x);
2262 break;
2263 case RuntimeJavaType w:
2264 PutFieldVolatile(w, offset, x);
2265 break;
2266 case Array array:
2267 WriteInt64Volatile(array, offset, x);
2268 break;
2269 default:
2270 PutFieldVolatile(o, offset, x);
2271 break;
2272 }
2273 }
2274 catch (Exception e) when (e is not global::java.lang.Throwable)
2275 {
2276 throw new global::java.lang.InternalError(e);
2277 }
2278#endif
2279 }

◆ putObject()

static void IKVM.Java.Externs.sun.misc.Unsafe.putObject ( object self,
object o,
long offset,
object x )
static

Implementation of native method 'putObject'.

Parameters
self
o
offset
x

Definition at line 223 of file Unsafe.cs.

224 {
225#if FIRST_PASS
226 throw new NotImplementedException();
227#else
228 try
229 {
230 switch (o)
231 {
232 case RuntimeJavaType w:
233 PutField(w, offset, x);
234 break;
235 case object[] array:
236 array[offset / IntPtr.Size] = x;
237 break;
238 case object obj:
239 PutField(obj, offset, x);
240 break;
241 default:
242 throw new global::java.lang.IllegalArgumentException();
243 }
244 }
245 catch (Exception e) when (e is not global::java.lang.Throwable)
246 {
247 throw new global::java.lang.InternalError(e);
248 }
249#endif
250 }

◆ putObjectVolatile()

static void IKVM.Java.Externs.sun.misc.Unsafe.putObjectVolatile ( object self,
object o,
long offset,
object x )
static

Implementation of native method 'putObjectVolatile'.

Parameters
self
o
offset
x

Definition at line 1859 of file Unsafe.cs.

1860 {
1861#if FIRST_PASS
1862 throw new NotImplementedException();
1863#else
1864 try
1865 {
1866 switch (o)
1867 {
1868 case RuntimeJavaType w:
1869 PutField(w, offset, x);
1870 break;
1871 case object[] array when array.GetType() == typeof(object[]):
1872 Volatile.Write(ref array[offset / IntPtr.Size], x);
1873 break;
1874 case object[] array:
1875 PutArrayObjectVolatile(array, offset, x);
1876 break;
1877 case object obj:
1878 PutFieldVolatile(o, offset, x);
1879 break;
1880 default:
1881 throw new global::java.lang.IllegalArgumentException();
1882 }
1883 }
1884 catch (Exception e) when (e is not global::java.lang.Throwable)
1885 {
1886 throw new global::java.lang.InternalError(e);
1887 }
1888#endif
1889 }

◆ putOrderedInt()

static void IKVM.Java.Externs.sun.misc.Unsafe.putOrderedInt ( object self,
object o,
long offset,
int x )
static

Definition at line 2416 of file Unsafe.cs.

2417 {
2418 putIntVolatile(self, o, offset, x);
2419 }
static unsafe void putIntVolatile(object self, object o, long offset, int x)
Implementation of native method 'putIntVolatile'.
Definition Unsafe.cs:1927

◆ putOrderedLong()

static void IKVM.Java.Externs.sun.misc.Unsafe.putOrderedLong ( object self,
object o,
long offset,
long x )
static

Definition at line 2421 of file Unsafe.cs.

2422 {
2423 putLongVolatile(self, o, offset, x);
2424 }
static unsafe void putLongVolatile(object self, object o, long offset, long x)
Implementation of native method 'putLongVolatile'.
Definition Unsafe.cs:2251

◆ putOrderedObject()

static void IKVM.Java.Externs.sun.misc.Unsafe.putOrderedObject ( object self,
object o,
long offset,
object x )
static

Definition at line 2411 of file Unsafe.cs.

2412 {
2413 putObjectVolatile(self, o, offset, x);
2414 }
static void putObjectVolatile(object self, object o, long offset, object x)
Implementation of native method 'putObjectVolatile'.
Definition Unsafe.cs:1859

◆ putShort() [1/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putShort ( object self,
long address,
short x )
static

Implementation of native method 'putShort'.

Parameters
self
address
x

Definition at line 852 of file Unsafe.cs.

853 {
854#if FIRST_PASS
855 throw new NotImplementedException();
856#else
857 try
858 {
859 Marshal.WriteInt16((IntPtr)address, x);
860 }
861 catch (Exception e) when (e is not global::java.lang.Throwable)
862 {
863 throw new global::java.lang.InternalError(e);
864 }
865#endif
866 }

◆ putShort() [2/2]

static void IKVM.Java.Externs.sun.misc.Unsafe.putShort ( object self,
object o,
long offset,
short x )
static

Implementation of native method 'putShort'.

Parameters
self
o
offset
x

Definition at line 420 of file Unsafe.cs.

421 {
422#if FIRST_PASS
423 throw new NotImplementedException();
424#else
425 try
426 {
427 switch (o)
428 {
429 case null:
430 Marshal.WriteInt16((IntPtr)offset, x);
431 break;
432 case RuntimeJavaType w:
433 PutField(w, offset, x);
434 break;
435 case Array array:
436 WriteInt16(array, offset, x);
437 break;
438 default:
439 PutField(o, offset, x);
440 break;
441 }
442 }
443 catch (Exception e) when (e is not global::java.lang.Throwable)
444 {
445 throw new global::java.lang.InternalError(e);
446 }
447#endif
448 }

◆ putShortVolatile()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.putShortVolatile ( object self,
object o,
long offset,
short x )
static

Implementation of native method 'putShortVolatile'.

Parameters
self
o
offset
x

Definition at line 2123 of file Unsafe.cs.

2124 {
2125#if FIRST_PASS
2126 throw new NotImplementedException();
2127#else
2128 try
2129 {
2130 switch (o)
2131 {
2132 case null:
2133 Volatile.Write(ref System.Runtime.CompilerServices.Unsafe.AsRef<short>((void*)(IntPtr)offset), x);
2134 break;
2135 case RuntimeJavaType w:
2136 PutFieldVolatile(w, offset, x);
2137 break;
2138 case Array array:
2139 WriteInt16Volatile(array, offset, x);
2140 break;
2141 default:
2142 PutFieldVolatile(o, offset, x);
2143 break;
2144 }
2145 }
2146 catch (Exception e) when (e is not global::java.lang.Throwable)
2147 {
2148 throw new global::java.lang.InternalError(e);
2149 }
2150#endif
2151 }

◆ reallocateMemory()

static unsafe long IKVM.Java.Externs.sun.misc.Unsafe.reallocateMemory ( object self,
long address,
long bytes )
static

Implementation of native method 'reallocateMemory'.

Parameters
self
address
bytes
Returns
Exceptions
global::java.lang.OutOfMemoryError

Definition at line 1160 of file Unsafe.cs.

1161 {
1162#if FIRST_PASS
1163 throw new NotImplementedException();
1164#else
1165 try
1166 {
1167 if (bytes == 0)
1168 {
1169 freeMemory(self, address);
1170 return 0;
1171 }
1172
1173 // remove memory pressure
1174 var ptr = (IntPtr)address - sizeof(IntPtr);
1175 var len = Marshal.ReadIntPtr(ptr);
1176 System.GC.RemoveMemoryPressure((long)len);
1177
1178 // reallocate and add memory pressure
1179 len = (IntPtr)bytes + sizeof(IntPtr);
1180 ptr = Marshal.ReAllocHGlobal(ptr, len);
1181 Marshal.WriteIntPtr(ptr, len);
1182 System.GC.AddMemoryPressure((long)len);
1183 return (long)ptr + sizeof(IntPtr);
1184 }
1185 catch (OutOfMemoryException e)
1186 {
1187 throw new global::java.lang.OutOfMemoryError(e.Message).initCause(e);
1188 }
1189 catch (Exception e) when (e is not global::java.lang.Throwable)
1190 {
1191 throw new global::java.lang.InternalError(e);
1192 }
1193#endif
1194 }
static unsafe void freeMemory(object self, long address)
Implementation of native method 'freeMemory'.
Definition Unsafe.cs:1361

◆ registerNatives()

static void IKVM.Java.Externs.sun.misc.Unsafe.registerNatives ( )
static

Implementation of native method 'registerNatives'.

Definition at line 130 of file Unsafe.cs.

131 {
132
133 }

◆ setMemory()

static unsafe void IKVM.Java.Externs.sun.misc.Unsafe.setMemory ( object self,
object o,
long offset,
long bytes,
byte value )
static

Implementation of native method 'setMemory'.

Parameters
self
o
offset
bytes
value
Exceptions
global::java.lang.IllegalArgumentException

Definition at line 1205 of file Unsafe.cs.

1206 {
1207#if FIRST_PASS
1208 throw new NotImplementedException();
1209#else
1210 try
1211 {
1212 if (o == null)
1213 new Span<byte>((void*)(IntPtr)offset, (int)bytes).Fill(value);
1214 else if (o is byte[] array)
1215 ((Span<byte>)array).Slice((int)offset, (int)bytes).Fill(value);
1216 else if (o is Array array2)
1217 {
1218 GCHandle h = new();
1219
1220 try
1221 {
1222 h = GCHandle.Alloc(array2, GCHandleType.Pinned);
1223 new Span<byte>((byte*)h.AddrOfPinnedObject(), Buffer.ByteLength(array2)).Slice((int)offset, (int)bytes).Fill(value);
1224 }
1225 finally
1226 {
1227 if (h.IsAllocated)
1228 h.Free();
1229 }
1230 }
1231 else
1232 throw new global::java.lang.IllegalArgumentException();
1233 }
1234 catch (Exception e) when (e is not global::java.lang.Throwable)
1235 {
1236 throw new global::java.lang.InternalError(e);
1237 }
1238#endif
1239 }

◆ shouldBeInitialized()

static bool IKVM.Java.Externs.sun.misc.Unsafe.shouldBeInitialized ( object self,
global.java.lang.Class c )
static

Implementation of native method 'shouldBeInitialized'.

Parameters
self
c
Returns

Definition at line 1424 of file Unsafe.cs.

1425 {
1426 return RuntimeJavaType.FromClass(c).HasStaticInitializer;
1427 }

◆ staticFieldBase()

static object IKVM.Java.Externs.sun.misc.Unsafe.staticFieldBase ( object self,
global.java.lang.reflect.Field f )
static

Implementation of native method 'staticFieldBase'.

Parameters
self
f
Returns

Definition at line 1379 of file Unsafe.cs.

1380 {
1381 var w = RuntimeJavaField.FromField(f);
1382 if (w.IsStatic == false)
1383 throw new global::java.lang.IllegalArgumentException();
1384
1385 return w.DeclaringType;
1386 }

◆ staticFieldOffset()

static long IKVM.Java.Externs.sun.misc.Unsafe.staticFieldOffset ( object self,
global.java.lang.reflect.Field f )
static

Implementation of native method 'staticFieldOffset'.

Parameters
self
f
Returns

Definition at line 1394 of file Unsafe.cs.

1395 {
1396 var w = RuntimeJavaField.FromField(f);
1397 if (w.IsStatic == false)
1398 throw new global::java.lang.IllegalArgumentException();
1399
1400 return (long)w.Cookie;
1401 }

◆ storeFence()

static void IKVM.Java.Externs.sun.misc.Unsafe.storeFence ( object self)
static

Definition at line 2714 of file Unsafe.cs.

2715 {
2716 Thread.MemoryBarrier();
2717 }

◆ throwException()

static void IKVM.Java.Externs.sun.misc.Unsafe.throwException ( object self,
Exception ee )
static

Implementation of native method 'throwException'.

Parameters
self
ee

Definition at line 1660 of file Unsafe.cs.

1661 {
1662 throw ee;
1663 }

◆ tryMonitorEnter()

static bool IKVM.Java.Externs.sun.misc.Unsafe.tryMonitorEnter ( object self,
object o )
static

Implementation of native method 'tryMonitorEnter'.

Parameters
self
o
Returns

Definition at line 1650 of file Unsafe.cs.

1651 {
1652 return Monitor.TryEnter(o);
1653 }

◆ unpark()

static void IKVM.Java.Externs.sun.misc.Unsafe.unpark ( object self,
object thread )
static

Implements the native method 'unpark'.

Parameters
self
thread

Definition at line 2624 of file Unsafe.cs.

2625 {
2626#if FIRST_PASS
2627 throw new NotImplementedException();
2628#else
2629 var currentThread = (global::java.lang.Thread)thread;
2630 if (currentThread == null)
2631 throw new global::java.lang.IllegalStateException();
2632
2633 if (currentThread != null)
2634 {
2635 if (Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_PERMIT, PARK_STATE_RUNNING) == PARK_STATE_PARKED)
2636 {
2637 if (Interlocked.CompareExchange(ref currentThread.parkState, PARK_STATE_RUNNING, PARK_STATE_PARKED) == PARK_STATE_PARKED)
2638 {
2639 // initialize lock
2640 Interlocked.CompareExchange(ref currentThread.parkLock, new global::java.lang.Object(), null);
2641
2642 // thread is currently blocking, so we have to release it
2643 lock (currentThread.parkLock)
2644 Monitor.Pulse(currentThread.parkLock);
2645 }
2646 }
2647 }
2648#endif
2649 }

The documentation for this class was generated from the following file: