* src/native/vm/java_lang_Thread.h,
authortwisti <none@none>
Tue, 26 Dec 2006 23:14:46 +0000 (23:14 +0000)
committertwisti <none@none>
Tue, 26 Dec 2006 23:14:46 +0000 (23:14 +0000)
src/native/vm/java_lang_Class.c,
src/native/vm/java_lang_Object.c,
src/native/vm/java_lang_Thread.c,
src/native/vm/java_lang_Class.h,
src/native/vm/java_lang_Object.h: Java ME changes.

src/native/vm/java_lang_Class.c
src/native/vm/java_lang_Class.h
src/native/vm/java_lang_Object.c
src/native/vm/java_lang_Object.h
src/native/vm/java_lang_Thread.c
src/native/vm/java_lang_Thread.h

index e44694cdcdd9c5e6b91a0b63785fa7711b887cc7..05b370892c09562d12c9f9dc2049407b440b9384 100644 (file)
 #include "native/jni.h"
 #include "native/native.h"
 #include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
 #include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_VMClass.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/java_security_ProtectionDomain.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ClassLoader.h"
+# include "native/include/java_lang_reflect_Constructor.h"
+# include "native/include/java_lang_reflect_Field.h"
+# include "native/include/java_lang_reflect_Method.h"
+#endif
+
 #include "native/vm/java_lang_Class.h"
 #include "toolbox/logging.h"
 #include "vm/builtin.h"
 #include "vm/stringlocal.h"
 
 
+/*
+ * Class:     java/lang/Class
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass)
+{
+       classinfo        *c;
+       java_lang_String *s;
+       u4                i;
+
+       c = (classinfo *) klass;
+
+       /* create a java string */
+
+       s = (java_lang_String *) javastring_new(c->name);
+
+       if (s == NULL)
+               return NULL;
+
+       /* return string where '/' is replaced by '.' */
+
+       for (i = 0; i < s->value->header.size; i++) {
+               if (s->value->data[i] == '/')
+                       s->value->data[i] = '.';
+       }
+
+       return s;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    forName
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+#if defined(ENABLE_JAVASE)
+java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader)
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name)
+#endif
+{
+       classinfo *c;
+       utf       *u;
+       u2        *pos;
+       s4         i;
+
+       /* illegal argument */
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* name must not contain '/' (mauve test) */
+
+       for (i = 0, pos = name->value->data + name->offset; i < name->count; i++, pos++) {
+               if (*pos == '/') {
+                       *exceptionptr =
+                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
+                       return NULL;
+               }
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       u = javastring_toutf(name, true);
+
+       /* try to load, ... */
+
+#if defined(ENABLE_JAVASE)
+       if (!(c = load_class_from_classloader(u, (java_objectheader *) loader))) {
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+       if (!(c = load_class_bootstrap(u))) {
+#endif
+               classinfo *xclass;
+
+               xclass = (*exceptionptr)->vftbl->class;
+
+               /* if the exception is a NoClassDefFoundError, we replace it with a
+                  ClassNotFoundException, otherwise return the exception */
+
+               if (xclass == class_java_lang_NoClassDefFoundError) {
+                       /* clear exceptionptr, because builtin_new checks for 
+                          ExceptionInInitializerError */
+                       *exceptionptr = NULL;
+
+                       *exceptionptr =
+                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
+               }
+
+           return NULL;
+       }
+
+       /* link, ... */
+
+       if (!link_class(c))
+               return NULL;
+       
+       /* ...and initialize it, if required */
+
+#if defined(ENABLE_JAVASE)
+       if (initialize)
+#endif
+               if (!initialize_class(c))
+                       return NULL;
+
+       return (java_lang_Class *) c;
+}
+
+
+#if defined(ENABLE_JAVASE)
+
 /*
  * Class:     java/lang/Class
  * Method:    isInstance
@@ -157,37 +272,6 @@ s4 _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass)
 }
 
 
-/*
- * Class:     java/lang/Class
- * Method:    getName
- * Signature: ()Ljava/lang/String;
- */
-java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass)
-{
-       classinfo        *c;
-       java_lang_String *s;
-       u4                i;
-
-       c = (classinfo *) klass;
-
-       /* create a java string */
-
-       s = (java_lang_String *) javastring_new(c->name);
-
-       if (s == NULL)
-               return NULL;
-
-       /* return string where '/' is replaced by '.' */
-
-       for (i = 0; i < s->value->header.size; i++) {
-               if (s->value->data[i] == '/')
-                       s->value->data[i] = '.';
-       }
-
-       return s;
-}
-
-
 /*
  * Class:     java/lang/Class
  * Method:    getSuperclass
@@ -682,76 +766,6 @@ java_lang_ClassLoader *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass
 }
 
 
-/*
- * Class:     java/lang/VMClass
- * Method:    forName
- * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
- */
-java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader)
-{
-       classinfo *c;
-       utf       *u;
-       u2        *pos;
-       s4         i;
-
-       /* illegal argument */
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* name must not contain '/' (mauve test) */
-
-       for (i = 0, pos = name->value->data + name->offset; i < name->count; i++, pos++) {
-               if (*pos == '/') {
-                       *exceptionptr =
-                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
-                       return NULL;
-               }
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       u = javastring_toutf(name, true);
-
-       /* try to load, ... */
-
-       if (!(c = load_class_from_classloader(u, (java_objectheader *) loader))) {
-               classinfo *xclass;
-
-               xclass = (*exceptionptr)->vftbl->class;
-
-               /* if the exception is a NoClassDefFoundError, we replace it with a
-                  ClassNotFoundException, otherwise return the exception */
-
-               if (xclass == class_java_lang_NoClassDefFoundError) {
-                       /* clear exceptionptr, because builtin_new checks for 
-                          ExceptionInInitializerError */
-                       *exceptionptr = NULL;
-
-                       *exceptionptr =
-                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
-               }
-
-           return NULL;
-       }
-
-       /* link, ... */
-
-       if (!link_class(c))
-               return NULL;
-       
-       /* ...and initialize it, if required */
-
-       if (initialize)
-               if (!initialize_class(c))
-                       return NULL;
-
-       return (java_lang_Class *) c;
-}
-
-
 /*
  * Class:     java/lang/Class
  * Method:    isArray
@@ -1017,6 +1031,8 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass cla
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
 #endif
 
+#endif /* ENABLE_JAVASE */
+
 
 /*
  * These are local overrides for various environment variables in Emacs.
index ff2db150522dad0f7ac9f8331435491e24ee9f09..86a31e011caf3ca9a573d28656fa2ae4ec26ddb5 100644 (file)
 
 #include "native/jni.h"
 #include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
 #include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Method.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ClassLoader.h"
+# include "native/include/java_lang_String.h"
+# include "native/include/java_lang_Throwable.h"
+# include "native/include/java_lang_reflect_Constructor.h"
+# include "native/include/java_lang_reflect_Method.h"
+#endif
 
 
 /* function prototypes ********************************************************/
 
+java_lang_String              *_Jv_java_lang_Class_getName(java_lang_Class *klass);
+
+#if defined(ENABLE_JAVASE)
+java_lang_Class               *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader);
 s4                             _Jv_java_lang_Class_isInstance(java_lang_Class *klass, java_lang_Object *o);
 s4                             _Jv_java_lang_Class_isAssignableFrom(java_lang_Class *klass, java_lang_Class *c);
 s4                             _Jv_java_lang_Class_isInterface(java_lang_Class *klass);
 s4                             _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass);
