RFC: Handling special cases during VM startup
Gary Benson
gbenson@redhat.com
Thu Jul 27 13:32:00 GMT 2006
Hi all,
Currently there is no way to tell whether the VM is initalized, and
thus no way to handle things which must be done differently during
VM startup. There is one special case like this, in VMThrowable: the
flag trace_enabled is used to inhibit stack trace generation. I need
to add another special case; I could use trace_enabled, or I could
make another flag, but it seems a better idea to do something generic.
There is a global variable runtimeInitialized, but it is set before
initialization starts rather than after it is complete. Apart from
preventing multiple calls to _Jv_CreateJavaVM it is only used once,
in natClassLoader.cc, and there it seems to be used as though it were
set after initialization.
I propose changing _Jv_CreateJavaVM to set runtimeInitialized after
initialization completes, and changing VMThrowable to use it. The
attached patch does this.
Comments?
Cheers,
Gary
-------------- next part --------------
Index: ChangeLog
===================================================================
--- ChangeLog (revision 115772)
+++ ChangeLog (working copy)
@@ -1,3 +1,13 @@
+2006-07-27 Gary Benson <gbenson@redhat.com>
+
+ * prims.cc (_Jv_CreateJavaVM): Move setting runtimeInitialized
+ from the start to the end of the function. Remove references
+ to VMThrowable.trace_enabled.
+ * java/lang/natVMThrowable.cc (fillInStackTrace): Use
+ runtimeInitialized rather than trace_enabled to decide
+ whether to inhibit stack trace generation.
+ * java/lang/VMThrowable.java (trace_enabled): Removed.
+
2006-07-23 Mohan Embar <gnustuff@thisiscool.com>
* include/win32-threads.h (_Jv_Thread_t): Explicitly
Index: prims.cc
===================================================================
--- prims.cc (revision 115772)
+++ prims.cc (working copy)
@@ -56,7 +56,6 @@
#include <java/lang/NullPointerException.h>
#include <java/lang/OutOfMemoryError.h>
#include <java/lang/System.h>
-#include <java/lang/VMThrowable.h>
#include <java/lang/VMClassLoader.h>
#include <java/lang/reflect/Modifier.h>
#include <java/io/PrintStream.h>
@@ -1404,8 +1403,6 @@
if (runtimeInitialized)
return -1;
- runtimeInitialized = true;
-
jint result = parse_init_args (vm_args);
if (result < 0)
return -1;
@@ -1447,10 +1444,6 @@
_Jv_InitPrimClass (&_Jv_doubleClass, "double", 'D', 8);
_Jv_InitPrimClass (&_Jv_voidClass, "void", 'V', 0);
- // Turn stack trace generation off while creating exception objects.
- _Jv_InitClass (&java::lang::VMThrowable::class$);
- java::lang::VMThrowable::trace_enabled = 0;
-
// We have to initialize this fairly early, to avoid circular class
// initialization. In particular we want to start the
// initialization of ClassLoader before we start the initialization
@@ -1465,8 +1458,6 @@
no_memory = new java::lang::OutOfMemoryError;
- java::lang::VMThrowable::trace_enabled = 1;
-
#ifdef USE_LTDL
LTDL_SET_PRELOADED_SYMBOLS ();
#endif
@@ -1489,6 +1480,8 @@
{
}
+ runtimeInitialized = true;
+
return 0;
}
Index: java/lang/natVMThrowable.cc
===================================================================
--- java/lang/natVMThrowable.cc (revision 115772)
+++ java/lang/natVMThrowable.cc (working copy)
@@ -1,6 +1,6 @@
// natVMThrowable.cc - Native part of VMThrowable class.
-/* Copyright (C) 2003 Free Software Foundation
+/* Copyright (C) 2003, 2006 Free Software Foundation
This file is part of libgcj.
@@ -27,7 +27,7 @@
using namespace java::lang;
// Don't trace stack during initialization of the runtime.
- if (! trace_enabled)
+ if (! gcj::runtimeInitialized)
return NULL;
_Jv_StackTrace *trace = _Jv_StackTrace::GetStackTrace ();
Index: java/lang/VMThrowable.java
===================================================================
--- java/lang/VMThrowable.java (revision 115772)
+++ java/lang/VMThrowable.java (working copy)
@@ -1,5 +1,6 @@
/* java.lang.VMThrowable -- VM support methods for Throwable.
- Copyright (C) 1998, 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -76,9 +77,6 @@
*/
native StackTraceElement[] getStackTrace(Throwable t);
- // Setting this flag to false prevents fillInStackTrace() from running.
- static boolean trace_enabled = true;
-
// Native stack data.
private RawDataManaged data;
}
More information about the Java-patches
mailing list