Mixing BC and CNI in the same executable
Andrew Haley
aph@redhat.com
Sat Jan 23 22:41:00 GMT 2010
On 01/23/2010 02:51 PM, Stephen Kell wrote:
>> It looks like the problem here is that antlr-runtime.jar.so was built
>> with BC, but the java code in your app binary was not. When using
>> BC-ABI (and specifically, -findirect-classes), the class$ symbols are
>> hidden.
>>
>> Try building the Antlr .so with -findirect-dispatch
>> -fno-indirect-classes. This means that it's calls will be made with be
>> made with the BC ABI but class references will not - which is probably
>> ok most of the time.
>>
>> I'd also build the java code in your app binary with
>> -findirect-dispatch -fno-indirect-classes.
>
> Thanks very much for this -- those options got my program to build and
> run. However, it falls over during run-time linking. In my C++ code:
>
> 34: int request::process()
> 35: {
> 36: using namespace org::antlr::runtime;
> 37: using namespace java::lang;
> 38:
> 39: // invoke the parser
> 40: stream = new ANTLRInputStream(in_file);
> 41: lexer = new cakeJavaLexer((CharStream*) stream);
>
> ... the second "new" segfaults. Strangely, the first "new" is okay. The
> first is a class from a antlr-runtime.jar.so, whereas the second is in
> a .o compiled from local source. They were both compiled with
> -findirect-dispatch -fno-indirect-classes.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xb6670fb1 in _Jv_ClosureList::registerClosure(java::lang::Class*, void*) ()
> from /usr/lib/libgcj_bc.so.1
> (gdb) bt
> #0 0xb6670fb1 in _Jv_ClosureList::registerClosure(java::lang::Class*, void*) ()
> from /usr/lib/libgcj_bc.so.1
> #1 0xb6639389 in _Jv_Linker::create_error_method(_Jv_Utf8Const*, java::lang::Class*) ()
> from /usr/lib/libgcj_bc.so.1
> #2 0xb663b423 in _Jv_Linker::link_symbol_table(java::lang::Class*) () from /usr/lib/libgcj_bc.so.1
> #3 0xb663a85c in _Jv_Linker::wait_for_state(java::lang::Class*, int) ()
> from /usr/lib/libgcj_bc.so.1
> #4 0xb6674930 in void java::lang::Class::initializeClass() () from /usr/lib/libgcj_bc.so.1
> #5 0xb662a018 in _Jv_AllocObjectNoFinalizer () from /usr/lib/libgcj_bc.so.1
> #6 0xb662a046 in _Jv_AllocObject () from /usr/lib/libgcj_bc.so.1
> #7 0x08052c7b in cake::request::process (this=0xbffff00c) at cake.cpp:41
> #8 0x08057a08 in main (argc=2, argv=0xbffff114) at main.cpp:62
>
> Thanks again for any further suggestions!
>
> (I only just noticed that the BC libgcj is a completely different
> shared object... so perhaps mixing ABIs is a non-starter as I feared.)
You should be OK. Tell us how you linked it all.
Andrew.
More information about the Java
mailing list