[pylucene-dev] Re: using JCC
Andi Vajda
vajda at osafoundation.org
Wed Feb 20 19:21:44 PST 2008
On Wed, 20 Feb 2008, Bill Janssen wrote:
>>> Sure enough, that's the difference. Adding "--package java.lang" to
>>> the "python -m jcc" line, as PyLucene does, somehow changes the gcc
>>> command line, and things compile.
>>
>> No, it just causes header files to be found that are missing otherwise or
>> incorrect. The bug in JCC could be that these files are required and not
>> optional. I wonder if the gcj ones were not present if this bug would be
>> replaced by a missing header error. It'd be interesting to know which header
>> if causing this. JCC is already generating some wrappers for essential JRE
>> classes like Object and Class. Maybe more are required.
>>
>> I'm still not convinced it's a JCC bug, though :)
>
> Let me try to convince you. When I omit "--package java.lang", JCC
> still generates header files for some small set of java.lang.*. One
> of these is java.lang.RuntimeException. This file contains
>
> #include "java/lang/Exception.h"
>
> The only "java/lang/Exception.h" on my whole machine is this:
>
> % locate java/lang/Exception.h
> /usr/include/c++/4.1.2/java/lang/Exception.h
> /usr/local/gcc-3.4.5/include/java/lang/Exception.h
> %
>
> Now, "/usr/include/c++/4.1.2/java/lang/Exception.h" includes
> "java/lang/Throwable.h", which in turn includes "gcj/array.h".
>
> I'm not sure where JCC expects java/lang/Exception.h to come from if
> you don't generate it. It certainly isn't part of the Sun JDK.
Right. The Sun JDK doesn't include any of the Java class header files as
these don't exist. It's a gcj feature to expose Java as C++. This is what
made gcj-PyLucene originally possible and this is what JCC aims to replace.
JCC will generate the wrappers and header files all the superclasses of a
class (recursively) that is requested. So, by requesting wrappers for
java.lang.RuntimeException as is hardcoded in cpp.py, I should be getting
the one for java.lang.Exception - its parent class - and for
java.lang.Throwable, Exception's parent class.
If java/lang/Exception.h and java/lang/Throwable.h are not being generated,
then there is a bug somewhere.
Looking at the code more, the bug became apparent :)
The code that does include-the-parent trick is called _before_
RuntimeException is added to the pile. My bad.
The untested (there is a lunar eclipse going on) patch below should solve
the problem.
Andi..
Index: jcc/cpp.py
===================================================================
--- jcc/cpp.py (revision 383)
+++ jcc/cpp.py (working copy)
@@ -341,6 +341,8 @@
typeset.add(cls)
cls = cls.getSuperclass()
typeset.add(env.findClass('java/lang/Class'))
+ typeset.add(env.findClass('java/lang/Throwable'))
+ typeset.add(env.findClass('java/lang/Exception'))
typeset.add(env.findClass('java/lang/RuntimeException'))
if moduleName:
typeset.add(env.findClass('java/lang/Number'))
More information about the pylucene-dev
mailing list