FYI: VMAccessController tweak

Gary Benson gbenson@redhat.com
Mon Aug 7 14:29:00 GMT 2006


Hi all,

VMAccessController uses thread-local storage which does not become
available until late in the bootstrap process.  Various methods have
checks to ensure that TLS is not accessed during _Jv_CreateJavaVM(),
but this is not enough.  This commit fixes these checks.

Cheers,
Gary
-------------- next part --------------
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 115995)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2006-08-07  Gary Benson  <gbenson@redhat.com>
+
+	* java/security/VMAccessController.java (pushContext, popContext,
+	getContext): Use Thread.currentThread() to determine when we're
+	bootstrapping.
+	(runtimeInitialized): Remove.
+	* java/security/natVMAccessController.cc (runtimeInitialized):
+	Remove.
+
 2006-08-06  Tom Tromey  <tromey@redhat.com>
 
 	PR libgcj/28491:
Index: java/security/VMAccessController.java
===================================================================
--- java/security/VMAccessController.java	(revision 115995)
+++ java/security/VMAccessController.java	(working copy)
@@ -103,7 +103,7 @@
    */
   static void pushContext (AccessControlContext acc)
   {
-    if (!runtimeInitialized())
+    if (Thread.currentThread() == null)
       return;
 
     if (DEBUG)
@@ -127,7 +127,7 @@
    */
   static void popContext()
   {
-    if (!runtimeInitialized())
+    if (Thread.currentThread() == null)
       return;
 
     if (DEBUG)
@@ -161,7 +161,7 @@
     // so that any security checks succeed.
     //
     // XXX this might not be necessary, but it seems prudent.
-    if (!runtimeInitialized())
+    if (Thread.currentThread() == null)
       return DEFAULT_CONTEXT;
 
     // If we are already in getContext, but called a method that needs
@@ -284,11 +284,4 @@
    *    of Strings comprising the method names.
    */
   private static native Object[][] getStack();
-
-  /**
-   * Tell whether runtime initialization is complete.
-   *
-   * @return whether runtime initialization is complete.
-   */
-  private static native boolean runtimeInitialized();
 }
Index: java/security/natVMAccessController.cc
===================================================================
--- java/security/natVMAccessController.cc	(revision 115995)
+++ java/security/natVMAccessController.cc	(working copy)
@@ -22,9 +22,3 @@
   _Jv_StackTrace *trace = _Jv_StackTrace::GetStackTrace ();
   return _Jv_StackTrace::GetClassMethodStack (trace);
 }
-
-jboolean
-java::security::VMAccessController::runtimeInitialized ()
-{
-  return gcj::runtimeInitialized;
-}


More information about the Java-patches mailing list