[pylucene-dev] Re: using JCC

Andi Vajda vajda at osafoundation.org
Tue Feb 19 19:58:30 PST 2008


On Tue, 19 Feb 2008, Bill Janssen wrote:

> This may be a question for a JCC mailing list, but...

Good point, there is no JCC mailing list at the moment. JCC hasn't graduated 
yet on its own except as a source egg released on Cheeseshop [1].
If there is interest in using JCC outside of PyLucene, I'd certainly be open 
to separating it out for good and give it its own homepage and mailing list.
Until then, it's fine to use this list for JCC topics.

> I've got a big Java library I'd like to wrap with JCC.  It's a small
> jar file which depends on a huge poorly-engineered library of various
> cruft from lots of sources.  Works fine if you just run "java" on it,
> but when I try to run JCC on it, I get things like

Do you need to wrap the good stuff _and_ the cruft or can you get away with 
just wrapping the good stuff ? By default, JCC will wrap every public 
class/public method/public field it can find. If you have 28 Mb worth of 
cruft that's declared public, JCC is going to be generate a _LOT_ of code.
For comparison, for Lucene, JCC generates over 100,000 lines of C++.
This includes the pieces of the Java Runtime that are useful when using Lucene.

By default, JCC does a transitive closure on everything it finds that is 
public. You may end-up generating wrappers for stuff you don't need.

If you don't need to generate wrappers for code in Support.jar, then don't 
include it with --jar. Yes, you still need it on your classpath for the 
classes in GoodStuff.jar to load but that's a different issue.

> % python -m jcc --jar GoodStuff.jar --jar Support.jar
> Traceback (most recent call last):
>  File "/usr/lib/python2.5/runpy.py", line 95, in run_module
>    filename, loader, alter_sys)
>  File "/usr/lib/python2.5/runpy.py", line 52, in _run_module_code
>    mod_name, mod_fname, mod_loader)
>  File "/usr/lib/python2.5/runpy.py", line 32, in _run_code
>    exec code in run_globals
>  File "/usr/lib/python2.5/site-packages/JCC-1.7-py2.5-linux-i686.egg/jcc/__init__.py", line 28, in <module>
>    cpp.jcc(sys.argv)
>  File "/usr/lib/python2.5/site-packages/JCC-1.7-py2.5-linux-i686.egg/jcc/cpp.py", line 332, in jcc
>    cls = env.findClass(className.replace('.', '/'))
> jcc.cpp.JavaError: java.lang.VerifyError: (class: org/apache/html/dom/HTMLElementImpl, method: <init> signature: (Lorg/apache/html/dom/HTMLDocumentImpl;Ljava/lang/String;)V) Incompatible argument to function
> %
>
> Sure enough, Support.jar (a 28MB jar file containing all sorts of
> libraries) does indeed include a version of
> org.apache.html.dom.HTMLElementImpl, from some point in the past, but
> it's not ever actually used by any of the code in GoodStuff.jar.
>
> Can I turn off the verifier?  Only use it in certain cases?

I don't know what this error means.

Before feeding stuff to JCC, you should really carefully read the topic 
about all the command line args it can take in [2] if you haven't done so 
already. For example, the invocation you're using above is not going to 
generate any wrappers for use with Python, only the ones for use with C++.

Andi..

[1] http://pypi.python.org/pypi/JCC/1.7
[2] http://svn.osafoundation.org/pylucene/trunk/jcc/jcc/README


More information about the pylucene-dev mailing list