Bytecode Manipulation #1863
-
|
Q: How would you modify bytecode at runtime? |
Beta Was this translation helpful? Give feedback.
Answered by
shivrajcodez
Mar 21, 2026
Replies: 1 comment
-
|
Use Java Instrumentation API (java.lang.instrument) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use Java Instrumentation API (java.lang.instrument)
Create a Java Agent (premain/agentmain)
Apply ClassFileTransformer to modify classes
Libraries:
ASM → low-level, fast
Javassist → easier API
Byte Buddy → modern & clean
Use cases: logging, AOP, monitoring, proxies