Index: trunk/vm/tests/smoke/shutdown/TestWaitSet.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestWaitSet.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestWaitSet.java (revision 0) @@ -0,0 +1,34 @@ +package shutdown; + +public class TestWaitSet { + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (sync) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("PASSED"); + } + + static class WorkerThread extends Thread { + public void run() { + synchronized (sync) { + try { + sync.notify(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + } +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestFatalError.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.java (revision 0) @@ -0,0 +1,37 @@ +package shutdown; + +public class TestFatalError { + private static Object sync = new Object(); + + static { + System.loadLibrary("TestFatalError"); + } + + public static native void sendFatalError(); + + public static void main(String[] args) { + synchronized (sync) { + Thread permanentThread = new PermanentThread(); + permanentThread.start(); + Thread hook = new HookThread(); + Runtime.getRuntime().addShutdownHook(hook); + sendFatalError(); + System.out.println("FAILED"); + } + } + + static class PermanentThread extends Thread { + public void run() { + synchronized (sync) { + System.out.println("FAILED"); + } + } + + } + + static class HookThread extends Thread { + public void run() { + System.out.println("FAILED"); + } + } +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestFatalError.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.c (revision 0) @@ -0,0 +1,7 @@ +#include "TestFatalError.h" + +JNIEXPORT void JNICALL Java_shutdown_TestFatalError_sendFatalError + (JNIEnv * jni_env, jclass clazz) +{ + (*jni_env)->FatalError(jni_env, "PASSED"); +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.h (revision 0) @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestInterrupt */ + +#ifndef _Included_shutdown_TestInterrupt +#define _Included_shutdown_TestInterrupt +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: shutdown_TestInterrupt + * Method: sendInterrupt + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h (revision 0) @@ -0,0 +1,27 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestNativeAllocation_WorkerThread */ + +#ifndef _Included_shutdown_TestNativeAllocation_WorkerThread +#define _Included_shutdown_TestNativeAllocation_WorkerThread +#ifdef __cplusplus +extern "C" { +#endif +#undef shutdown_TestNativeAllocation_WorkerThread_MIN_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_MIN_PRIORITY 1L +#undef shutdown_TestNativeAllocation_WorkerThread_NORM_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_NORM_PRIORITY 5L +#undef shutdown_TestNativeAllocation_WorkerThread_MAX_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_MAX_PRIORITY 10L +/* + * Class: shutdown_TestNativeAllocation_WorkerThread + * Method: callJNI + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestNativeAllocation_00024WorkerThread_callJNI + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestFatalError.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.h (revision 0) @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestFatalError */ + +#ifndef _Included_shutdown_TestFatalError +#define _Included_shutdown_TestFatalError +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: shutdown_TestFatalError + * Method: sendFatalError + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestFatalError_sendFatalError + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestLock.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestLock.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestLock.java (revision 0) @@ -0,0 +1,50 @@ +package shutdown; + +public class TestLock { + private static Object start = new Object(); + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (start) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + start.wait(); + Thread locked = new LockedThread(); + locked.setDaemon(true); + locked.start(); + start.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("PASSED"); + } + + static class WorkerThread extends Thread { + public void run() { + synchronized (sync) { + synchronized (start) { + start.notify(); + } + while (true) { + Thread.yield(); + } + } + } + } + + static class LockedThread extends Thread { + public void run() { + synchronized (start) { + start.notify(); + } + synchronized (sync) { + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + } + +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.java (revision 0) @@ -0,0 +1,35 @@ +package shutdown; + +public class TestInterrupt { + private static Object sync = new Object(); + + static { + System.loadLibrary("TestInterrupt"); + } + + public static native void sendInterrupt(); + + public static void main(String[] args) { + synchronized (sync) { + try { + Thread hook = new HookThread(); + Runtime.getRuntime().addShutdownHook(hook); + sendInterrupt(); + sync.wait(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("FAILED"); + } + + static class HookThread extends Thread { + public void run() { + synchronized (sync) { + sync.notify(); + } + System.out.println("PASSED"); + } + } +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java (revision 0) @@ -0,0 +1,56 @@ +package shutdown; + +public class TestNativeAllocation { + private static Object start = new Object(); + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (start) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + start.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + } + + static class WorkerThread extends Thread { + private int recursion = 0; + + static { + System.loadLibrary("TestNativeAllocation"); + } + + + public native void callJNI(); + + public void calledFromJNI() { + if (recursion < 30) { + ++recursion; + run(); + } + synchronized (sync) { + synchronized (start) { + start.notify(); + } + try { + // wait here forever + sync.wait(); + } catch (Throwable e) { + System.out.println("FAILED"); + } finally { + System.out.println("FAILED"); + } + } + System.out.println("FAILED"); + } + + public void run() { + callJNI(); + System.out.println("FAILED"); + } + } +} Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.c (revision 0) @@ -0,0 +1,24 @@ +#include "TestInterrupt.h" + +#if defined (_WIN32) || defined (__WIN32__) || defined (WIN32) +#include + +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv * jni_env, jclass clazz) +{ + printf("HAH Signalling...."); + GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); +} + +#else + +#include + +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv * jni_env, jclass clazz) +{ + printf("Signalling...."); + raise(SIGINT); +} + +#endif \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c (revision 0) @@ -0,0 +1,36 @@ + +#include "TestNativeAllocation.h" + +/* + * Class: shutdown_TestNativeAllocation_WorkerThread + * Method: callJNI + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestNativeAllocation_00024WorkerThread_callJNI + (JNIEnv * jni_env, jobject thread) +{ + static int allocated = 0; + jclass thread_class; + jmethodID methID; + + ++allocated; + thread_class = (*jni_env)->GetObjectClass(jni_env, thread); + methID = (*jni_env)->GetMethodID(jni_env, thread_class, "calledFromJNI", "()V"); + if (methID == NULL) { + --allocated; + if (allocated == 0) { + printf("PASSED"); + } + return; + } + + (*jni_env)->CallVoidMethod(jni_env, thread, methID); + if ((*jni_env)->ExceptionOccurred(jni_env)) { + --allocated; + if (allocated == 0) { + printf("PASSED"); + } + return; + } + printf("FAILED"); +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestFatalError.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.c (revision 0) @@ -0,0 +1,7 @@ +#include "TestFatalError.h" + +JNIEXPORT void JNICALL Java_shutdown_TestFatalError_sendFatalError + (JNIEnv * jni_env, jclass clazz) +{ + (*jni_env)->FatalError(jni_env, "PASSED"); +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestFatalError.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.h (revision 0) @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestFatalError */ + +#ifndef _Included_shutdown_TestFatalError +#define _Included_shutdown_TestFatalError +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: shutdown_TestFatalError + * Method: sendFatalError + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestFatalError_sendFatalError + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestFatalError.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestFatalError.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestFatalError.java (revision 0) @@ -0,0 +1,37 @@ +package shutdown; + +public class TestFatalError { + private static Object sync = new Object(); + + static { + System.loadLibrary("TestFatalError"); + } + + public static native void sendFatalError(); + + public static void main(String[] args) { + synchronized (sync) { + Thread permanentThread = new PermanentThread(); + permanentThread.start(); + Thread hook = new HookThread(); + Runtime.getRuntime().addShutdownHook(hook); + sendFatalError(); + System.out.println("FAILED"); + } + } + + static class PermanentThread extends Thread { + public void run() { + synchronized (sync) { + System.out.println("FAILED"); + } + } + + } + + static class HookThread extends Thread { + public void run() { + System.out.println("FAILED"); + } + } +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.c (revision 0) @@ -0,0 +1,24 @@ +#include "TestInterrupt.h" + +#if defined (_WIN32) || defined (__WIN32__) || defined (WIN32) +#include + +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv * jni_env, jclass clazz) +{ + printf("HAH Signalling...."); + GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); +} + +#else + +#include + +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv * jni_env, jclass clazz) +{ + printf("Signalling...."); + raise(SIGINT); +} + +#endif \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.h (revision 0) @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestInterrupt */ + +#ifndef _Included_shutdown_TestInterrupt +#define _Included_shutdown_TestInterrupt +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: shutdown_TestInterrupt + * Method: sendInterrupt + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestInterrupt_sendInterrupt + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestInterrupt.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestInterrupt.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestInterrupt.java (revision 0) @@ -0,0 +1,35 @@ +package shutdown; + +public class TestInterrupt { + private static Object sync = new Object(); + + static { + System.loadLibrary("TestInterrupt"); + } + + public static native void sendInterrupt(); + + public static void main(String[] args) { + synchronized (sync) { + try { + Thread hook = new HookThread(); + Runtime.getRuntime().addShutdownHook(hook); + sendInterrupt(); + sync.wait(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("FAILED"); + } + + static class HookThread extends Thread { + public void run() { + synchronized (sync) { + sync.notify(); + } + System.out.println("PASSED"); + } + } +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestLock.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestLock.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestLock.java (revision 0) @@ -0,0 +1,50 @@ +package shutdown; + +public class TestLock { + private static Object start = new Object(); + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (start) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + start.wait(); + Thread locked = new LockedThread(); + locked.setDaemon(true); + locked.start(); + start.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("PASSED"); + } + + static class WorkerThread extends Thread { + public void run() { + synchronized (sync) { + synchronized (start) { + start.notify(); + } + while (true) { + Thread.yield(); + } + } + } + } + + static class LockedThread extends Thread { + public void run() { + synchronized (start) { + start.notify(); + } + synchronized (sync) { + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + } + +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c (revision 0) @@ -0,0 +1,36 @@ + +#include "TestNativeAllocation.h" + +/* + * Class: shutdown_TestNativeAllocation_WorkerThread + * Method: callJNI + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestNativeAllocation_00024WorkerThread_callJNI + (JNIEnv * jni_env, jobject thread) +{ + static int allocated = 0; + jclass thread_class; + jmethodID methID; + + ++allocated; + thread_class = (*jni_env)->GetObjectClass(jni_env, thread); + methID = (*jni_env)->GetMethodID(jni_env, thread_class, "calledFromJNI", "()V"); + if (methID == NULL) { + --allocated; + if (allocated == 0) { + printf("PASSED"); + } + return; + } + + (*jni_env)->CallVoidMethod(jni_env, thread, methID); + if ((*jni_env)->ExceptionOccurred(jni_env)) { + --allocated; + if (allocated == 0) { + printf("PASSED"); + } + return; + } + printf("FAILED"); +} \ No newline at end of file Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.h (revision 0) @@ -0,0 +1,27 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class shutdown_TestNativeAllocation_WorkerThread */ + +#ifndef _Included_shutdown_TestNativeAllocation_WorkerThread +#define _Included_shutdown_TestNativeAllocation_WorkerThread +#ifdef __cplusplus +extern "C" { +#endif +#undef shutdown_TestNativeAllocation_WorkerThread_MIN_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_MIN_PRIORITY 1L +#undef shutdown_TestNativeAllocation_WorkerThread_NORM_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_NORM_PRIORITY 5L +#undef shutdown_TestNativeAllocation_WorkerThread_MAX_PRIORITY +#define shutdown_TestNativeAllocation_WorkerThread_MAX_PRIORITY 10L +/* + * Class: shutdown_TestNativeAllocation_WorkerThread + * Method: callJNI + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_shutdown_TestNativeAllocation_00024WorkerThread_callJNI + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif Index: trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java (revision 0) @@ -0,0 +1,56 @@ +package shutdown; + +public class TestNativeAllocation { + private static Object start = new Object(); + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (start) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + start.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + } + + static class WorkerThread extends Thread { + private int recursion = 0; + + static { + System.loadLibrary("TestNativeAllocation"); + } + + + public native void callJNI(); + + public void calledFromJNI() { + if (recursion < 30) { + ++recursion; + run(); + } + synchronized (sync) { + synchronized (start) { + start.notify(); + } + try { + // wait here forever + sync.wait(); + } catch (Throwable e) { + System.out.println("FAILED"); + } finally { + System.out.println("FAILED"); + } + } + System.out.println("FAILED"); + } + + public void run() { + callJNI(); + System.out.println("FAILED"); + } + } +} Index: trunk/vm/tests/smoke/shutdown/TestWaitSet.java =================================================================== --- trunk/vm/tests/smoke/shutdown/TestWaitSet.java (revision 0) +++ trunk/vm/tests/smoke/shutdown/TestWaitSet.java (revision 0) @@ -0,0 +1,34 @@ +package shutdown; + +public class TestWaitSet { + private static Object sync = new Object(); + + public static void main(String[] args) { + synchronized (sync) { + try { + Thread worker = new WorkerThread(); + worker.setDaemon(true); + worker.start(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + } + System.out.println("PASSED"); + } + + static class WorkerThread extends Thread { + public void run() { + synchronized (sync) { + try { + sync.notify(); + sync.wait(); + } catch (InterruptedException e) { + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + System.out.println("FAILED"); + } + } +} \ No newline at end of file