mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
implement sun.misc.Unsafe.throwException
This commit is contained in:
parent
f7ce0c4207
commit
8cda2446d5
@ -79,4 +79,6 @@ public final class Unsafe {
|
||||
public void copyMemory(long src, long dst, long count) {
|
||||
copyMemory(null, src, null, dst, count);
|
||||
}
|
||||
|
||||
public native void throwException(Throwable t);
|
||||
}
|
||||
|
@ -757,6 +757,13 @@ Avian_sun_misc_Unsafe_putOrderedInt
|
||||
Avian_sun_misc_Unsafe_putIntVolatile(t, method, arguments);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_throwException
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
vm::throw_(t, reinterpret_cast<object>(arguments[1]));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_avian_Classes_primitiveClass
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
|
@ -5,9 +5,22 @@ public class UnsafeTest {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Unsafe u = avian.Machine.getUnsafe();
|
||||
private static void unsafeThrow(Unsafe u) {
|
||||
u.throwException(new Exception());
|
||||
}
|
||||
|
||||
private static void unsafeCatch(Unsafe u) {
|
||||
boolean success = false;
|
||||
try {
|
||||
unsafeThrow(u);
|
||||
} catch(Exception e) {
|
||||
expect(e.getClass() == Exception.class);
|
||||
success = true;
|
||||
}
|
||||
expect(success);
|
||||
}
|
||||
|
||||
private static void unsafeMemory(Unsafe u) {
|
||||
final long size = 64;
|
||||
long memory = u.allocateMemory(size);
|
||||
try {
|
||||
@ -62,4 +75,11 @@ public class UnsafeTest {
|
||||
u.freeMemory(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Unsafe u = avian.Machine.getUnsafe();
|
||||
|
||||
unsafeCatch(u);
|
||||
unsafeMemory(u);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user