This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I was trying to learn how JNA works, so I decided to use the spotify API (libspotify 0.0.7). I managed to load my dll correctly, but then it looks like my code is not finding any of the method defined in the API:
I'm running Windows 7 x86 and I'm running my code in Eclipse.
Here is my code:
My Library wrapping interface:
Here is the declaration of the method I'm trying to call
The domain classes:
Do you have any idea of what's happening? Do you see any problem with my code?
I finally found the solution by opening the libspotify.dll with Dependency Walker: The compiler added some extra information to the method name (a underscore prefix and a @4 or @8 suffix).
I had to:
- Create an implementation of FunctionMapper that renamed all my methods according to the real names (available in Dependency Walker)
- Instantiate my Library with an instance of this mapper in the options map.