Skip to content

Java to C/C++ exchange data objects #3634

Answered by rschatz
mswiderski asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is that foreign objects are always interpreted as pointers in C (that's the closest thing to a Java "reference" we have). You can't pass a Java object to a function that expects a by-value struct. The runtime would have to copy it to replicate by-value semantics. That is currently not implemented (and it probably also wouldn't be what you want, the resulting copy wouldn't be a Java object anymore).

Modifying the printHello function to take a pointer as argument should fix it.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mswiderski
Comment options

@mswiderski
Comment options

Answer selected by rschatz
Comment options

You must be logged in to vote
1 reply
@rschatz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants