thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Margozzi" <>
Subject RE: thrift and JNI
Date Thu, 28 Jul 2011 21:52:17 GMT
Have you considered using JNA rather than JNI? No C++ code to write at

-----Original Message-----
From: Steve Angelovich [] 
Sent: Thursday, July 28, 2011 12:52 PM
Subject: thrift and JNI


Has anybody considered using thrift in conjunction with JNI?

I have a large java application where I want to be able to implement 
some algorithms in either java or c++.  Right now we do this by writing 
a small amount of JNI code or using SWIG.

I'd like to generalize this a little so that the JNI code only has to be

written once instead of for each algorithm.  I can do this purely using 
JNI but then I end up with very tight coupling between my c++ code and 
the java code.

Does it make any sense to use thrift to define my interface.  Then when 
moving between the java and c++ I wouldn't require a socket connection 
but would use a memory based transport.

Does this very small code segment look correct for how to move the 
contents of the TData java class into a memory buffer and then get it 
back?  This is all java code but I could do the same thing with the 
first half java and the complementary code in c++.

     byte[] buf = null ;
       TData data = new TData() ;
       TMemoryBuffer transportIn = new TMemoryBuffer(0) ;
       TProtocol oprot = new TBinaryProtocol(transportIn) ;
       data.write(oprot) ;

       transportIn.flush() ;
       buf = transportIn.getArray() ;
       System.out.println("buf.length=" + buf.length) ;

       TTransport transportOut = new TMemoryInputTransport(buf) ;
       TProtocol iprot = new TBinaryProtocol(transportOut) ;
       TData data = new TData() ; ;
       System.out.println(data.toString()) ;

Has anybody considered writing an implementation of TTransport based on 
the NIO ByteBuffer class?


This e-mail, including any attached files, may contain confidential and
privileged information for the sole use of the intended recipient.  Any
review, use, distribution, or disclosure by others is strictly
prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the
sender by reply e-mail and delete all copies of this message.

The information contained in this transmission may be confidential. Any disclosure, copying,
or further distribution of confidential information is not permitted unless such privilege
is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic
communications, including email and attachments, sent across its networks filtered through
anti virus and spam software programs and retain such messages in order to comply with applicable
data security and retention requirements. Quantum is not responsible for the proper and complete
transmission of the substance of this communication or for any delay in its receipt.

View raw message