Re: System.load() problem
From: Gordon Beaton (not_at_for.email)
Date: 08/12/04
- Next message: Cram TeXeD: "Re: JNDI NamingEnumeration parsing is too slow : what's wrong ?"
- Previous message: Tor Iver Wilhelmsen: "Re: System.load() problem"
- In reply to: cppaddict: "System.load() problem"
- Next in thread: Paul Ashby: "Re: System.load() problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Aug 2004 09:33:49 +0200
On Thu, 12 Aug 2004 06:31:47 GMT, cppaddict wrote:
> Then I moved my project to a new folder and gave it a new package
> name. However, I did not change or move my .DLL, and the code that
> calls it (above) was untouched. However, I am now getting an
> UnsatisifiedLinkError at runtime when my app hits the first native
> method call. Why is this happening? How can I fix it?
Since UnsatisifiedLinkError occurs at method invokation, it means the
JVM cannot find the required symbol in the DLL. (Had the error occured
at System.load() it would have meant that the JVM could not find the
DLL, or that loading failed for some other reason).
The native symbol names the JVM expects to find depend on the fully
qualified name of the class to which they belong. You changed the
package name, so essentially your native methods no longer belong to
the class.
Re-run javah to get a new list of symbol names, rename the symbols in
the C file, and recompile the DLL. Note that you need to specify the
_fully_qualified_ classname when you run javah.
If you call RegisterNatives() from JNI_OnLoad() you can name the
symbols anything you like, without regard to the package name or the
java-declared native method names. It lets you provide an explicit
mapping from the java-names of your native methods to the actual names
in the DLL source. RegisterNatives() still needs to know the fully
qualified classname, but since the information is in a single place
you don't need to re-run javah and you don't need to rename anything.
/gordon
-- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e
- Next message: Cram TeXeD: "Re: JNDI NamingEnumeration parsing is too slow : what's wrong ?"
- Previous message: Tor Iver Wilhelmsen: "Re: System.load() problem"
- In reply to: cppaddict: "System.load() problem"
- Next in thread: Paul Ashby: "Re: System.load() problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|