1 message in net.java.dev.jna.users[jna-users] char* versus wchar_t * in...
FromSent OnAttachments
Dale...@coats.comMay 19, 2008 10:17 am.zip
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] char* versus wchar_t * in a Structure (Mischief Managed! - nullActions...
From:Dale...@coats.com (Dale@coats.com)
Date:May 19, 2008 10:17:56 am
List:net.java.dev.jna.users
Attachments:
WindowHandleWipe.zip - 44k

On Mon, 19 May 2008 10:53:44 -0400, Timothy Wall wrote:

On May 19, 2008, at 10:39 AM, Dale@coats.com wrote:

The problem seems to be that the W32HANDLEs are getting wiped-out when I run the .size() method, but only if I use the char array and not if I use individual char fields!

This might be considered a bug; the Java fields should probably not get wiped if Structure.size() is called after the Java fields have been assigned. If you could supply a stand-alone JUnit test which fails for this (or append one to StructureTest), that'd be helpful.

I'm subversion challenged (behind a pita firewall) and in this project have just been using the main method for testing. But I created three Classes (named: TryIconNotWorking, TrayIconWorkAround, and TrayIconWorking) that show what I've seen (marked with "<<<<change"). There are only a few lines different in each. So I've attached the zipped stand-alone Eclipse project.

Are the Java fields wiped, or is it only the native memory that is blank? I would expect the latter; the former would be a bug. Structures are auto-written before function invocation and auto-read after for convenience (otherwise this list would be full of questions about why invocations with structures fail).

Yeah, the Java fields are wiped. I should have noticed this right away, but I was not even using the Structure.toString() until today, when I also added the -Djna.dump_memory=true.

--Dale--