

![]() | 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.usersRe: Passing String objects to native ...| From | Sent On | Attachments |
|---|---|---|
| Mendoza, Rogelio (GE, Corporate, consultant) | May 9, 2007 12:05 pm | |
| Timothy Wall | May 9, 2007 12:11 pm |

![]() | 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: | Re: Passing String objects to native methods | Actions... |
|---|---|---|
| From: | Timothy Wall (twa...@users.sf.net) | |
| Date: | May 9, 2007 12:11:41 pm | |
| List: | net.java.dev.jna.users | |
What symbols are exported in your DLL? Make a simple C program (NOT C ++) which calls your DLL's setPathToMonitor method and make sure that works.
On May 9, 2007, at 3:05 PM, Mendoza, Rogelio ((GE, Corporate, consultant)) wrote:
Hi Timothy,
I have change the signature of my method to get a const char*, but it still did't work. It sent me this error in my java console, what do you thing could be wrong? :
An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x8310C2 Function=[Unknown.] Library=(N/A)
NOTE: We are unable to locate the function name symbol for the error just occurred. Please refer to release documentation for possible reason and solutions.
Current Java thread: at com.sun.jna.Function.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:217) at com.sun.jna.Library$Handler.invoke(Library.java:180) at $Proxy0.isFileOpen(Unknown Source) at TestDialogHook.main(TestDialogHook.java:79)
Dynamic libraries: 0x00400000 - 0x0040B000 D:\j2sdk1.4.2_08\bin\javaw.exe 0x7C900000 - 0x7C9B0000 C:\WINDOWS\system32\ntdll.dll 0x7C800000 - 0x7C8F4000 C:\WINDOWS\system32\kernel32.dll 0x77DD0000 - 0x77E6B000 C:\WINDOWS\system32\ADVAPI32.dll 0x77E70000 - 0x77F01000 C:\WINDOWS\system32\RPCRT4.dll 0x7E410000 - 0x7E4A0000 C:\WINDOWS\system32\USER32.dll 0x77F10000 - 0x77F57000 C:\WINDOWS\system32\GDI32.dll 0x77C10000 - 0x77C68000 C:\WINDOWS\system32\MSVCRT.dll 0x76390000 - 0x763AD000 C:\WINDOWS\system32\IMM32.DLL 0x629C0000 - 0x629C9000 C:\WINDOWS\system32\LPK.DLL 0x74D90000 - 0x74DFB000 C:\WINDOWS\system32\USP10.dll 0x08000000 - 0x08138000 D:\j2sdk1.4.2_08\jre\bin\client\jvm.dll 0x76B40000 - 0x76B6D000 C:\WINDOWS\system32\WINMM.dll 0x10000000 - 0x10007000 D:\j2sdk1.4.2_08\jre\bin\hpi.dll 0x00940000 - 0x0094E000 D:\j2sdk1.4.2_08\jre\bin\verify.dll 0x00950000 - 0x00969000 D:\j2sdk1.4.2_08\jre\bin\java.dll 0x00970000 - 0x0097E000 D:\j2sdk1.4.2_08\jre\bin\zip.dll 0x02D70000 - 0x02E82000 D:\j2sdk1.4.2_08\jre\bin\awt.dll 0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV 0x774E0000 - 0x7761D000 C:\WINDOWS\system32\ole32.dll 0x02E90000 - 0x02E95000 D:\j2sdk1.4.2_08\jre\bin\jawt.dll 0x02EA0000 - 0x02EC1000 D:\Documents and Settings\501114286\Local Settings\Temp\jnidispatch.dll 0x02EE0000 - 0x02EEF000 D:\Documents and Settings\501114286 \workspace\JNA_WIN32\GEDialogMonitor.dll 0x72830000 - 0x7292E000 C:\WINDOWS\system32\MFC42u.DLL 0x77120000 - 0x771AC000 C:\WINDOWS\system32\OLEAUT32.dll 0x76C90000 - 0x76CB8000 C:\WINDOWS\system32\imagehlp.dll 0x59A60000 - 0x59B01000 C:\WINDOWS\system32\DBGHELP.dll 0x77C00000 - 0x77C08000 C:\WINDOWS\system32\VERSION.dll 0x76BF0000 - 0x76BFB000 C:\WINDOWS\system32\PSAPI.DLL
Heap at VM Abort: Heap def new generation total 576K, used 465K [0x10010000, 0x100b0000, 0x104f0000) eden space 512K, 90% used [0x10010000, 0x10084618, 0x10090000) from space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000) to space 64K, 0% used [0x100a0000, 0x100a0000, 0x100b0000) tenured generation total 1408K, used 0K [0x104f0000, 0x10650000, 0x14010000) the space 1408K, 0% used [0x104f0000, 0x104f0000, 0x104f0200, 0x10650000) compacting perm gen total 4096K, used 1395K [0x14010000, 0x14410000, 0x18010000) the space 4096K, 34% used [0x14010000, 0x1416cf60, 0x1416d000, 0x14410000)
Local Time = Wed May 09 15:03:03 2007 Elapsed Time = 0 # # The exception above was detected in native code outside the VM # # Java VM: Java HotSpot(TM) Client VM (1.4.2_08-b03 mixed mode) # # An error report file has been saved as hs_err_pid2120.log. # Please refer to the file for further information. #
Thanks in advance, Rogelio.
-----Original Message----- From: Timothy Wall [mailto:twal...@dev.java.net] Sent: 02 May 2007 17:52 To: Mendoza, Rogelio (GE, Corporate, consultant) Cc: use...@jna.dev.java.net Subject: Re: Passing String objects to native methods
Change your native method to accept const char* instead. JNA doesn't know anything about implicitly creating C++ classes.
When you do setPathToMonitor("c:\\tmp") in C++, the compiler implicitly uses the CString(const char*) constructor in order to get the right data type.
On May 2, 2007, at 12:23 PM, Mendoza, Rogelio ((GE, Corporate, consultant)) wrote:
Hi Timothy,
In my current project we're implementing a functionality that let us add a hook to the Standard Dialog boxes in Windows. For now I've been doing some basic testing with a method in my dll that have this signature:
extern "C" __declspec(dllexport) void setPathToMonitor(CString jstr);
extern "C" __declspec(dllexport) void setPathToMonitor(CString jstr) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); }
I'm calling this method from my java code in this way,
GEDialogMonitor.INSTANCE.setPathToMonitor("C:\\TestDir");
But I'm getting an error. It let me debug the error from MSVC++ and here is the methods call stack,
_free_dbg_lk(void * 0x02ed3f04, int 1) line 1044 + 48 bytes _free_dbg(void * 0x02ed3f04, int 1) line 1001 + 13 bytes operator delete(void * 0x02ed3f04) line 351 + 12 bytes CString::FreeData() line 146 + 15 bytes CString::~CString() line 213 setPathToMonitor(CString {"C:\TestDir"}) line 188 + 16 bytes JNIDISPATCH! Java_com_sun_jna_Pointer_write__I_3SII@24 + 10617 bytes JNIDISPATCH! Java_com_sun_jna_Pointer_write__I_3SII@24 + 1319 bytes 1416cc58() 1416cab0()
What could be the best way to pass a String object to my native methods? Can you see something wrong here?
Best Regards, Rogelio.
Timothy Wall http://abbot.sf.net







