문제

Is there a way to write a javassist program in a package other than the src folder that can modify other classes (either in the src folder or subfolders of the src folder). I have messed around with cp.addPath("/usr/local/javalib"); and I cannot get that to work. I do not know if that is because I am not using it properly, or if that isn't even an appropriate approach to modifying java files in other packages.

Any input would be greatly appreciated. Thanks!

도움이 되었습니까?

해결책

I was making this much more difficult than was needed. If I want to grab a class object in another package, say for example I wanted to modify a "foo.java" class in a "stuff" package. I simply use: pool.get(stuff.foo);

That's it, now I have the foo class in the classpool.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top