Makefile.am: New friends for java/lang/Thread.h.
* Makefile.am: New friends for java/lang/Thread.h. * prims.cc (runFirst): Removed. (JvRunMain): Merged into _Jv_RunMain. Now just calls that. (_Jv_RunMain): Now takes either a klass or class name parameter. Create a gnu.gcj.runtime.FirstThread and attach the native thread to that, then run it using _Jv_ThreadRun. Remove special handling of jar files, instead pass is_jar parameter through to FirstThread. * gcj/javaprims.h: Add prototypes for _Jv_ThreadRun and new variant of _Jv_AttachCurrentThread. * gnu/gcj/runtime/FirstThread.java (FirstThread): Now extends Thread. (run): New method. Take care of looking up main class manifest attribute and calling forName if neccessary. Then call call_main. (call_main): New native method. * gnu/gcj/runtime/natFirstThread.cc (call_main): New function, code relocated from prims.cc. Look up and call main method. * java/lang/Thread.java (run_): Removed. * java/lang/natThread.cc (run_): Renamed to... (_Jv_ThreadRun): this. JVMPI notification code moved to ... (_Jv_NotifyThreadStart): here. New function. (countStackFrames, destroy, resume, suspend, stop): Throw UnsupportedOperationExceptions rather than JvFail'ing. (_Jv_AttachCurrentThread): New variant takes a Thread argument. Existing version wraps new variant. From-SVN: r45182
This commit is contained in:
parent
387edc7625
commit
2dc55bc99f
11 changed files with 264 additions and 1174 deletions
|
@ -109,8 +109,6 @@ public class Thread implements Runnable
|
|||
|
||||
public final native void resume ();
|
||||
|
||||
// This method exists only to avoid a warning from the C++ compiler.
|
||||
private static final native void run_ (Object obj);
|
||||
private final native void finish_ ();
|
||||
|
||||
// Check the thread's interrupted status. If clear_flag is true, the
|
||||
|
|
|
@ -87,7 +87,8 @@ jint
|
|||
java::lang::Thread::countStackFrames (void)
|
||||
{
|
||||
// NOTE: This is deprecated in JDK 1.2.
|
||||
JvFail ("java::lang::Thread::countStackFrames unimplemented");
|
||||
throw new UnsupportedOperationException
|
||||
(JvNewStringLatin1 ("Thread.countStackFrames unimplemented"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,8 @@ java::lang::Thread::destroy (void)
|
|||
{
|
||||
// NOTE: This is marked as unimplemented in the JDK 1.2
|
||||
// documentation.
|
||||
JvFail ("java::lang::Thread::destroy unimplemented");
|
||||
throw new UnsupportedOperationException
|
||||
(JvNewStringLatin1 ("Thread.destroy unimplemented"));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -142,7 +144,8 @@ void
|
|||
java::lang::Thread::resume (void)
|
||||
{
|
||||
checkAccess ();
|
||||
JvFail ("java::lang::Thread::resume unimplemented");
|
||||
throw new UnsupportedOperationException
|
||||
(JvNewStringLatin1 ("Thread.resume unimplemented"));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -213,12 +216,11 @@ java::lang::Thread::finish_ ()
|
|||
_Jv_MutexUnlock (&nt->join_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
java::lang::Thread::run_ (jobject obj)
|
||||
// Run once at thread startup, either when thread is attached or when
|
||||
// _Jv_ThreadRun is called.
|
||||
static void
|
||||
_Jv_NotifyThreadStart (java::lang::Thread* thread)
|
||||
{
|
||||
java::lang::Thread *thread = (java::lang::Thread *) obj;
|
||||
try
|
||||
{
|
||||
#ifdef ENABLE_JVMPI
|
||||
if (_Jv_JVMPI_Notify_THREAD_START)
|
||||
{
|
||||
|
@ -272,7 +274,14 @@ java::lang::Thread::run_ (jobject obj)
|
|||
_Jv_EnableGC ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_Jv_ThreadRun (java::lang::Thread* thread)
|
||||
{
|
||||
try
|
||||
{
|
||||
_Jv_NotifyThreadStart (thread);
|
||||
thread->run ();
|
||||
}
|
||||
catch (java::lang::Throwable *t)
|
||||
|
@ -304,14 +313,14 @@ java::lang::Thread::start (void)
|
|||
alive_flag = true;
|
||||
startable_flag = false;
|
||||
natThread *nt = (natThread *) data;
|
||||
_Jv_ThreadStart (this, nt->thread, (_Jv_ThreadStartFunc *) &run_);
|
||||
_Jv_ThreadStart (this, nt->thread, (_Jv_ThreadStartFunc *) &_Jv_ThreadRun);
|
||||
}
|
||||
|
||||
void
|
||||
java::lang::Thread::stop (java::lang::Throwable *)
|
||||
{
|
||||
throw new UnsupportedOperationException
|
||||
(JvNewStringLatin1 ("java::lang::Thread::stop unimplemented"));
|
||||
(JvNewStringLatin1 ("Thread.stop unimplemented"));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -319,7 +328,7 @@ java::lang::Thread::suspend (void)
|
|||
{
|
||||
checkAccess ();
|
||||
throw new UnsupportedOperationException
|
||||
(JvNewStringLatin1 ("java::lang::Thread::suspend unimplemented"));
|
||||
(JvNewStringLatin1 ("Thread.suspend unimplemented"));
|
||||
}
|
||||
|
||||
static int nextThreadNumber = 0;
|
||||
|
@ -373,6 +382,20 @@ _Jv_SetCurrentJNIEnv (JNIEnv *env)
|
|||
((natThread *) t->data)->jni_env = env;
|
||||
}
|
||||
|
||||
// Attach the current native thread to an existing (but unstarted) Thread
|
||||
// object. Returns -1 on failure, 0 upon success.
|
||||
jint
|
||||
_Jv_AttachCurrentThread(java::lang::Thread* thread)
|
||||
{
|
||||
if (thread == NULL || thread->startable_flag == false)
|
||||
return -1;
|
||||
thread->startable_flag = false;
|
||||
thread->alive_flag = true;
|
||||
natThread *nt = (natThread *) thread->data;
|
||||
_Jv_ThreadRegister (nt->thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
java::lang::Thread*
|
||||
_Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
|
||||
{
|
||||
|
@ -382,10 +405,8 @@ _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
|
|||
if (name == NULL)
|
||||
name = java::lang::Thread::gen_name ();
|
||||
thread = new java::lang::Thread (NULL, group, NULL, name);
|
||||
thread->startable_flag = false;
|
||||
thread->alive_flag = true;
|
||||
natThread *nt = (natThread *) thread->data;
|
||||
_Jv_ThreadRegister (nt->thread);
|
||||
_Jv_AttachCurrentThread (thread);
|
||||
_Jv_NotifyThreadStart (thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue