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: Storing C++ data in an instance field using CNI?


David Daney wrote:

Stanley Brown wrote:

I played a little bit with RawData. Soon my Java code became very GCJ dependent. I eventually switched back to JNI (which GCJ handles just fine) storing pointers in long instance variables and NIO buffers. To be fair this was mainly because I ran into complications on the Win32 port where (1) I could not mix C++ and GCJ and (2) creating instances of Calendar overloaded the memory.

Could someone please explain the advantage of using RawData over the methods I employed?

CNI has lower overhead than JNI.

If you use RawData, your code will continue to work when ported to architectures with 128bit pointers.

David Daney.

Bothner wrote some interesting stuff some time back on Linux Journal about CNI. After reading it I was "thats the way to go" for java-2-native programming. After much JNI and CNI coding Im thinking both will leave anyone longing for something like how .NET handles it. Sure, being able to use Java classes like C++ classes while in C++ code is nice but what would be really cool is to instantiate and control C++ classes from within Java like they were Java classes. I know: thats crazy talk!

A 128b pointer is a bit fantastic to me. 64-bit is just starting to become a reality for most people. Java probably needs a native integral type. Saying an int is always 32 bits no matter what the platform is an advantage and disadvantage at the same time. Perhaps "long long" for 128 bits? :)


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