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

  • Home
  • SEARCH
  • 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 549193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:09:31+00:00 2026-05-13T11:09:31+00:00

Having my own Java code I’m using C# to call some unmanaged code that

  • 0

Having my own Java code I’m using C# to call some unmanaged code that call (via JNI) the java code. I’m using JNI since I need to ensure:

  • the ability that the Java code will run over real JVM and not over some .NET VM
  • the ability to attach to the VM for debugging (IKVM does’nt support it)
  • I need free solution
  • The current free solutions are not applicable (e.g. IKVM)

Anyway, my question is how can I manage strings passed between these layers in the best manner without leaks.
I’m doing something like:

[DllImport(@"MyDll.dll")]
public extern static void receive_message(string receDest, StringBuilder response);

This means I’m allocating the memory for the response in the managed code.
I want to avoid that since I don’t know in advance the response length. How can I write a JNI appropriate method that will allocate the right buffer for the managed code without leaks. The JNI code should be thread safe.

Any suggestions?

Thanks,

Guy

  • 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-13T11:09:31+00:00Added an answer on May 13, 2026 at 11:09 am

    You may need JNI, but your requirements don’t really indicate it.

    The requirement to use a real JVM does not dictate the use of JNI. I’d suggest sharpening your requirements, or considering looser coupling. For example, socket comms, web services, a shared database, a shared file, or a queue.

    If you really need Java and .NET to be run in the same process, with tight coupling, consider JNBridge.
    They’ve solved the problem you are confronting.

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

Sidebar

Ask A Question

Stats

  • Questions 304k
  • Answers 304k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Update current_theme option: update_option('current_theme', '[theme name]'); To get the theme's… May 13, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer From the docs: >>> from itertools import groupby >>> from… May 13, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer You need to redirect your output stream to the newly… May 13, 2026 at 8:45 pm

Related Questions

So we ran into an interesting issue today. We have a Java EE web
I want to write a simple visualization of a Java program by displaying the
While writing a game for J2ME we ran into an issue using java.lang.Integer.parseInt() We
I've got a couple thousand lines of code somewhere and I've noticed that my
Every time I need to work with date and/or timstamps in Java I always

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.