BCEL , - , , . monkeypatching JVM, , BCEL Java. Java ( -javaagent) API- . .
:
- , javaagent.
- .
- You can change the method. Theoretically, you can also add some method, but you need to compile the project with the modified (fixed) classes. I think it would cause a lot of pain, and it's not worth it. There are alternative languages that support it (e.g. Groovy) or support something similar (e.g. implicit conversions in Scala).
- It's better to design your API than using a monkey patch. This may be useful for third-party libraries.
source
share