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 8835859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:21:28+00:00 2026-06-14T09:21:28+00:00

I have a DLL written in C++ that I can not change. It has

  • 0

I have a DLL written in C++ that I can not change. It has the following exposed function

// c++ 
DllExport unsigned int ProcessMessage( char * in_message, USHORT in_message_length, char * connectionString, bool ( SendMessage)( char * connectionString, BYTE * payload, USHORT iPayloadSize )  );

I have a Java application that needs to call this DLL function. I am currently using a java library com.sun.jna

// Java 
public class main {
    public interface CBlargAPI extends Library {
        interface sendMessage_t extends Callback {
            boolean invoke(String connectionString, Pointer payload, short iPayloadSize );
        }
        int ProcessMessage( byte[] in_message, short in_message_length, String connectionString, sendMessage_t SendMessage ) ; 
    }
    public static void main(String[] args) throws Exception 
    {
        // Override function thingy (#A) 
        CBlarg.sendMessage_t sendMessage_fn  = new CBlarg.sendMessage_t() {
            @Override
            public boolean invoke(String connectionString, Pointer payload, short iPayloadSize) {
                System.out.println("sendMessage_t: " )  ;
                return false; 
                }
            };         
        }
        CBlargAPI.INSTANCE.ProcessMessage( receivePacket.getData(), (short) receivePacket.getLength(), connectionString, sendMessage_fn ); 
    }

    // static member function (#B) 
    public static boolean SendUDPMessage( String connectionString, Pointer payload, short length )  {    
        // ToDo: I want to use this one. 
    }
}

Currently this is working with the override function thingy (#A) but I want to use the static member function (#B) instead. I have tried a few things without success such as

// Errors with "cannot find symbol, symbol: class SendUDPMessage, location: class main" 
CBACnetAPI.sendMessage_t sendMessage_fn  = new main.SendUDPMessage();

I am primary a c++ programmer and rarely touch java

My question is:

  • How do I call the static member function SendUDPMessage() as the callback instead of the Override function thingy (#A)?
  • 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-06-14T09:21:29+00:00Added an answer on June 14, 2026 at 9:21 am

    You have to make the override function thingy (#A) call the static member function(#B). Java does not have function pointers, so you need an interface object to serve that purpose.

    Why do you need to do #B over #A?

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

Sidebar

Related Questions

I have a third-party (Win32) DLL, written in C, that exposes the following interface:
I have a dll written by someone else and that has many flaws. Let's
I have a DLL that is written in C++ and I want to suppress
I have a test suite DLL written in C# that uses Selenium.This is then
I have an application written in PHP that uses a COM dll written in
I have a very simple DLL written in unmanaged C++ that I access from
I have a DLL, written in XE2 that takes a PChar as a parameter
I have written a c# program that calls a c++ dll that echoes the
I have an MFC extension DLL that I've written. It contains derived classes of
I have a program written in VB.Net (Visual Studio 2008) that uses a DLL

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.