java-native-access / java-native-access/jna

Problem running in user account when username contains utf characters

Open
#238 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
8.9k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Here is a simple test program (for jna 3.5.2):

import com.sun.jna.platform.win32.Kernel32Util;
public class Test
{
    public static void main(String[] args)
    {
        String s = Kernel32Util.getComputerName();
        return;
    }
}

When I test it on win7 account цц (2 cyrillic characters), I get the following exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\??\AppData\Local\Temp\jna1644595665224573683.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1928)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
    at java.lang.Runtime.load0(Runtime.java:792)
    at java.lang.System.load(System.java:1059)
    at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:752)
    at com.sun.jna.Native.loadNativeLibrary(Native.java:737)
    at com.sun.jna.Native.<clinit>(Native.java:129)
    at com.sun.jna.Pointer.<clinit>(Pointer.java:42)
    at com.sun.jna.platform.win32.WinBase.<clinit>(WinBase.java:35)
    at com.sun.jna.platform.win32.Kernel32Util.getComputerName(Kernel32Util.java:41)
    at Test.main(Test.java:7)

When I test it on win7 account xx (2 'normal' characters), all goes fine.
This is heavy if you want to ship to russia or the most places in the world.
What may I do with this ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the native-loading path in Native.java, especially Native.loadNativeLibraryFromJar and Native.loadNativeLibrary, using the supplied Test program on Windows 7 with a Cyrillic username. Investigate why the extracted DLL path is represented with question marks, then verify that the program runs successfully under a non-ASCII account.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.