lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Jancewicz <>
Subject JCC CompileError -- incorrect generic parameter detection
Date Fri, 29 Jul 2011 13:22:06 GMT

I encountered an error while trying to create a JCC wrapper for Apache
Tika. In particular, the problematic interface was
org.apache.poi.poifs.filesystem.DirectoryEntry. It's a rather unusual,
but simple, interface, defined as:

public interface DirectoryEntry extends Entry, Iterable<Entry> {
  // some method declarations, unimportant

In fact, creating a simple project with only two files: (defined as above) and (public
interface Entry {}) causes JCC to fail in the following way:

build\_failing\__wrap__.cpp(972) : error C2039: 'parameters' : is not
a member of 'p::t_DirectoryEntry'
: see declaration of 'p::t_DirectoryEntry'
Traceback (most recent call last):
  File "C:\Python26\lib\distutils\", line 533, in compile
    raise CompileError(msg)
distutils.errors.CompileError: command '"c:\Program Files\Microsoft
Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

This is because the C++ file generated by JCC references a
"parameters" variable not declared in the appropriate .h file. And
this, in turn, is caused by an incorrect result from
getGenericReturnType() in

def call(...):
    returnType = method.getReturnType()
    if generics:
        genericRT = method.getGenericReturnType() # line 340 (rev
1149172): this method returns incorrect results
        genericParams = method.getGenericParameterTypes()
        typeParams = set()

method.getGenericReturnType() returns java.util.Iterator<T> for
DirectoryEntry.iterator method. It should be
java.util.Iterator<Entry>. From the discussions on the Internet, it
seems that it's a known issue of Java reflection. Someone created a
small Java library to enhance its reflection algorithms, gentyref
(, Apache License). I managed to
substitute the incorrect line with:

        genericRT = GenericTypeReflector.getExactReturnType(method, cls)

GenericTypeReflector is a class from gentyref. It worked and compiled
Tika correctly. I also modified JCC build scripts to include gentyref
in the distribution.

So basically my problem was solved, but there is a bug in JCC on this
simple example. I don't know what your policy is regarding inclusion
of third-party libraries into the project, but maybe you'll be
interested in the patch I created?

Best Regards,
Łukasz Jancewicz

View raw message