Aliasing (Method Renaming)

Sometimes you want to use a name for the Java method that is different from the name that the DLL uses when it exports the function. For example, you might want to have the Java name start with a lowercase letter so that it conforms to Java naming conventions. To do so, just use the @dll.import directive with the entrypoint modifier as in the following example:

/** @dll.import("USER32", entrypoint="GetSysColor") */
  static native int getSysColor(int nIndex);

You do not need to use aliasing to perform the ANSI/Unicode suffixing done by the Win32 APIs. The Microsoft VM automatically takes care of this (see How the VM Chooses Between ANSI and Unicode). Aliasing is also unnecessary when accessing functions that have been exported by a .def file. Such names are typically exported using "stdcall mangling." That is, a method such as the following sample method would be renamed to _sample@8 (where 8 denotes the number of parameter bytes accepted by the function):

extern "C"
  VOID sample(int x, int y){

J/Direct automatically binds to stdcall-mangled names without an explicit entrypoint.

The Microsoft VM automatically provides aliases for the following KERNEL32 API functions.

Kernel32 Function Alias
CopyMemory RtlMoveMemory
MoveMemory RtlMoveMemory
FillMemory RtlFillMemory
ZeroMemory RtlZeroMemory