Jump to content
Excelsior Forums
Sign in to follow this  
fatbird

Problem when using JNA library (application doesn't work)

Recommended Posts

Dear Sir,

I would like to buy JET software, and now I found a bug in the trial version.

my application use JNA library in order to connect native library (DLL). I have the following error in the second setting up step (Test Run):

The application has started with command line:

java -cp "E:\lib\mydoggy-api-1.5.0.jar;E:\lib\mydoggy-itest-1.5.0.jar;E:\lib\mydoggy-plaf-1.5.0.jar;E:\lib\mydoggy-res-1.5.0.jar; E:\lib\jna.jar" com/ugs/start/Main

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

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

But my application works well in Eclipse and with JET generated command:

java -cp "E:\lib\mydoggy-api-1.5.0.jar;E:\lib\mydoggy-itest-1.5.0.jar;E:\lib\mydoggy-plaf-1.5.0.jar;E:\lib\mydoggy-res-1.5.0.jar; E:\lib\jna.jar" com/ugs/start/Main

I cannot understand the problem. Is it a bug? Thank you for your answer.

Share this post


Link to post
Share on other sites

You found 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.

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

You may try to use other libraries that provide similar functionality (e.g. JNative, JNIWrapper, etc.) which are not biased to a particular JVM implementation.

Share this post


Link to post
Share on other sites

Thank you for your answer.

Could you please tell me if JET can pack the Jar and DLL files together into exe file? Because DLL file is easy to be replace by unauthorized user.

Share this post


Link to post
Share on other sites
Because DLL file is easy to be replace by unauthorized user.

Hello, I don't mean to be annoying, but is there something that is stopping an unauthorized user from replacing your exe?

You may try verifying the integrity of your DLL with md5, provided the architecture permits that.  But this is a weak security approach -- your verifying exe can still be "edited" by a hacker, although, it may take time to narrow down the location/s in the exe to edit.  If you are so concerned, the better way is to encrypt your exe and wrap it up into another exe, so your verifying code would be practically impossible to edit.  But you, most likely, have already thought of that. 

Share this post


Link to post
Share on other sites

If it is a bug from JNA. But why my java application can executed from Eclipse instead from JET?

You can find an answer in zztop's post.

JNA is tuned to work with Sun HotSpot JVM and expects that others JVM behave in similar way, even if Java Specification allows them to behave differently.

Share this post


Link to post
Share on other sites

JNA has delivered a new version, it works with JET.

Thank you very much

Regards

Which new version? I dropped in the latest jnidispatch.dll (md5 de9af41a7e0ad0dd7f83a5bc88d50d0f). 324KB. Still the same problem.

JNA is so easy compared to other libraries. If Excelsior can't support this, I don't know what I can do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×