2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
17 #include "java/lang/Object.h"
18 #include "java/lang/Class.h"
19 #include "java/lang/String.h"
20 #include "java/lang/Throwable.h"
21 #include "java/io/PrintWriter.h"
27 mid_printStackTrace_0,
28 mid_printStackTrace_1,
33 Class *Throwable::class$ = NULL;
34 jmethodID *Throwable::_mids = NULL;
36 jclass Throwable::initializeClass()
40 jclass cls = env->findClass("java/lang/Throwable");
42 _mids = new jmethodID[max_mid];
43 _mids[mid_printStackTrace_0] =
44 env->getMethodID(cls, "printStackTrace",
46 _mids[mid_printStackTrace_1] =
47 env->getMethodID(cls, "printStackTrace",
48 "(Ljava/io/PrintWriter;)V");
49 _mids[mid_getMessage] =
50 env->getMethodID(cls, "getMessage",
51 "()Ljava/lang/String;");
53 class$ = (Class *) new JObject(cls);
56 return (jclass) class$->this$;
59 void Throwable::printStackTrace() const
61 env->callVoidMethod(this$, _mids[mid_printStackTrace_0]);
64 void Throwable::printStackTrace(java::io::PrintWriter writer) const
66 env->callVoidMethod(this$, _mids[mid_printStackTrace_1],
70 String Throwable::getMessage() const
72 return String(env->callObjectMethod(this$, _mids[mid_getMessage]));
78 #include "structmember.h"
79 #include "functions.h"
85 static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
88 static PyMethodDef t_Throwable__methods_[] = {
89 DECLARE_METHOD(t_Throwable, printStackTrace, METH_VARARGS),
90 { NULL, NULL, 0, NULL }
93 DECLARE_TYPE(Throwable, t_Throwable, Object, Throwable,
94 abstract_init, 0, 0, 0, 0, 0);
96 static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
99 switch (PyTuple_Size(args)) {
101 OBJ_CALL(self->object.printStackTrace());
105 java::io::PrintWriter writer((jobject) NULL);
107 if (!parseArgs(args, "j", java::io::PrintWriter::class$,
110 OBJ_CALL(self->object.printStackTrace(writer));
115 PyErr_SetString(PyExc_ValueError, "invalid args");