d******e 发帖数: 117 | 1 手头有一个大的java程序,没有它的源代码。这个程序里有一个类,我想改变它的几个
method的功能, 就开发了一个新的类,interface保持相同. 我能不能在这个程序运行
时,让这个新的类自动替换掉旧的类? | s***8 发帖数: 1136 | 2 If the client code is programmed to the interface, and acquire the reference
via injection or lookup, you can tweak the configuration the provide your
impl. If it's direct instantiation, this option won't work.
Then you can try attach a java agent and in its pre-main method enhance the byte code and substitue it. | r*****l 发帖数: 2859 | 3 Can also try AspectJ.
reference
the byte code and substitue it.
【在 s***8 的大作中提到】 : If the client code is programmed to the interface, and acquire the reference : via injection or lookup, you can tweak the configuration the provide your : impl. If it's direct instantiation, this option won't work. : Then you can try attach a java agent and in its pre-main method enhance the byte code and substitue it.
| g*****g 发帖数: 34805 | 4 Well, if you are sure there's no license issue. Just remove the
class, have your class in the right package, compiled, put it back in the
jar.
【在 d******e 的大作中提到】 : 手头有一个大的java程序,没有它的源代码。这个程序里有一个类,我想改变它的几个 : method的功能, 就开发了一个新的类,interface保持相同. 我能不能在这个程序运行 : 时,让这个新的类自动替换掉旧的类?
| e*****t 发帖数: 1005 | 5 yeah, definitely check the license and talk to somebody who deals with
license in your organization to make sure it own't bite you later.
What goodbug said is the simplest solution. If you in control of the
classpath, you may also try to put your class on the classpath before this
jar.
【在 g*****g 的大作中提到】 : Well, if you are sure there's no license issue. Just remove the : class, have your class in the right package, compiled, put it back in the : jar.
| k******p 发帖数: 21 | 6 decompile and customize/subclass it |
|