This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CNI for C


On Wed, 2004-04-07 at 14:24, Geert Bevin wrote:
> On Wed, 2004-04-07 at 22:38, Michael Koch wrote:
> > > If it really is as little work as it sounds to be, by all means get
> > > it in there!!
> > 
> > It always needs people interested to do. If noone currently involved in 
> > GCJ is interested in doing it it will never be done. Geert, will you do 
> > a step forward and do it ?
> 
> I could have look at it. I have no knowledge of the inner workings of
> GCC at all and never even looked at how GCJ is constructed. Without some
> major guidance I doubt I'll be able to get this done.
> As far as GCC/GCJ is concerned I've just been a user :-/

I don't know how pinvoke works, but I was just reading about JDirect3,
which was in a previous version of Apple's JVM:

                   import com.apple.mrj.jdirect.Linker;
                                    
                           public class Prime {
           // The call to new Linker() installs the native methods
               static Object linkage = new Linker(Prime.class);
                                    
          // This string tells JDirect where to find the native code
             static final String JDirect_MacOSX = "prime.dylib";
                                    
               public static native long ComputePrime(short n);
                                     }

Calling ComputePrime forces the creation of Linker, which loads the
prim.dylib shared library and looks for the C function ComputePrime. 
So, there are a couple of tricks here (demangling, marshalling
arguments), but nothing too bad.  This combined with static imports
would make a nice dynamic interface to C from Java.

AG

-- 
Anthony Green <green@redhat.com>
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]