1 message in net.java.dev.jna.users[jna-users] Re: bug for JNA
FromSent OnAttachments
Timothy WallJul 17, 2008 6:48 am 
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] Re: bug for JNAActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jul 17, 2008 6:48:46 am
List:net.java.dev.jna.users

What VM are you using?

While the documentation does not require an order, in practice most VMs do preserve order. JNA makes use of this behavior to avoid lines upon lines of manual configuration. GCJ even patched its field storage to provide a predictable order for JNA compatibility.

However, it wouldn't be too much work to extend Structure to accept a List of field names which explicitly indicates their order, to be used with VMs that don't have a predictable field order. It would, though, be a pain when defining a Structure to basically repeat the field list with a list of strings.

On Jul 16, 2008, at 4:42 AM, Jiang (EXT), Hongyi wrote:

Dear Sir,

I am recently using JNA, which is a very good java library to access native library like DLL. I got following exceptions, when I transform my java application with JNA to exe file: Exception in thread "main" java.lang.Error: This VM does not store fields in a predictable order at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source) Exception in thread "Thread-2" java.lang.NoClassDefFoundError: com.sun.jna.Native at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source) at java.lang.Void.<unknown>(Unknown Source)

--------------------------------------------------------------------------- The application has terminated with exit code: 1

This is a (known) bug in JNA that is not coded to the Java spec.

According to the Java SE API specification of java.lang.Class.getFields() method, it may return fields in any order. Here is an excerpt from the specification:

------------- getFields public Field [] getFields() throws SecurityException Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object. The elements in the array returned are not sorted and are not in any particular order.

-------------

Do you have any new bug free JNA library? Thank you very much.

Regards Hongyi Jiang