This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: newbie question: need help linking
- From: Andrew Haley <aph at redhat dot com>
- To: "Prabhakar, Vijay (IT)" <Vijay dot Prabhakar at morganstanley dot com>
- Cc: <java at gcc dot gnu dot org>
- Date: Wed, 1 Dec 2004 15:48:49 +0000
- Subject: RE: newbie question: need help linking
- References: <B02B40763A4E244B85073170FFFE10887B5F85@NYWEXMB27.msad.ms.com>
Prabhakar, Vijay (IT) writes:
> Hmm, what about a native method that's written as part of a Java class
> that's compiled with gcj. Can that be called from a .class file?
Yes. You make it into a shared library. See
Extra features unique to gcj
* When you compile your classes into a shared library they can be
automatically loaded by the `libgcj' system classloader. When
trying to load a class `gnu.pkg.SomeClass' the system classloader
will first try to load the shared library
`lib-gnu-pkg-SomeClass.so', if that fails to load the class then
it will try to load `lib-gnu-pkg.so' and finally when the class is
still not loaded it will try to load `lib-gnu.so'. Note that all
`.'s will be transformed into `-'s and that searching for inner
classes starts with their outermost outer class. If the class
cannot be found this way the system classloader tries to use the
`libgcj' bytecode interpreter to load the class from the standard
classpath. This process can be controlled to some degree via the
`gnu.gcj.runtime.VMClassLoader.library_control' property; see *Note
libgcj Runtime Properties::.
> I was thinking about writing a class for wrapping and unwrapping
> primitives when communicating between C++ and Java. In other
> words, I was hoping to have a class converts RawData objects which
> are actually arrays (or vectors/other STL datastructures) of C++
> primitives and returns arrays of Java primitives. Would I be
> better off writing a C++ template that converts C++ primitives into
> j<primitive> arrays so that it can communicate with the Java code?
I have no idea. Depends on your application.
Andrew.