-java_lang_String              *_Jv_java_lang_Class_getName(java_lang_Class *klass);
 java_lang_Class               *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass);
 java_objectarray              *_Jv_java_lang_Class_getInterfaces(java_lang_Class *klass);
 java_lang_Class               *_Jv_java_lang_Class_getComponentType(java_lang_Class *klass);
@@ -64,7 +70,6 @@ java_objectarray              *_Jv_java_lang_Class_getDeclaredFields(java_lang_C
 java_objectarray              *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Class *klass, s4 publicOnly);
 java_objectarray              *_Jv_java_lang_Class_getDeclaredConstructors(java_lang_Class *klass, s4 publicOnly);
 java_lang_ClassLoader         *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass);
-java_lang_Class               *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader);
 s4                             _Jv_java_lang_Class_isArray(java_lang_Class *klass);
 void                           _Jv_java_lang_Class_throwException(java_lang_Throwable *t);
 
@@ -83,6 +88,11 @@ s4                             _Jv_java_lang_Class_isAnonymousClass(JNIEnv *env,
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
 #endif
+#endif /* ENABLE_JAVASE */
+
+#if defined(ENABLE_JAVAME_CLDC1_1)
+java_lang_Class               *_Jv_java_lang_Class_forName(java_lang_String *name);
+#endif
 
 #endif /* _JV_JAVA_LANG_CLASS_H */
 
index a806876023e3c84fd404f1fcfca20bd590e5a26f..8f4ec57a865be47a25379fcd6324fa9db69bee5f 100644 (file)
 #include "native/jni.h"
 #include "native/native.h"
 #include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Cloneable.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_Cloneable.h"
+#endif
+
 #include "native/include/java_lang_Object.h"
 
 #if defined(ENABLE_THREADS)
@@ -75,24 +79,6 @@ java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj)
 }
 
 
-/*
- * Class:     java/lang/Object
- * Method:    clone
- * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
- */
-java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this)
-{
-       java_objectheader *o;
-       java_objectheader *co;
-
-       o = (java_objectheader *) this;
-
-       co = builtin_clone(NULL, o);
-
-       return (java_lang_Object *) co;
-}
-
-
 /*
  * Class:     java/lang/Object
  * Method:    notify
@@ -143,6 +129,28 @@ void _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns)
 }
 
 
+#if defined(ENABLE_JAVASE)
+
+/*
+ * Class:     java/lang/Object
+ * Method:    clone
+ * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
+ */
+java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this)
+{
+       java_objectheader *o;
+       java_objectheader *co;
+
+       o = (java_objectheader *) this;
+
+       co = builtin_clone(NULL, o);
+
+       return (java_lang_Object *) co;
+}
+
+#endif /* ENABLE_JAVASE */
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index b5ff5f674f25c2471f44f57b0306a7c5875b884d..0fdb6d29f0d38d35cc47bf0a38fc1e6cc5b17f08 100644 (file)
 /* function prototypes ********************************************************/
 
 java_lang_Class  *_Jv_java_lang_Object_getClass(java_lang_Object *obj);
