简体   繁体   中英

Wrapping C++ modules in Java

I've inherited a project, originally written in C++ . Due to implementation requirements, I need to either re-write the project in a JVM based language, like Java or Kotlin , or simply wrap the existing code in a Java or Kotlin (RESTful) API.

The existing code base is also entangled with an very old network simulation framework. I'm therefore leaning heavily towards untangling the simulation framework and wrapping the C++ code using something like JNI and SWIG to implement in a non simulated environment.

I'm wondering if JNI and SWIG are still the best options available?

Any advice will be greatly appreciated!

Wrapping with JNI (or SWIG) requires a clever definition of the API. See a nice explanation here . There exist some C++ frameworks that make JNI operations easier on the C++ side, consider them early, before you get too deeply invested in reference management. From what you write, it may be necessary also to provide some Java interface below the C++ layer, eg we use the the Java network APIs on Android, even from C++ code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM