Return Value JNA Pointer

I use JNA to access the dll and everything works fine ... while I am debugging !!!

The problem is that I run my Java code in non-debug mode.

The dll target should be called by passing the somme parameters in the string and filling in the char pointer with the result.

So, to get the result in java, I use a PointerByReference object. When I have no problems debugging, I have the correct result, but there is only one indicator in my result in the standard run.

This is my java call:

PointerByReference EXMES = new PointerByReference();
PointerByReference SCHAINE = new PointerByReference();
DoubleByReference dateDujour = new DoubleByReference(DATEJOUR);

log.debug(String.format("Appel avec les arguments : ECHAINE=[%s]; DATEJOUR=[%s]", echaine, sdf.format(dateEngagement)));

Map<String, Object> options = new HashMap<String, Object>();
options.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.ASCII);

log.error(String.format("Default Charset : [%s]", Charset.defaultCharset().displayName()));
Native.setProtected(true);
MyNativeLibrary library = (MyNativeLibrary) Native.loadLibrary("myLib", MyNativeLibrary.class, options);
library = (MyNativeLibrary) Native.synchronizedLibrary(library);

String chaineAscii = new String("DATE_NAISSANCE\n19780102\nMEDIA\n4\n".getBytes(Charset.forName("US-ASCII")));

log.error(String.format("ECHAINE [%s]", chaineAscii));

library.SATINTS(chaineAscii, SCHAINE, dateDujour, EXMES);

String chaineSortie = new String(SCHAINE.getPointer().getString(0, false).getBytes(Charset.forName("US-ASCII")));
String chaineExmes = new String(EXMES.getPointer().getString(0, false).getBytes(Charset.forName("US-ASCII")));

log.debug(String.format("Retour taille Prexis : SCHAINE=[%d]; EXMES=[%d]", chaineSortie.length(), chaineExmes.length()));
log.debug(String.format("Retour Prexis : SCHAINE=[%s]; EXMES=[%s]", chaineSortie, chaineExmes));

This is an excerpt of my C function:

#define PRX_ALPHA char
#define EALPHA PRX_ALPHA *
#define SALPHA PRX_ALPHA *

EALPHA CHAINE;
SALPHA SCHAINE;
EDATE DATEJOUR;
SALPHA EXMES;

int winapi myFunction(
CHAINE,
SCHAINE,
DATEJOUR,
EXMES
) {


// Do something with the CHAINE and DATEJOUR then fill SCHAINE and EXMES with an answer
to my call

Thnaks in advance for every help I'm stuck

+3
source share
1 answer

PointerByReference void ** C. , .

String const char*. , , , . , byte[], Memory.

Memory.getString(0) Native.toString(byte[]) Java String String.

+7

All Articles