harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r540768 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: include/classloader.h src/init/vm_init.cpp src/jni/jni.cpp src/kernel_classes/javasrc/java/lang/Thread.java
Date Tue, 22 May 2007 21:56:09 GMT
Author: gshimansky
Date: Tue May 22 14:56:08 2007
New Revision: 540768

URL: http://svn.apache.org/viewvc?view=rev&rev=540768
Log:
Applied HARMONY-3891 [drlvm][thread] null Thread.currentThread in custom system classloader
constructor


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h?view=diff&rev=540768&r1=540767&r2=540768
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h Tue May 22 14:56:08 2007
@@ -212,6 +212,7 @@
     void Mark() { m_markBit = true; }
     bool isMarked() { return m_markBit; }
     ManagedObject* GetLoader() { return m_loader; }
+    ManagedObject** GetLoaderHandle() { return &m_loader; }
     const String* GetName() { return m_name; }
     ClassLoader* GetParent() { return m_parent; }
     Package_Table* getPackageTable() { return m_package_table; }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=540768&r1=540767&r2=540768
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Tue May 22 14:56:08 2007
@@ -25,6 +25,7 @@
 #include "port_dso.h"
 
 #include "open/gc.h"
+#include "open/jthread.h"   // this is for jthread_self()
 #include "open/thread_externals.h"
 
 #include "init.h"
@@ -450,6 +451,19 @@
     return JNI_OK;
 }
 
+static jint set_main_thread_context_loader(JNIEnv* jni_env) {
+    Global_Env* vm_env = jni_get_vm_env(jni_env);
+    jthread main_thread = jthread_self();
+    jfieldID scl_field = jni_env->GetFieldID(jni_env->GetObjectClass(main_thread),
+        "contextClassLoader", "Ljava/lang/ClassLoader;");
+    assert(scl_field);
+    jobject loader = jni_env->NewLocalRef((jobject)(vm_env->system_class_loader->GetLoaderHandle()));
+    jni_env->SetObjectField(main_thread, scl_field, loader);
+    jni_env->DeleteLocalRef(loader);
+
+    return JNI_OK;
+}
+
 #define PROCESS_EXCEPTION(messageId, message) \
 { \
     LECHO(messageId, message << "Internal error: "); \
@@ -856,6 +870,8 @@
     }
 
     TRACE("system class loader initialized");
+
+    set_main_thread_context_loader(jni_env);
 
     status = run_java_init(jni_env);
     if (status != JNI_OK) return status;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=540768&r1=540767&r2=540768
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Tue May 22 14:56:08 2007
@@ -519,17 +519,17 @@
     finalizer_threads_init(java_vm);   /* added for NATIVE FINALIZER THREAD */
     ref_enqueue_thread_init(java_vm);  /* added for NATIVE REFERENCE ENQUEUE THREAD */
     
-    // Now JVMTIThread keeps global reference. Discared temporary global reference.
+    // Now JVMTIThread keeps global reference. Discard temporary global reference.
     jni_env->DeleteGlobalRef(java_thread);
 
-    // Send VM start event. JNI services are available now.
-    // JVMTI services permited in the start phase are available as well.
-    jvmti_send_vm_start_event(vm_env, jni_env);
-
     status = vm_init2(jni_env);
     if (status != JNI_OK) {
         goto done;
     }
+
+    // Send VM start event. JNI services are available now.
+    // JVMTI services permited in the start phase are available as well.
+    jvmti_send_vm_start_event(vm_env, jni_env);
 
     // The VM is fully initialized now.
     vm_env->vm_state = Global_Env::VM_RUNNING;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java?view=diff&rev=540768&r1=540767&r2=540768
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
Tue May 22 14:56:08 2007
@@ -225,8 +225,6 @@
                 systemThreadGroup = new ThreadGroup();
                 mainThreadGroup = new ThreadGroup(systemThreadGroup, "main");
                 group = mainThreadGroup;
-                // Initialize system class loader.
-                contextLoader = ClassLoader.getSystemClassLoader();
             } else {
                 group = mainThreadGroup;
             }



Mime
View raw message