1

I have a dll including some methods like this

f(DWORD a, DWORD b, ulong *c)

I have an example of declaring this method in C# as follows

f(uint a, ref uint b, ref IntPtr c)

now I want to implement the same in java. Neither uint nor ref are not supported by java. I added JOOU library to have UInteger but I do not know how to pass it as reference.

  • See following : https://stackoverflow.com/questions/9854166/declaring-an-unsigned-int-in-java – jdweng May 27 '20 at 23:54
  • But in this link there is no information about passing as reference – Mohammad Nakhaee May 29 '20 at 00:14
  • Reference just means you are passing a pointer (memory address) and that the address is passed into the method and returned from the method. The passed Parameters are put onto the execution stack. So from java it doesn't matter if "ref" is in the parameter list or not included. It is only used by c#. – jdweng May 29 '20 at 01:37
  • There is no pass by reference in Java. You can't do what the C# `ref` keyword does in Java. – Youssef13 May 29 '20 at 16:36

1 Answers1

0

Using jna library we can pass IntByReference instead of ref uint. After calling the method we need only to change that to an unsigned value So in java we have

f(UINT a, IntByReference int_b, PointerByReference c)
long b = int_b & 0xFFFFFFFFL;