Hi,
Am Freitag, dem 14.07.2023 um 13:22 -0700 schrieb 'Roy Zhang' via Java Native Access:
> It is called in an application, I could not specify "-
> Djna.nosys=true" . I did not modify the location of any native
> components.
>
> I have tried to make a simple test project. It works fine. But once
> move the code to my project, it has this problem. The call stack is
> like this.
>
> java.lang.UnsatisfiedLinkError: Can't obtain class
> com.sun.jna.CallbackReference
> at com.sun.jna.Native.initIDs(Native Method)
> at com.sun.jna.Native.<clinit>(Native.java:248)
> at
> com.sun.jna.platform.win32.Kernel32.<clinit>(Kernel32.java:44)
I had a look at the native code and in general classloading must still
work, as CallbackReference is one of the last classes to be loaded.
The I thought about what might cause so differential problems and I
have a hunch:
Check the dependencies (including all transitive depdencies) of your
main project. Check each jar if you find a second set of JNA classes.
If the classes are not consistent, they will fail to properly load.
An additional debugging option is to remove your native call and at
that point call `Class.forName("com.sun.jna.CallbackReference")`. This
will try to load the `CallbackReference` class and should also fail.
The difference is, that now you should get a stack trace and better
error report why class loading fails.
HTH
Matthias