

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in net.java.dev.jna.usersJNA NullPointerException| From | Sent On | Attachments |
|---|---|---|
| ilya...@mail.ru | May 20, 2008 8:19 am | |
| Timothy Wall | May 20, 2008 8:36 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | JNA NullPointerException | Actions... |
|---|---|---|
| From: | ilya...@mail.ru (ilya...@mail.ru) | |
| Date: | May 20, 2008 8:19:05 am | |
| List: | net.java.dev.jna.users | |
Hi!
I've create simple application for test calling of dll functions and receive NullPointerException:
Exception in thread "main" java.lang.NullPointerException at java.lang.reflect.Array.getLength(Native Method) at com.sun.jna.Structure.getNativeSize(Structure.java:859) at com.sun.jna.Structure.getNativeSize(Structure.java:862) at com.sun.jna.Structure.calculateSize(Structure.java:764) at com.sun.jna.Structure.allocateMemory(Structure.java:194) at com.sun.jna.Structure.size(Structure.java:225) at com.sun.jna.Structure.useMemory(Structure.java:187) at com.sun.jna.Structure.useMemory(Structure.java:178) at com.sun.jna.Function.invoke(Function.java:324) at com.sun.jna.Function.invoke(Function.java:220) at com.sun.jna.Library$Handler.invoke(Library.java:204) at $Proxy0.GetTextList(Unknown Source) at SimpleTest.main(SimpleTest.java:33)
code of SimpleTest.java:
import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Structure;
public class SimpleTest {
public static class ArrayClass { public byte[][] list = new byte[16][256]; }
public static class TextList extends Structure { public int count; public byte list[][] = new byte[16][128]; }
public interface mylib extends Library {
String GetText(); TextList GetTextList(); }
public static void main(String[] args) throws Exception {
String dllfile = "d:/testdll.dll"; mylib dll = (mylib) Native.loadLibrary(dllfile, mylib.class); TextList text = dll.GetTextList(); System.out.println(text.toString()); }
}
in DLL file -
TTextList * WINAPI GetTextList() { TextList.Count = 16; for(int i=0;i<16;i++) { strcpy(TextList.List[i], " This is test text in list"); } return &TextList; }
where: TTextList TextList;
struct TTextList{ int Count; char List[16][128]; };
Please, explain were is my (or your) mistake... Thanks
P.S. Win XP SP2, jdk1.5.0_06
-- Regards Ilya