-java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this);
 void              _Jv_java_lang_Object_notify(java_lang_Object *this);
 void              _Jv_java_lang_Object_notifyAll(java_lang_Object *this);
 void              _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns);
 
+#if defined(ENABLE_JAVASE)
+
+java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this);
+
+#endif
+
 #endif /* _JV_JAVA_LANG_OBJECT_H */
 
 
index 0868db0bad13b009046d3176a279d93fb662073f..c2e2fe1e5ef0153c869530857533511c6d7e8d56 100644 (file)
 
 #include "native/jni.h"
 #include "native/native.h"
-#include "native/include/java_lang_ThreadGroup.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ThreadGroup.h"
+#endif
+
 #include "native/include/java_lang_Object.h"            /* java_lang_Thread.h */
 #include "native/include/java_lang_Throwable.h"         /* java_lang_Thread.h */
 #include "native/include/java_lang_Thread.h"
@@ -48,6 +52,8 @@
 #endif
 
 #include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
 #include "vm/options.h"
 
 
@@ -64,6 +70,19 @@ s4 _Jv_java_lang_Thread_countStackFrames(java_lang_Thread *this)
 }
 
 
+/*
+ * Class:     java/lang/Thread
+ * Method:    sleep
+ * Signature: (J)V
+ */
+void _Jv_java_lang_Thread_sleep(s8 millis)
+{
+#if defined(ENABLE_THREADS)
+       threads_sleep(millis, 0);
+#endif
+}
+
+
 /*
  * Class:     java/lang/Thread
  * Method:    start
@@ -113,6 +132,8 @@ s4 _Jv_java_lang_Thread_isInterrupted(java_lang_Thread *this)
        thread = (threadobject *) this;
 
        return threads_thread_has_been_interrupted(thread);
+#else
+       return 0;
 #endif
 }
 
@@ -177,7 +198,9 @@ void _Jv_java_lang_Thread_stop(java_lang_Thread *this, java_lang_Throwable *t)
  */
 java_lang_Thread *_Jv_java_lang_Thread_currentThread(void)
 {
+#if defined(ENABLE_THREADS)
        threadobject     *thread;
+#endif
        java_lang_Thread *t;
 
 #if defined(ENABLE_THREADS)
@@ -188,6 +211,7 @@ java_lang_Thread *_Jv_java_lang_Thread_currentThread(void)
        if (t == NULL)
                log_text("t ptr is NULL\n");
   
+# if defined(ENABLE_JAVASE)
        if (t->group == NULL) {
                /* ThreadGroup of currentThread is not initialized */
 
@@ -197,6 +221,7 @@ java_lang_Thread *_Jv_java_lang_Thread_currentThread(void)
                if (t->group == NULL)
                        log_text("unable to create ThreadGroup");
        }
+# endif
 #else
        /* we just return a fake java.lang.Thread object, otherwise we get
        NullPointerException's in GNU classpath */
@@ -230,6 +255,8 @@ s4 _Jv_java_lang_Thread_interrupted(void)
 {
 #if defined(ENABLE_THREADS)
        return threads_check_if_interrupted_and_reset();
+#else
+       return 0;
 #endif
 }
 
@@ -248,10 +275,12 @@ s4 _Jv_java_lang_Thread_holdsLock(java_lang_Object* obj)
 
        if (o == NULL) {
                exceptions_throw_nullpointerexception();
-               return;
+               return 0;
        }
 
        return lock_is_held_by_current_thread(o);
+#else
+       return 0;
 #endif
 }
 
index 95c1dab433205bc220b0bf400191cc11f3ab881b..2dac587b5320c290ea54240f64ec620a5f2f74ba 100644 (file)
 
 #include "native/jni.h"
 #include "native/include/java_lang_String.h"
-#include "native/include/java_lang_ThreadGroup.h"
 #include "native/include/java_lang_Object.h"            /* java_lang_Thread.h */
 #include "native/include/java_lang_Throwable.h"         /* java_lang_Thread.h */
-#include "native/include/java_lang_VMThread.h"
 #include "native/include/java_lang_Thread.h"
 
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ThreadGroup.h"
+#endif
+
+#if defined(WITH_CLASSPATH_GNU)
+# include "native/include/java_lang_VMThread.h"
+#endif
+
 #include "threads/native/threads.h"
 
 
 /* function prototypes ********************************************************/
 
 s4                _Jv_java_lang_Thread_countStackFrames(java_lang_Thread *this);
+void              _Jv_java_lang_Thread_sleep(s8 millis);
 void              _Jv_java_lang_Thread_start(java_lang_Thread *this, s8 stacksize);
 void              _Jv_java_lang_Thread_interrupt(java_lang_Thread *this);
 s4                _Jv_java_lang_Thread_isInterrupted(java_lang_Thread *this);