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.
有没有办法在运行时在 java 中添加(或扩展现有)类。我遇到了一个问题,我必须在运行时扩展现有类并将其添加到类路径中,以便拾取这个新类。
谢谢,
有很多方法可以做到这一点。
我想还有其他选择。
你可能想看看BCEL。如果没有更多关于您需要做什么的信息,很难给出更具体的答案。
您绝对应该写下为什么需要此功能。如果您尝试在运行时添加或替换逻辑,您可能需要查看脚本 API和一些实际实现。