OSDN Git Service

PR libgcj/31084
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / natVMThrowable.cc
1 // natVMThrowable.cc - Native part of VMThrowable class.
2
3 /* Copyright (C) 2003, 2006 Free Software Foundation
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #include <config.h>
12
13 #include <stdlib.h>
14
15 #include <gcj/cni.h>
16 #include <jvm.h>
17 #include <java-stack.h>
18
19 #include <java/lang/Throwable.h>
20 #include <java/lang/VMThrowable.h>
21
22 using namespace gnu::gcj;
23
24 java::lang::VMThrowable *
25 java::lang::VMThrowable::fillInStackTrace (java::lang::Throwable *)
26 {
27   using namespace java::lang;
28
29   // Don't trace stack during initialization of the runtime.
30   if (! gcj::runtimeInitialized)
31     return NULL;
32   
33   _Jv_StackTrace *trace = _Jv_StackTrace::GetStackTrace ();
34   VMThrowable *vmthrowable = new VMThrowable ();
35   vmthrowable->data = (RawDataManaged *) trace;
36   return vmthrowable;
37 }
38
39
40 JArray< ::java::lang::StackTraceElement *> *
41 java::lang::VMThrowable::getStackTrace (java::lang::Throwable *throwable)
42 {
43   _Jv_StackTrace *trace = reinterpret_cast <_Jv_StackTrace *> (data);
44   return _Jv_StackTrace::GetStackTraceElements (trace, throwable);
45 }