[英]override the new package with the old one
Considering a java application with a embedded X
impl/jar file, for example com.test
package. 考虑带有嵌入式
X
impl / jar文件的Java应用程序,例如com.test
软件包。
and we cannot change and modify the jar file. 并且我们无法更改和修改jar文件。
Now suppose I have a X1.jar
file which is modified version of exist X(com.test)
package. 现在假设我有一个
X1.jar
文件,它是存在的X(com.test)
包的修改版本。
Question: 题:
Is it possible to override the X1.jar
implementation with embedded(exist) implementation just before the library gets loaded? 在加载库之前,是否可以使用Embedded(exist)实现覆盖
X1.jar
实现? and again, assume we cannot change the package anyway. 再一次,假设我们仍然无法更改软件包。
I'd like that to redirect all the types under com.test
package to the new one. 我希望将
com.test
包下的所有类型重定向到新的类型。
Thanks in advance. 提前致谢。
As per m0skit0's suggestion: 根据m0skit0的建议:
Orig class: 原始类别:
package example.x
public class SomeClass
{
public SomeClass(String neededVar)
{...}
public String someMethod(String someVar)
{
// original implementation
}
}
Custom class: 自定义类:
import example.x.SomeClass
public class MySomeClass extends SomeClass
{
public MySomeClass(String neededVar)
{
super(neededVar);
// anything else
}
@Override
public String someMethod(String someVar)
{
// implement differently
super.someMethod(someVar);
// or add to it
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.