2003-04-16  Tom Tromey  <tromey@redhat.com>

	* java/lang/natClassLoader.cc (_Jv_RegisterClasses): Don't set
	`state' for compiled class.
	(_Jv_FindClass): Unconditionally wait for class to be `loaded'.
	(_Jv_WaitForState): Added special case for compiled classes and
	JV_STATE_LOADED.

Index: libjava/java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.58
diff -u -r1.58 natClassLoader.cc
--- libjava/java/lang/natClassLoader.cc 30 Jan 2003 23:20:45 -0000 1.58
+++ libjava/java/lang/natClassLoader.cc 16 Apr 2003 23:53:19 -0000
@@ -1,6 +1,6 @@
 // natClassLoader.cc - Implementation of java.lang.ClassLoader native methods.
 
-/* Copyright (C) 1999, 2000, 2001, 2002  Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -113,7 +113,11 @@
   
   _Jv_MonitorEnter (klass) ;
 
-  if (state == JV_STATE_LINKED)
+  // FIXME: this works around some deficiencies in how we handle
+  // compiled classes.  Right now they don't properly enter
+  // JV_STATE_LOADING, so we work around it here.
+  if (state == JV_STATE_LINKED
+      || (! _Jv_IsInterpretedClass (klass) && state == JV_STATE_LOADED))
     {
       // Must call _Jv_PrepareCompiledClass while holding the class
       // mutex.
@@ -405,11 +409,6 @@
       jclass klass = *classes;
 
       (*_Jv_RegisterClassHook) (klass);
-
-      // registering a compiled class causes
-      // it to be immediately "prepared".  
-      if (klass->state == JV_STATE_NOTHING)
-	klass->state = JV_STATE_COMPILED;
     }
 }
 
@@ -502,12 +501,13 @@
 	    _Jv_RegisterInitiatingLoader (klass, 0);
 	}
     }
-  else
-    {
-      // we need classes to be in the hash while
-      // we're loading, so that they can refer to themselves. 
-      _Jv_WaitForState (klass, JV_STATE_LOADED);
-    }
+
+  // We need classes to be in the hash while we're loading, so that
+  // they can refer to themselves.  We do this unconditionally
+  // because we can get a non-"loaded" compiled class here.  FIXME:
+  // should finish loading compiled classes earlier, but that means
+  // adding a new post-load hook.
+  _Jv_WaitForState (klass, JV_STATE_LOADED);
 
   return klass;
 }
