Mixing BC and CNI in the same executable
Andrew Haley
aph@redhat.com
Tue Jan 26 13:57:00 GMT 2010
On 01/25/2010 03:45 PM, Stephen Kell wrote:
>> Thanks.
>>>> I've seen something like this years ago, but I can't remember what
>> caused it. I expect it's something quite simple, but I can't tell
>> from what you've posted here.
>>>> If you can make a self-contained test case theat reproduces the
>> problem I'll debug it.
>> Great -- thanks! The following tarball *should* be self-contained...
> "make testcase" should trigger the bug.
>> http://www.cl.cam.ac.uk/~srk31/private/testcase-20100125.tar.bz2
It's a combination of bugs. Firstly, there's a bug in libgcj when a
needed class is not found in an executable: it causes a crash when
trying to report the problem. Fixed thusly:
Index: java/lang/natClass.cc
===================================================================
--- java/lang/natClass.cc (revision 156043)
+++ java/lang/natClass.cc (working copy)
@@ -689,9 +689,12 @@
_Jv_ClosureList::registerClosure (jclass klass, void *ptr)
{
_Jv_ClosureList **closures = klass->engine->get_closure_list (klass);
- this->ptr = ptr;
- this->next = *closures;
- *closures = this;
+ if (closures)
+ {
+ this->ptr = ptr;
+ this->next = *closures;
+ *closures = this;
+ }
}
#endif
Secondly, you don't catch errors in your main program, just exceptions,
so you won't see Errors. Do this instead:
catch (java::lang::Throwable *e)
{
java::lang::System::err->print(e->toString());
return 1;
}
Thirdly, you aren't linking in inner classes. This works for me:
gcj -fno-eliminate-unused-debug-symbols -fno-eliminate-unused-debug-types -findirect-dispatch -fno-indirect-classes -fpic -g3 --classpath=./java:./antlr-runtime-3.1.3.jar:: -Wall -Wl,-R. cake.o main.o parser/parser.a antlr-runtime.jar.so stringtemplate.jar.so -lstdc++ -o "cake" -Wl,-Map,map java/cake/TreewalkError.o java/cake/InternalError.o java/cake/CloneableTree.o java/cake/SemanticError.o ./parser/cake/cakeJavaParser\$DFA*.o ./parser/cake/cakeJavaLexer\$DFA*.o ./parser/cake/cakeJavaParser\$*_return.o
It would be better to compile from .java -> .o, and then you would not
have to worry about all the inner classes.
Andrew.
More information about the Java
mailing list