junkdog / graftt

annotation-driven bytecode surgery
MIT License
8 stars 2 forks source link

Bug: Classpath with windows drive name causes FileNotFoundException #11

Closed DaanVanYperen closed 4 years ago

DaanVanYperen commented 5 years ago

Given classpath: cp:C:\github\odb\artemis-odb-contrib\contrib-plugin-debug/../contrib-plugin-lifecycle-transplants/target/classes/ (windows)

GraftAgent::parseArgs parses it as "C", caused by 349272f5e81f0c42f85bab67aa616a608be4dee0

image

Resulting in:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.io.FileNotFoundException: C
    at net.onedaybeard.graftt.CoreKt.classNodes(Core.kt:64)
    at net.onedaybeard.graftt.agent.GraftAgentKt$premain$1.register(GraftAgent.kt:37)
    at net.onedaybeard.graftt.agent.GraftAgentKt$premain$1.<init>(GraftAgent.kt:31)
    at net.onedaybeard.graftt.agent.GraftAgentKt.premain(GraftAgent.kt:18)
junkdog commented 4 years ago

Fixed in https://github.com/junkdog/graftt/commit/56806477d0ceb666557ab6b74d11f79d2d256e28

Changed it somewhat from your pull request: there's now an additional =, format is: param1=value1,value2;param2=value3, so:

java -javaagent:agent-${VERSION}.jar=cp=C:\path1\to\artifact.jar ...