Skip to content

Replace JavaCPP with hand-written JNI - #102

Merged
ds58 merged 3 commits into
developfrom
remove-javacpp-handwritten-jni
Jul 22, 2026
Merged

Replace JavaCPP with hand-written JNI#102
ds58 merged 3 commits into
developfrom
remove-javacpp-handwritten-jni

Conversation

@ds58

@ds58 ds58 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace JavaCPP with hand-written JNI (fastddsjava)
  • Upgrade Fast-DDS to 3.6.2
  • Drop Jackson; marshal Fast-DDS XML profiles with a small hand-written writer
  • Expand CI across major ROS 2 distros (including Foxy / Ubuntu 20.04) and Android native load

@ds58
ds58 force-pushed the remove-javacpp-handwritten-jni branch from bd0bba8 to c747337 Compare July 22, 2026 17:04
@ds58
ds58 requested a review from TomaszTB July 22, 2026 17:14
@ds58
ds58 marked this pull request as ready for review July 22, 2026 17:19

@TomaszTB TomaszTB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, this is one of those PRs where I just have to trust that the tests passing means things work well. Left a few comments on things that stood out to me though

Comment thread .github/workflows/build-natives.yml Outdated
Comment on lines +59 to +133
timeout-minutes: 30
timeout-minutes: 60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the build duration increase? That's a big timeout jump

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a hang earlier and this was temporary, reverted

{
buffer = ByteBuffer.allocate(1);
// Direct buffers allow zero-copy JNI via GetDirectBufferAddress.
buffer = ByteBuffer.allocateDirect(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes me wonder if we ever used the assumption that the buffer was a Java heap buffer.. I feel like we did. Might be worth double checking, looking for sequential access to the buffer. It wouldn't cause an exception or anything, but it'd be quite slow. Also if we every access the internal byte array, though I hope that would throw an exception (or would it allocate a new byte[]?).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We possibly did, but we did not use .array() or in the code assume it was heap-backed.

For buffer backed IDLSequences, we do assume heap backed, and that is correct. When messages are deserialized, they get copied from native to heap.

synchronized (loadLock)
{
fastddsjavaTools.retcodeThrowOnError(fastddsjava.fastddsjava_load_xml_profiles_string(xml));
fastddsjavaTools.retcodeThrowOnError(us.ihmc.fastddsjava.natives.fastddsjava.loadXmlProfilesString(xml));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full qualification?

Comment on lines +39 to +36
private static final int OK = RETCODE_OK();
private static final int OK = RETCODE_OK;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an optimization anymore, is it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, removed

@ds58
ds58 merged commit f7513d7 into develop Jul 22, 2026
19 of 20 checks passed
@ds58
ds58 deleted the remove-javacpp-handwritten-jni branch July 22, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants