OSDN Git Service

2005-02-21 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / libjava / java / util / logging / natLogger.cc
1 // natLogger.cc - Native part of Logger class.
2
3 /* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
4
5    This Logger is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the Logger "LIBGCJ_LICENSE" for
9 details.  */
10
11 #include <config.h>
12 #include <platform.h>
13
14 #include <string.h>
15
16 #pragma implementation "Logger.h"
17
18 #include <gcj/cni.h>
19 #include <jvm.h>
20
21
22 #include <java/lang/Object.h>
23 #include <java/lang/Class.h>
24 #include <java/util/logging/Logger.h>
25 #include <java/lang/StackTraceElement.h>
26 #include <java/lang/ArrayIndexOutOfBoundsException.h>
27
28 java::lang::StackTraceElement* 
29 java::util::logging::Logger::getCallerStackFrame ()
30 {
31   gnu::gcj::runtime::StackTrace *t 
32     = new gnu::gcj::runtime::StackTrace(4);
33   java::lang::Class *klass = NULL;
34   int i = 2;
35   try
36     {
37       // skip until this class
38       while ((klass = t->classAt (i)) != getClass())
39         i++;
40       // skip the stackentries of this class
41       while ((klass = t->classAt (i)) == getClass() || klass == NULL)
42         i++;
43     }
44   catch (::java::lang::ArrayIndexOutOfBoundsException *e)
45     {
46       // FIXME: RuntimeError
47     }
48
49   java::lang::StackTraceElement *e 
50     = new java::lang::StackTraceElement
51     (JvNewStringUTF (""), 0, 
52      klass->getName(), t->methodAt(i), false);
53
54   return e;
55 }