You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2009/06/19 04:44:32 UTC

svn commit: r786355 - in /lucene/pylucene/trunk/jcc: ./ _jcc/ _jcc/java/io/ _jcc/java/lang/ jcc/

Author: vajda
Date: Fri Jun 19 02:44:32 2009
New Revision: 786355

URL: http://svn.apache.org/viewvc?rev=786355&view=rev
Log:
 - added Java stacktrace to __str__() of JavaError, fixing half of PYLUCENE-1

Added:
    lucene/pylucene/trunk/jcc/_jcc/java/io/
    lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h   (with props)
    lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp   (with props)
Modified:
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/_jcc/boot.cpp
    lucene/pylucene/trunk/jcc/_jcc/java/lang/Exception.cpp
    lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.cpp
    lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.h
    lucene/pylucene/trunk/jcc/jcc/cpp.py
    lucene/pylucene/trunk/jcc/jcc/python.py

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Fri Jun 19 02:44:32 2009
@@ -2,6 +2,7 @@
 Version 2.3 ->
 ------------------
  - added 'typeof' to reserved word list
+ - added Java stacktrace to __str__() of JavaError, fixing half of PYLUCENE-1
  - 
 
 Version 2.2 -> 2.3

Modified: lucene/pylucene/trunk/jcc/_jcc/boot.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/boot.cpp?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/boot.cpp (original)
+++ lucene/pylucene/trunk/jcc/_jcc/boot.cpp Fri Jun 19 02:44:32 2009
@@ -27,6 +27,9 @@
     namespace lang {
         void __install__(PyObject *m);
     }
+    namespace io {
+        void __install__(PyObject *m);
+    }
 }
 
 PyObject *__initialize__(PyObject *module, PyObject *args, PyObject *kwds)
@@ -55,5 +58,6 @@
         INSTALL_TYPE(JObject, m);
         INSTALL_TYPE(ConstVariableDescriptor, m);
         java::lang::__install__(m);
