Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6119209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:31:32+00:00 2026-05-23T15:31:32+00:00

I have two sources: an xml-file containing definitions of several hundred data structures, basically

  • 0

I have two sources:

  • an xml-file containing definitions of several hundred data structures, basically structs with fields consisting of simple data types (e.g. int, short, boolean, enum), and
  • a c header-file containing the same data structures represented a c structs. (I cannot modify this header-file or the c structs.)

I also have a library, written in c, that is able to use these c structs to perform a specific task.

Last I have a Java application which needs to use this library somehow.

Currently I generate Java classes from the xml-file representing the data structures, now I “just” need to provide them to the library somehow.

My current approach is to generate jni code, to call a c-function for each struct from Java, accepting the Java generated class as a parameter. Then generate c-code which takes the Java classes and fill in the appropriate fields in the c-structs.

Is this a good approach? Does anybody have suggestions for a simpler approach?

I am considering using sockets and e.g. protobuf, but I do not see this as any simpler.

Thanks in advance for any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:31:33+00:00Added an answer on May 23, 2026 at 3:31 pm

    The solution I am ending up with is using the Javolution struct library

    Basically I am generating Java classes that inherits the javolution.io.Struct class from the xml, and declaring the fields appropriately such that javolution can interpret it as struct.

    This allows me to do a myJavaStructClass.getByteBuffer() and get a directly mapped byte buffer which has the same memory layout as if the Java “struct” where declared in c. And because it is directly mapped, contains a reference which can be passed directly to native code through JNI.

    Javolution also supports both packed and non-packed structs, as well as arbitrary endianness.

    Another solution would be to use SWIG to generate Java classes directly from the c header-files, and manage them directly in native code through JNI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to compare XML data. There are two sources- Web Service XML files
I have two base addresses defined in my WCF Service config file: <?xml version=1.0
I have a sheet in which I have data from two different sources.I've a
So I have an xml file containing ... <chapter> <para>This line has a quote
I have a bunch of hierarchical data stored in an XML file. I am
I have a big (1.9 GB) XML file which has data I want to
I have two applications written in Java that communicate with each other using XML
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two xml files, defect. xml and employee.xml. But the files havea common
I need to parse xml files from two sources. Both xml files contain the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.