Java agents in paths containing unicode characters on Windows

Michael Rasmussen MRasmussen at perforce.com
Mon Jun 15 10:48:24 UTC 2020


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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20200615/e707dea0/attachment.htm>


More information about the serviceability-dev mailing list