You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
47
external/ikvm/openjdk/sun/misc/Unsafe.java
vendored
47
external/ikvm/openjdk/sun/misc/Unsafe.java
vendored
@@ -32,7 +32,6 @@ import cli.System.Security.Permissions.SecurityPermissionAttribute;
|
||||
import ikvm.lang.Internal;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ReflectHelper;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -57,10 +56,13 @@ public final class Unsafe
|
||||
return theUnsafe;
|
||||
}
|
||||
|
||||
private static native Field createFieldAndMakeAccessible(Class c, String field);
|
||||
private static native Field copyFieldAndMakeAccessible(Field field);
|
||||
|
||||
// this is the intrinsified version of objectFieldOffset(XXX.class.getDeclaredField("xxx"))
|
||||
public long objectFieldOffset(Class c, String field)
|
||||
{
|
||||
return allocateUnsafeFieldId(ReflectHelper.createFieldAndMakeAccessible(c, field));
|
||||
return allocateUnsafeFieldId(createFieldAndMakeAccessible(c, field));
|
||||
}
|
||||
|
||||
// NOTE we have a really lame (and slow) implementation!
|
||||
@@ -72,6 +74,15 @@ public final class Unsafe
|
||||
}
|
||||
return allocateUnsafeFieldId(field);
|
||||
}
|
||||
|
||||
public long staticFieldOffset(Field field)
|
||||
{
|
||||
if(!Modifier.isStatic(field.getModifiers()))
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return allocateUnsafeFieldId(field);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int fieldOffset(Field original)
|
||||
@@ -81,7 +92,7 @@ public final class Unsafe
|
||||
|
||||
static int allocateUnsafeFieldId(Field original)
|
||||
{
|
||||
Field copy = ReflectHelper.copyFieldAndMakeAccessible(original);
|
||||
Field copy = copyFieldAndMakeAccessible(original);
|
||||
synchronized(fields)
|
||||
{
|
||||
int id = fields.size();
|
||||
@@ -850,6 +861,10 @@ public final class Unsafe
|
||||
@cli.System.Security.SecurityCriticalAttribute.Annotation
|
||||
public long allocateMemory(long bytes)
|
||||
{
|
||||
if (bytes == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (false) throw new cli.System.OutOfMemoryException();
|
||||
@@ -861,6 +876,26 @@ public final class Unsafe
|
||||
}
|
||||
}
|
||||
|
||||
@SecurityPermissionAttribute.Annotation(value = SecurityAction.__Enum.LinkDemand, UnmanagedCode = true)
|
||||
@cli.System.Security.SecurityCriticalAttribute.Annotation
|
||||
public long reallocateMemory(long address, long bytes)
|
||||
{
|
||||
if (bytes == 0)
|
||||
{
|
||||
freeMemory(address);
|
||||
return 0;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (false) throw new cli.System.OutOfMemoryException();
|
||||
return Marshal.ReAllocHGlobal(IntPtr.op_Explicit(address), IntPtr.op_Explicit(bytes)).ToInt64();
|
||||
}
|
||||
catch (cli.System.OutOfMemoryException x)
|
||||
{
|
||||
throw new OutOfMemoryError(x.get_Message());
|
||||
}
|
||||
}
|
||||
|
||||
@SecurityPermissionAttribute.Annotation(value = SecurityAction.__Enum.LinkDemand, UnmanagedCode = true)
|
||||
@cli.System.Security.SecurityCriticalAttribute.Annotation
|
||||
public void freeMemory(long address)
|
||||
@@ -1126,6 +1161,12 @@ public final class Unsafe
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Object staticFieldBase(Class<?> c)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public native boolean shouldBeInitialized(Class<?> c);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user