aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/natThread.cc
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2001-08-26 11:30:09 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2001-08-26 12:30:09 +0100
commit2dc55bc99fbb19ab0df8ae0ec3480f469bceb93e (patch)
tree70a829a7aec07076169c6eefbc98e07abb6aa926 /libjava/java/lang/natThread.cc
parent387edc7625471683c0f26cdb3ecea436495ff4c1 (diff)
downloadgcc-2dc55bc99fbb19ab0df8ae0ec3480f469bceb93e.zip
gcc-2dc55bc99fbb19ab0df8ae0ec3480f469bceb93e.tar.gz
gcc-2dc55bc99fbb19ab0df8ae0ec3480f469bceb93e.tar.bz2
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
Diffstat (limited to 'libjava/java/lang/natThread.cc')
-rw-r--r--libjava/java/lang/natThread.cc51
1 files changed, 36 insertions, 15 deletions
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc
index 66ce7d2..4c0d978 100644
--- a/libjava/java/lang/natThread.cc
+++ b/libjava/java/lang/natThread.cc
@@ -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;
}