GCJ and C++ (calling Java from C++)

Andrew Haley aph@redhat.com
Tue Nov 29 17:42:00 GMT 2005


Lothar Werzinger writes:
 > I cited the full mail, as this is a reply to the mailing list :-)
 > 
 > On Tuesday 29 November 2005 03:16, you wrote:
 > > Lothar Werzinger writes:
 > > > Sorry to contact you directly, but I found references on the WEB
 > > > (ftp://gcc.gnu.org/pub/gcc/summit/2004/GCJ New ABI.pdf) that lead me to
 > > > believe you might be the right people to ask my question.
 > > >
 > > > I would like to use an ecore EMF model in my C++ application. As a test
 > > > I used the library example from Eclipse EMF. I added a Java class and a
 > > > C++ main to test it. (Both are in the
 > > > org.eclipse.emf.examples.library.edit directory). I also provide a
 > > > build.xml ANT script to build and run the test. I attached the example
 > > > files
 > > >
 > > > Currently the C++ main can successfully execute a static Method. It even
 > > > can execute a static Method that returns a Java object. But as soon as I
 > > > try to invoke a Method on that returned object I get an exception:
 > > >
 > > > [exec] Unhandled Java exception:
 > > > [exec] java.lang.NullPointerException
 > > > [exec] at .main
 > > > (/home/lothar/workspace/org.eclipse.emf.examples.library.edit/cpp/librar
 > > >ytest/main.cpp:99) [exec] at .__libc_start_main
 > > > (/lib64/tls/libc-2.3.5.so)
 > > >
 > > > Is that related to the writing in the GCJ Manual that
 > > > "-findirect-dispatch: CNI also does not yet work with the binary
 > > > compatibility ABI"?
 > > >
 > > > Is there a way to make my program work? It would be a big win if I could
 > > > use the EMF ecore model in my C++ application.
 > > >
 > > > Is there a newer GCJ than the one I use that may fix this problem?
 > > >
 > > > Thanks in advance if you can respond to my mail.
 > > >
 > > > P.S.
 > > > gcj --version
 > > > gcj (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux)
 > > > Copyright (C) 2005 Free Software Foundation, Inc.
 > > > This is free software; see the source for copying conditions. There is
 > > > NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
 > > > PURPOSE.
 > >
 > > Questions like this should probably be sent to java@gcc.gnu.org.
 > 
 > Thanks for the pointer. I apologize and hereby move the thread to 
 > java@gcc.gnu.org.
 > 
 > > Have you read Section 12.15, Invocation ?
 > 
 > Well if this subtle hint means if I noticed the (rather non
 > obvious) call to JvInitClass. I didn't noticed it the first
 > time. Actually I copied/modified an example I found on the WEB But
 > in general I do read manuals :-)
The first thing in Section 12.15, Invocation, is:
Function: jint JvCreateJavaVM (JvVMInitArgs* VM_ARGS)
 Initializes the Java runtime
Did you call that?
Did you do everything in 12.15.2, Example?
 > However after if I added JvInitClass() calls to my main I still get
 > an exception.
 > Is there anything else I overlooked? I do really not want to bother
 > you, but if you know if this is a solvable problem (and how to
 > solve it), please point me in the right direction.
That's fine. But first, we will try the simple things, then the hard
things.
 > 
 > My code now looks like this:
Andrew.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /