This is the mail archive of the java@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]

Patch: Re: Logging broken ?


Andreas Grunewald wrote:

> Well, it's hard for us without Windows platforms to know what the
> cause of your problem might be.  However, my guess is that you have
> some kind of problem with stack traces.

Ok so here is the output of my hello.exe

G:\2005-extraextra>hello
Now starting to LOG
Exception in thread "main" java.lang.NullPointerException
   at 0x00416a3e (Unknown Source)
   at 0x00416f32 (Unknown Source)


Here's a patch that should prevent Logger.log() throwing NullPointerException when the caller (stack) information is not available. This patch is against HEAD, but its possible that something similar needs to be applied to 3.4. I'm checking it in.

Bryce


2005-04-06  Bryce McKinlay  <mckinlay@redhat.com>

	* java/util/logging/natLogger.cc (getCallerStackFrame): Don't crash on
	NULL klass and meth values from _Jv_StackTrace::GetCallerInfo().

Index: java/util/logging/natLogger.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/logging/natLogger.cc,v
retrieving revision 1.2
diff -u -r1.2 natLogger.cc
--- java/util/logging/natLogger.cc	10 Mar 2005 19:02:21 -0000	1.2
+++ java/util/logging/natLogger.cc	6 Apr 2005 17:31:51 -0000
@@ -34,10 +34,16 @@
   _Jv_Method *meth = NULL;
   _Jv_StackTrace::GetCallerInfo (&Logger::class$, &klass, &meth);
 
+  jstring meth_name = NULL;
+  jstring klass_name = NULL;
+  if (klass != NULL)
+    klass_name = klass->getName();
+  if (meth != NULL)
+    meth_name = _Jv_NewStringUtf8Const (meth->name);
+  
   java::lang::StackTraceElement *e 
     = new java::lang::StackTraceElement
-    (JvNewStringUTF (""), 0, 
-     klass->getName(), _Jv_NewStringUtf8Const (meth->name), false);
+    (JvNewStringUTF (""), 0, klass_name, meth_name, false);
 
   return e;
 }

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