[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: Java agents in paths containing unicode characters on Windows
From:       Michael Rasmussen <MRasmussen () perforce ! com>
Date:       2020-06-25 10:34:34
Message-ID: BYAPR20MB2408B74F5F02D8C1A9F52C2CB1920 () BYAPR20MB2408 ! namprd20 ! prod ! outlook ! com
[Download RAW message or body]

Anyone know if the below is a known issue?

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

/Michael

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

Hi,

Trying to attach a javaagent that is located in a folder that contains char=
acters that cannot be represented in the current windows system code page w=
ill 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=9At (on my system, the short name (8.3) for that i=
s: C:\Tmp\tet~1)
no-agent.jar is a jar file that is not a javaagent

C:\>dir /s /b C:\tmp\Te=9At
C:\tmp\Te=9At\agent.jar
C:\tmp\Te=9At\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=9At>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 fa=
iled
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 clas=
s 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.ja=
r
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 fai=
ls 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 attach=
ments and notify us immediately.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic