Hi, I tested the methods in Pointer, like getByte, getByteBuffer and read()
in order to see the contents of a pointer but anything I get is the physical
Address of the memory it points to. I show this with an example:
///in C (so easy):
MySmallStruct mms;
typedef struct t_MySmallStruct
{
int v3d[3];
float v2d[2];
char chr;
}MySmallStruct;
MySmallStruct mms = {{1,2,3},{1.1f, 2.2f}, 'A'};
MySmallStruct* pmms = &mms;
//And here I can use i.e., pmms->v3d[0], pmms->v2d[1], etc to dereference
the pointer
//******************************************************************************************************
///Now in Java ???
public static class MySmallStruct extends Structure
{
public MySmallStruct()
{
super(-1, ALIGN_NONE); //or whatever align type
}
public int[] v3d = {1, 2, 3};
public float[] v2d = {1.1f, 2.2f};
public char chr = 'A';
}
MySmallStruct mms = new MySmallStruct();
Pointer pmms = mms.getPointer(); //I think pmms should point to mms!!!
pmms.setPointer(0, mms.getPointer());
String str = mms.getPointer().toString();//just to show the Msg:
allocated@(here come the address value)
System.out.println("str is: " + str);
byte[] byt = new byte[20]; //I thought I would get the values stored in
the fields of A :-(
pmms.read(0, byt, 0, 7); //or getByte or getByteBuffer, it is the same.
for(int i=6;i>=0;i--){
if((byt[i] & 0xFF) < 16) //
System.out.print("0");
System.out.print(Integer.toHexString(byt[i] & 0xFF) + " ");
if(i%2 == 0)
System.out.print(" ");
}//With the AND operation (0xFF) I can compare the contents of 'byt' with
that of 'str'
//
/// I GET THIS:
pointer to virtual:0.0
str is: allocated@0x2fb2ce0 (7 bytes)
//PLease tell me, how can I map pmms->v3d[0] into JAVA-JNA.
Thank you in advance!