This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: initialize ProcessManager early


Tom Tromey wrote:
This patch fixes the process -vs- InheritableThreadLocal problem I was
seeing.  It works by initializing the ProcessManager thread early.

This should let us complete mauve testing.

Mark, can you try this with frysk?  If it works I will check it in on
the RH 4.1 branch.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* gnu/java/lang/natMainThread.cc (call_main): Initialize platform
	Process class.
	* java/lang/PosixProcess.java (ProcessManager.run): Never stop
	thread.
	(PosixProcess): Don't start ProcessManager.
	Start ProcessManager in static initializer.


I didn't like this so I wrote my own. How about this untested patch (I didn't even try to compile it yet, and there is no ChangeLog. But if you like it, I will test it.


David Daney
Index: java/lang/PosixProcess.java
===================================================================
--- java/lang/PosixProcess.java	(revision 122045)
+++ java/lang/PosixProcess.java	(working copy)
@@ -42,7 +42,9 @@
 
     ProcessManager()
     {
-      super("ProcessManager");
+      // Use package private Thread constructor to place us in the
+      // root ThreadGroup with no InheritableThreadLocal.
+      super("ProcessManager", true);
       // Don't keep the (main) process from exiting on our account.
       this.setDaemon(true);
     }
Index: java/lang/Thread.java
===================================================================
--- java/lang/Thread.java	(revision 122045)
+++ java/lang/Thread.java	(working copy)
@@ -355,7 +355,7 @@
    */
   public Thread(ThreadGroup group, Runnable target, String name)
   {
-    this(currentThread(), group, target, name);
+    this(currentThread(), group, target, name, false);
   }
 
   /**
@@ -381,11 +381,16 @@
   public Thread(ThreadGroup group, Runnable target, String name, long size)
   {
     // Just ignore stackSize for now.
-    this(currentThread(), group, target, name);
+    this(currentThread(), group, target, name, false);
   }
 
-  private Thread (Thread current, ThreadGroup g, Runnable r, String n)
+  Thread(String name, boolean noInheritableThreadLocal)
   {
+    this(null, null, null, name, noInheritableThreadLocal);
+  }
+  
+  private Thread (Thread current, ThreadGroup g, Runnable r, String n, boolean noInheritableThreadLocal)
+  {
     // Make sure the current thread may create a new thread.
     checkAccess();
     
@@ -423,7 +428,8 @@
         int gmax = group.getMaxPriority();
 	int pri = current.getPriority();
 	priority = (gmax < pri ? gmax : pri);
-	contextClassLoader = current.contextClassLoader;
+        if (!noInheritableThreadLocal)
+          contextClassLoader = current.contextClassLoader;
 	InheritableThreadLocal.newChildThread(this);
       }
     else

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]