This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: Re: Logging broken ?
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Andreas Grunewald <gruni at users dot sourceforge dot net>
- Cc: Andrew Haley <aph at redhat dot com>, java at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Wed, 06 Apr 2005 13:39:11 -0400
- Subject: Patch: Re: Logging broken ?
- References: <4252872B.8010507@users.sourceforge.net> <16978.41976.79862.307079@cuddles.cambridge.redhat.com> <4252B952.5090102@users.sourceforge.net>
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;
}