Java agents in paths containing unicode characters on Windows

Michael Rasmussen MRasmussen at perforce.com
Thu Jun 25 10:34:34 UTC 2020


Anyone know if the below is a known issue?

Tried searching the bug database, but didn't find anything that really matched this issue.

/Michael

From: serviceability-dev <serviceability-dev-bounces at openjdk.java.net> on behalf of Michael Rasmussen <MRasmussen at perforce.com>
Sent: 15 June 2020 13:48
To: serviceability-dev at openjdk.java.net <serviceability-dev at openjdk.java.net>
Subject: Java agents in paths containing unicode characters on Windows

Hi,

Trying to attach a javaagent that is located in a folder that contains characters that cannot be represented in the current windows system code page will fail to load, even if specified with relative path or using a full path using short name.

Example:
agent.jar file is a javaagent located in a folder with unicode characters, in my example: C:\tmp\Tešt (on my system, the short name (8.3) for that is: C:\Tmp\tet~1)
no-agent.jar is a jar file that is not a javaagent

C:\>dir /s /b C:\tmp\Tešt
C:\tmp\Tešt\agent.jar
C:\tmp\Tešt\no-agent.jar

C:\>dir /s /b C:\tmp\tet~1\
C:\tmp\tet~1\agent.jar
C:\tmp\tet~1\no-agent.jar

C:\tmp\Tešt>java -javaagent:agent.jar -version
Unexpected error (103) returned by AddToSystemClassLoaderSearch
Unable to add agent.jar to system class path - the system class loader does not define the appendToClassPathForInstrumentation method or the method failed
FATAL ERROR in native method: processing of -javaagent failed, appending to system class path failed

If using full path using 8.3 names that is all in ASCII, it still fails:
C:\>java -javaagent:C:\tmp\tet~1\agent.jar -version
Unexpected error (103) returned by AddToSystemClassLoaderSearch
Unable to add C:\tmp\tet~1\agent.jar to system class path - the system class loader does not define the appendToClassPathForInstrumentation method or the method failed
FATAL ERROR in native method: processing of -javaagent failed, appending to system class path failed

If I try a jar file that doesn't have the necessary manifest entries to be a javaagent:
C:\>java -javaagent:C:\tmp\tet~1\no-agent.jar -version
Failed to find Premain-Class manifest attribute in C:\tmp\tet~1\no-agent.jar
Error occurred during initialization of VM
agent library failed to init: instrument

So it can find the jar file, is able to load and read the manifest, but fails afterwards when trying to add to classpath.

The above was tried with current JDK14 and JDK11 versions.

/Michael

This e-mail may contain information that is privileged or confidential. If you are not the intended recipient, please delete the e-mail and any attachments and notify us immediately.



More information about the serviceability-dev mailing list