PRB: Native Function Import Is Incompatible with Unicode and Auto Modifiers (326208)



The information in this article applies to:

  • Microsoft Visual J# .NET (2002)
  • Microsoft Visual J# .NET (2003)

This article was previously published under Q326208

SYMPTOMS

In a Visual J# .NET application, a J/Direct DLL import statement for function 'X' results in a different function version from the same DLL import statement for function 'X' in a Visual J++ application. This occurs when the following criteria are met:
  • You import the function with a Unicode or auto modifier.
  • The DLL that contains function 'X' also contains a function named 'XW', where the 'W' suffix indicates the Unicode version.
  • The application is running on a Unicode platform.

CAUSE

The Visual J# .NET application always imports the method with the 'W' suffix, if it exists. The Visual J++ application imports the method without the suffix in this scenario.

STATUS

This behavior is by design.

MORE INFORMATION

This compatibility issue occurs when 'X' and 'XW' are the only entry points for the function in the DLL.

In cases where 'X', 'XW', and 'XA' (where the 'A' suffix indicates the ANSI version) are defined, or only 'XW' and 'XA' are defined, both Visual J# .NET and Visual J++ bind to the same function, the 'XW' version.

Results in Visual J# .NET

Defined in DLLAutoUnicode
X and XAXX
X and XWXWXW
X and XA and XWXWXW
XA and XWXWXW

Results in Visual J++ 6.0

Defined in DLLAutoUnicode
X and XAXX
X and XWXX
X and XA and XWXWXW
XA and XWXWXW

Steps to Reproduce the Behavior

  1. Create or find a DLL that exports a Unicode and a generic version of a function, as described in this article. Make sure that the behavior in each function version is different so that you can identify which version is called.
  2. Create a Java language application that uses @dll.import with the Unicode or auto modifier to import the function from the DLL:
    public class MyApp
    {
    	/** @dll.import("Sample.dll", unicode) */ 
    	public static native void myFunc();
    	
    	public static void main(String[] args)
    	{
    		myFunc();
    	}
    }
    					
  3. Compile the application by using the Microsoft Visual J++ compiler, and then run the application. Notice that the application imports the generic version of the function.
  4. Compile the application by using the Visual J# .NET compiler, and then run the application. Notice that the application imports the Unicode version of the function.

Modification Type:MajorLast Reviewed:8/7/2003
Keywords:kbprb KB326208