+        java::io::__install__(m);
     }
 }

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp Fri Jun 19 02:44:32 2009
@@ -0,0 +1,87 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "java/io/PrintWriter.h"
+
+namespace java {
+    namespace io {
+
+        enum {
+            mid__init_,
+            max_mid
+        };
+
+        java::lang::Class *PrintWriter::class$ = NULL;
+        jmethodID *PrintWriter::_mids = NULL;
+
+        jclass PrintWriter::initializeClass()
+        {
+            if (!class$)
+            {
+                jclass cls = env->findClass("java/io/PrintWriter");
+
+                _mids = new jmethodID[max_mid];
+                _mids[mid__init_] =
+                    env->getMethodID(cls, "<init>", "(Ljava/io/Writer;)V");
+
+                class$ = (java::lang::Class *) new JObject(cls);
+            }
+
+            return (jclass) class$->this$;
+        }
+
+        PrintWriter::PrintWriter(Writer writer) : Writer(env->newObject(initializeClass, &_mids, mid__init_, writer.this$)) {
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace io {
+
+        static int t_PrintWriter_init(t_PrintWriter *self,
+                                      PyObject *args, PyObject *kwds);
+
+        static PyMethodDef t_PrintWriter__methods_[] = {
+            { NULL, NULL, 0, NULL }
+        };
+
+        DECLARE_TYPE(PrintWriter, t_PrintWriter, Writer,
+                     java::io::PrintWriter, t_PrintWriter_init,
+                     0, 0, 0, 0, 0);
+
+        static int t_PrintWriter_init(t_PrintWriter *self,
+                                      PyObject *args, PyObject *kwds)
+        {
+            Writer writer((jobject) NULL);
+
+            if (!parseArgs(args, "j", Writer::class$, &writer))
+            {
+                INT_CALL(self->object = PrintWriter(writer));
+                return 0;
+            }
+
+            PyErr_SetString(PyExc_ValueError, "invalid args");
+            return -1;
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h Fri Jun 19 02:44:32 2009
@@ -0,0 +1,50 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _PrintWriter_H
+#define _PrintWriter_H
+
+#include <Python.h>
+#include "java/lang/Class.h"
+#include "java/io/Writer.h"
+
+namespace java {
+    namespace io {
+
+        class PrintWriter : public Writer {
+        public:
+            static java::lang::Class *class$;
+            static jmethodID *_mids;
+            static jclass initializeClass();
+
+            explicit PrintWriter(jobject obj) : Writer(obj) {
+                initializeClass();
+            }
+            PrintWriter(Writer writer);
+            PrintWriter(const PrintWriter& obj) : Writer(obj) {}
+        };
+
+        extern PyTypeObject PrintWriter$$Type;
+
+        class t_PrintWriter {
+        public:
+            PyObject_HEAD
+            PrintWriter object;
+            static PyObject *wrap_Object(const PrintWriter& object);
+            static PyObject *wrap_jobject(const jobject& object);
+        };
+    }
+}
+
+#endif /* _PrintWriter_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/PrintWriter.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp Fri Jun 19 02:44:32 2009
@@ -0,0 +1,88 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "java/io/StringWriter.h"
+
+namespace java {
+    namespace io {
+
+        enum {
+            mid__init_,
+            max_mid
+        };
+
+        java::lang::Class *StringWriter::class$ = NULL;
+        jmethodID *StringWriter::_mids = NULL;
+
+        jclass StringWriter::initializeClass()
+        {
+            if (!class$)
+            {
+                jclass cls = env->findClass("java/io/StringWriter");
+
+                _mids = new jmethodID[max_mid];
+                _mids[mid__init_] = env->getMethodID(cls, "<init>", "()V");
+
+                class$ = (java::lang::Class *) new JObject(cls);
+            }
+
+            return (jclass) class$->this$;
+        }
+
+        StringWriter::StringWriter() : Writer(env->newObject(initializeClass, &_mids, mid__init_)) {
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace io {
+
+        static int t_StringWriter_init(t_StringWriter *self,
+                                       PyObject *args, PyObject *kwds);
+
+        static PyMethodDef t_StringWriter__methods_[] = {
+            { NULL, NULL, 0, NULL }
+        };
+
+        DECLARE_TYPE(StringWriter, t_StringWriter, Writer,
+                     java::io::StringWriter, t_StringWriter_init,
+                     0, 0, 0, 0, 0);
+
+        static int t_StringWriter_init(t_StringWriter *self,
+                                       PyObject *args, PyObject *kwds)
+        {
+            char *bytes;
+
+            switch (PyTuple_Size(args)) {
+              case 0:
+                INT_CALL(self->object = StringWriter());
+                break;
+              default:
+                PyErr_SetString(PyExc_ValueError, "invalid args");
+                return -1;
+            }
+        
+            return 0;
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h Fri Jun 19 02:44:32 2009
@@ -0,0 +1,50 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _StringWriter_H
+#define _StringWriter_H
+
+#include <Python.h>
+#include "java/lang/Class.h"
+#include "java/io/Writer.h"
+
+namespace java {
+    namespace io {
+
+        class StringWriter : public Writer {
+        public:
+            static java::lang::Class *class$;
+            static jmethodID *_mids;
+            static jclass initializeClass();
+
+            explicit StringWriter(jobject obj) : Writer(obj) {
+                initializeClass();
+            }
+            StringWriter();
+            StringWriter(const StringWriter& obj) : Writer(obj) {}
+        };
+
+        extern PyTypeObject StringWriter$$Type;
+
+        class t_StringWriter {
+        public:
+            PyObject_HEAD
+            StringWriter object;
+            static PyObject *wrap_Object(const StringWriter& object);
+            static PyObject *wrap_jobject(const jobject& object);
+        };
+    }
+}
+
+#endif /* _StringWriter_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/StringWriter.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp Fri Jun 19 02:44:32 2009
@@ -0,0 +1,61 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <jni.h>
+#include "JCCEnv.h"
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "java/io/Writer.h"
+
+namespace java {
+    namespace io {
+
+        enum {
+            max_mid
+        };
+
+        java::lang::Class *Writer::class$ = NULL;
+        jmethodID *Writer::_mids = NULL;
+
+        jclass Writer::initializeClass()
+        {
+            if (!class$)
+            {
+                jclass cls = env->findClass("java/io/Writer");
+
+                _mids = new jmethodID[max_mid];
+                class$ = (java::lang::Class *) new JObject(cls);
+            }
+
+            return (jclass) class$->this$;
+        }
+    }
+}
+
+
+#include "structmember.h"
+#include "functions.h"
+#include "macros.h"
+
+namespace java {
+    namespace io {
+
+        static PyMethodDef t_Writer__methods_[] = {
+            { NULL, NULL, 0, NULL }
+        };
+
+        DECLARE_TYPE(Writer, t_Writer, java::lang::Object, Writer,
+                     abstract_init, 0, 0, 0, 0, 0);
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h Fri Jun 19 02:44:32 2009
@@ -0,0 +1,49 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#ifndef _Writer_H
+#define _Writer_H
+
+#include <Python.h>
+#include "java/lang/Object.h"
+#include "java/lang/Class.h"
+#include "JArray.h"
+
+namespace java {
+    namespace io {
+
+        class Writer : public java::lang::Object {
+        public:
+            static java::lang::Class *class$;
+            static jmethodID *_mids;
+            static jclass initializeClass();
+
+            explicit Writer(jobject obj) : Object(obj) {
+                initializeClass();
+            }
+        };
+
+        extern PyTypeObject Writer$$Type;
+
+        class t_Writer {
+        public:
+            PyObject_HEAD
+            Writer object;
+            static PyObject *wrap_Object(const Writer& object);
+            static PyObject *wrap_jobject(const jobject& object);
+        };
+    }
+}
+
+#endif /* _Writer_H */

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/Writer.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp?rev=786355&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp (added)
+++ lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp Fri Jun 19 02:44:32 2009
@@ -0,0 +1,36 @@
+/*
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <Python.h>
+#include "macros.h"
+
+namespace java {
+    namespace io {
+
+        extern PyTypeObject Writer$$Type;
+        extern PyTypeObject StringWriter$$Type;
+        extern PyTypeObject PrintWriter$$Type;
+        
+        namespace reflect {
+            void __install__(PyObject *module);
+        }
+
+        void __install__(PyObject *m)
+        {
+            INSTALL_TYPE(Writer, m);
+            INSTALL_TYPE(StringWriter, m);
+            INSTALL_TYPE(PrintWriter, m);
+        }
+    }
+}

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/_jcc/java/io/__init__.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: lucene/pylucene/trunk/jcc/_jcc/java/lang/Exception.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/Exception.cpp?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/Exception.cpp (original)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/Exception.cpp Fri Jun 19 02:44:32 2009
@@ -22,7 +22,6 @@
     namespace lang {
 
         enum {
-            mid_printStackTrace,
             max_mid
         };
 
@@ -51,12 +50,11 @@
 namespace java {
     namespace lang {
 
-
         static PyMethodDef t_Exception__methods_[] = {
             { NULL, NULL, 0, NULL }
         };
 
-        DECLARE_TYPE(Exception, t_Exception, Object, java::lang::Exception,
+        DECLARE_TYPE(Exception, t_Exception, Throwable, Exception,
                      abstract_init, 0, 0, 0, 0, 0);
     }
 }

Modified: lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.cpp?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.cpp (original)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.cpp Fri Jun 19 02:44:32 2009
@@ -18,12 +18,14 @@
 #include "java/lang/Class.h"
 #include "java/lang/String.h"
 #include "java/lang/Throwable.h"
+#include "java/io/PrintWriter.h"
 
 namespace java {
     namespace lang {
 
         enum {
-            mid_printStackTrace,
+            mid_printStackTrace_0,
+            mid_printStackTrace_1,
             mid_getMessage,
             max_mid
         };
@@ -38,9 +40,12 @@
                 jclass cls = env->findClass("java/lang/Throwable");
 
                 _mids = new jmethodID[max_mid];
-                _mids[mid_printStackTrace] = 
+                _mids[mid_printStackTrace_0] = 
                     env->getMethodID(cls, "printStackTrace",
                                      "()V");
+                _mids[mid_printStackTrace_1] = 
+                    env->getMethodID(cls, "printStackTrace",
+                                     "(Ljava/io/PrintWriter;)V");
                 _mids[mid_getMessage] = 
                     env->getMethodID(cls, "getMessage",
                                      "()Ljava/lang/String;");
@@ -53,7 +58,13 @@
 
         void Throwable::printStackTrace() const
         {
-            env->callVoidMethod(this$, _mids[mid_printStackTrace]);
+            env->callVoidMethod(this$, _mids[mid_printStackTrace_0]);
+        }
+        
+        void Throwable::printStackTrace(java::io::PrintWriter writer) const
+        {
+            env->callVoidMethod(this$, _mids[mid_printStackTrace_1],
+                                writer.this$);
         }
         
         String Throwable::getMessage() const
@@ -71,20 +82,39 @@
 namespace java {
     namespace lang {
 
-        static PyObject *t_Throwable_printStackTrace(t_Throwable *self);
+        static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
+                                                     PyObject *args);
 
         static PyMethodDef t_Throwable__methods_[] = {
-            DECLARE_METHOD(t_Throwable, printStackTrace, METH_NOARGS),
+            DECLARE_METHOD(t_Throwable, printStackTrace, METH_VARARGS),
             { NULL, NULL, 0, NULL }
         };
 
-        DECLARE_TYPE(Throwable, t_Throwable, Object, java::lang::Throwable,
+        DECLARE_TYPE(Throwable, t_Throwable, Object, Throwable,
                      abstract_init, 0, 0, 0, 0, 0);
 
-        static PyObject *t_Throwable_printStackTrace(t_Throwable *self)
+        static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
+                                                     PyObject *args)
         {
-            OBJ_CALL(self->object.printStackTrace());
-            Py_RETURN_NONE;
+            switch (PyTuple_Size(args)) {
+              case 0:
+                OBJ_CALL(self->object.printStackTrace());
+                Py_RETURN_NONE;
+              case 1:
+              {
+                  java::io::PrintWriter writer((jobject) NULL);
+
+                  if (!parseArgs(args, "j", java::io::PrintWriter::class$,
+                                 &writer))
+                  {
+                      OBJ_CALL(self->object.printStackTrace(writer));
+                      Py_RETURN_NONE;
+                  }
+              }
+              default:
+                PyErr_SetString(PyExc_ValueError, "invalid args");
+                return NULL;
+            }
         }
     }
 }

Modified: lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.h?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.h (original)
+++ lucene/pylucene/trunk/jcc/_jcc/java/lang/Throwable.h Fri Jun 19 02:44:32 2009
@@ -21,6 +21,11 @@
 #include "JArray.h"
 
 namespace java {
+
+    namespace io {
+        class PrintWriter;
+    }
+
     namespace lang {
         class String;
 
@@ -35,6 +40,7 @@
             }
 
             void printStackTrace() const;
+            void printStackTrace(java::io::PrintWriter) const;
             String getMessage() const;
         };
 

Modified: lucene/pylucene/trunk/jcc/jcc/cpp.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/cpp.py?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/cpp.py (original)
+++ lucene/pylucene/trunk/jcc/jcc/cpp.py Fri Jun 19 02:44:32 2009
@@ -46,12 +46,24 @@
 
 
 class JavaError(Exception):
+
     def getJavaException(self):
+
         return self.args[0]
 
+    def __str__(self):
+
+        writer = StringWriter()
+        self.getJavaException().printStackTrace(PrintWriter(writer))
+
+        return '\n'.join((super(JavaError, self).__str__(),
+                          "Java stacktrace:", str(writer)))
+
+
 class InvalidArgsError(Exception):
     pass
 
+
 _jcc._setExceptionTypes(JavaError, InvalidArgsError)
 from _jcc import *
 
@@ -403,6 +415,8 @@
             typeset.add(findClass('java/lang/Double'))
             typeset.add(findClass('java/util/Iterator'))
             typeset.add(findClass('java/util/Enumeration'))
+            typeset.add(findClass('java/io/StringWriter'))
+            typeset.add(findClass('java/io/PrintWriter'))
             packages.add('java.lang')
 
         if moduleName:

Modified: lucene/pylucene/trunk/jcc/jcc/python.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/python.py?rev=786355&r1=786354&r2=786355&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/python.py (original)
+++ lucene/pylucene/trunk/jcc/jcc/python.py Fri Jun 19 02:44:32 2009
@@ -1332,6 +1332,10 @@
     line(out, 0, 'class JavaError(Exception):')
     line(out, 1, 'def getJavaException(self):')
     line(out, 2, 'return self.args[0]')
+    line(out, 1, 'def __str__(self):')
+    line(out, 2, 'writer = %s.StringWriter()', extname)
+    line(out, 2, 'self.getJavaException().printStackTrace(%s.PrintWriter(writer))', extname)
+    line(out, 2, 'return "\\n".join((super(JavaError, self).__str__(), "    Java stacktrace:", str(writer)))')
     line(out)
     line(out, 0, 'class InvalidArgsError(Exception):')
     line(out, 1, 'pass')