Living in the Matrix with Bytecode Manipulation
summary
Demonstrates adding audit logging by registering a Java agent that transforms class bytes at premain, finds methods annotated with an @ImportantLog, injects code and prints the expected audit lines — the demo works and shows logs at runtime. Compares Javassist (write Java strings, easier but slower) with ASM (event-based, smaller footprint, faster but requires writing JVM opcodes). Notes Hibernate uses bytecode enhancement and surprisingly only nine instances of “throw new LazyInitializationException” in its source.
AI-written summary · about
chapters (16)
- 0:00Introduction to bytecode
- 1:13What is bytecode manipulation
- 4:01Applications of bytecode manipulation
- 6:34Java agents explained
- 8:22Java Assist framework overview
- 12:17Audit logging with Java Assist
- 15:50Java Assist pros and cons
- 16:12ASM framework overview
- 18:38Audit logging with ASM
- 25:03ASM pros and cons
- 26:05Hibernate lazy loading exception
- 30:24Hibernate enhancement task
- 33:57Spring and ASM usage
- 38:32Lessons learned from bytecode
- 41:23More applications of bytecode
- 42:13Q&A session
related talks
45mMaking Java more dynamic
39mThe Java Agent: Modifying Bytecode at Runtime to Protect Against Log4J
55mMaking Java More Dynamic
53mWell there's your problem! Your engine's missing! A look under Java's hood
51mThe Craft of Metaprogramming on JVM
50mRevealing the magic behind Java annotations
55mMaking Java more dynamic
48mPatching Third-Party Library Bytecode at Runtime
