Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道使用支持代理的库(javassist、JDK 动态代理等)可以增强类以在运行时实现接口。
我的问题是:是否可以增强实例化对象以在运行时实现接口(并同样提供适当的方法处理程序)。
不,我们不能更改已经加载的类。而且我们不能替换加载的类(在类加载器中)。
如果你有机会
但那是非常非常黑的魔法……