[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regression in logger?
From: |
David P Grove |
Subject: |
Re: regression in logger? |
Date: |
Fri, 15 Jul 2005 10:10:47 -0400 |
Thanks Mark!
I just tested classpath cvs head against jikes rvm cvs head on SPECjbb2000
and all is happy again.
--dave
Mark Wielaard <address@hidden> wrote on 07/15/2005 08:52:44 AM:
> Hi,
>
> On Mon, 2005-07-11 at 07:54 -0400, David P Grove wrote:
> > This started showing up in regression tests of Jikes RVM with
classpath
> > cvs head recently. I haven't dug deeply, so it could be a latent
problem
> > in Jikes RVM that was exposed by a classpath change, rather than a
real
> > classpath bug, but might still be worth mentioning. The failing
program
> > is SPECjbb2000.
>
> Unfortunately I don't have a current Jikes RVM setup to test against.
> But I will include this workaround to make the code more robust against
> StackTraceElement[] that are not like it expects (note that
> Throwable.getStackTraceElements() may not contain all frames in general,
> so it isn't a very robust way to walk the stack.)
>
> 2005-07-15 Mark Wielaard <address@hidden>
>
> * java/util/logging/Logger.java (getCallerStackFrame):
> Make sure index < stackTrace.length and return null otherwise.
> (log): Check for caller == null.
>
> Note that this getCallerStackFrame() method is highly inefficient and
> should really use direct runtime support through the VMStackWalker
> methods.
>
> Cheers,
>
> Mark
>
> P.S. Hopefully the last patch before 0.17. Please coordinate on
> irc.gnu.org #classpath if you want some last minute fix in.
> Index: java/util/logging/Logger.java
> ===================================================================
> RCS file: /cvsroot/classpath/classpath/java/util/logging/Logger.java,v
> retrieving revision 1.10
> diff -u -r1.10 Logger.java
> --- java/util/logging/Logger.java 14 Jul 2005 13:16:58 -0000 1.10
> +++ java/util/logging/Logger.java 15 Jul 2005 12:51:12 -0000
> @@ -585,10 +585,10 @@
> String message,
> Object param)
> {
> - StackTraceElement caller = getCallerStackFrame();
> + StackTraceElement caller = getCallerStackFrame();
> logp(level,
> - caller.getClassName(),
> - caller.getMethodName(),
> + caller != null ? caller.getClassName() : "<unknown>",
> + caller != null ? caller.getMethodName() : "<unknown>",
> message,
> param);
> }
> @@ -600,8 +600,8 @@
> {
> StackTraceElement caller = getCallerStackFrame();
> logp(level,
> - caller.getClassName(),
> - caller.getMethodName(),
> + caller != null ? caller.getClassName() : "<unknown>",
> + caller != null ? caller.getMethodName() : "<unknown>",
> message,
> params);
> }
> @@ -611,10 +611,10 @@
> String message,
> Throwable thrown)
> {
> - StackTraceElement caller = getCallerStackFrame();
> + StackTraceElement caller = getCallerStackFrame();
> logp(level,
> - caller.getClassName(),
> - caller.getMethodName(),
> + caller != null ? caller.getClassName() : "<unknown>",
> + caller != null ? caller.getMethodName() : "<unknown>",
> message,
> thrown);
> }
> @@ -1162,19 +1162,25 @@
> /**
> * Gets the StackTraceElement of the first class that is not this
class.
> * That should be the initial caller of a logging method.
> - * @return caller of the initial looging method
> + * @return caller of the initial logging method or null if unknown.
> */
> private StackTraceElement getCallerStackFrame()
> {
> Throwable t = new Throwable();
> StackTraceElement[] stackTrace = t.getStackTrace();
> int index = 0;
> +
> // skip to stackentries until this class
> -
while(!stackTrace[index].getClassName().equals(getClass().getName())){index++;}
> + while(index < stackTrace.length
> + && !stackTrace[index].getClassName().equals(getClass().getName()))
> + index++;
> +
> // skip the stackentries of this class
> -
while(stackTrace[index].getClassName().equals(getClass().getName())){index++;}
> + while(index < stackTrace.length
> + && stackTrace[index].getClassName().equals(getClass().getName()))
> + index++;
>
> - return stackTrace[index];
> + return index < stackTrace.length ? stackTrace[index] : null;
> }
>
> /**
> [attachment "signature.asc" deleted by David P Grove/Watson/IBM]