I have a c++ custom lib in my java project. This custom c++ lib is using fibers (boost c++ library). Can i call a c++ fiber from java? Theretically fiber works inside the VM thread even if VM dont know it. So all might be ok but maybe there is some thing that i know about VM design, not expected in this usage? (Attention please it is not a normal c++ call , it is using fiber framework inside C++ , so TLS in c++ could conflict java maybe? the thread context switch is the same?)
Asked
Active
Viewed 534 times
1 Answers
0
Can i call a c++ fiber from java?
Yes, You can call C++ Library in Java . You can use Java Native Interface (JNI) in order to call C++ modules into java.
So you will have to write wrapper library to access built in library in C++ if required. So Java code will connect to Wrapper C++ Library using JNI and Wrapper Library will connect to fibre library of C++.
Please refer following tutorial to understand the JNI call's.

Rohan Kadu
- 1,311
- 2
- 12
- 22
-
Sorry but the question was another . I know JNI. c++Fiber could affect directly the VM internals . – Bianca Mattiolo Dec 18 '17 at 17:39
-
1After a test about porting c++ boost fiber in java ... i can tell you , it doesnt work (it works just if the c++ fiber is executing c++ code else there is a stackoverflow) , so the response above is wrong. This experiment has a important effect in the future interoperability . Java it will not be more interoperable with c++ . The fibers must be implemented at os kernel level for be transparent at higher levels – Bianca Mattiolo Dec 24 '17 at 03:12
-
Thanks for sharing your findings. – Rohan Kadu Dec 25 '17 at 11:18