Java Bytecode Wizardry: Supercharge Your Apps Without Touching the Source Code
Java bytecode instrumentation allows modifying compiled Java classes without changing source code. It uses Java Agents and libraries like ASM or ByteBuddy to manipulate bytecode at runtime. This technique enables adding features like timing, logging, profiling, and security checks to applications dynamically. It's powerful but should be used carefully to avoid complexity and performance issues.
The #JVM is an excellent platform for #monkeypatching
I want to demo several approaches for monkey-patching in Java in this post.
As an example, I’ll use a sample for-loop. Imagine we have a class and a method. We want to call the method multiple times without doing it explicitly.
The JVM is an excellent platform for monkey-patching. Monkey patching is a technique used to dynamically update the behavior of a piece of code at run-time. A monkey patch (also spelled monkey-patch, MonkeyPatch) is a way to extend or modify the runtime code of dynamic languages (e.g. Smalltalk, JavaScript, Objective-C, Ruby, Perl, Python, Groovy, etc.) without altering the original source code. — Wikipedia I want to demo several approaches for monkey-patching in Java in this post
Von Buddies und Agenten – dynamische Codegenerierung in Java
Manchmal reichen die üblichen Möglichkeiten der Programmiersprache nicht aus und die exotischeren Ansätze müssen zum Einsatz kommen. Angefangen bei ClassLoader, Reflections, ServiceLoader, über AnnotationProcessor und JavaAgents
https://schegge.de/2023/08/von-buddies-und-agenten-dynamische-codegenerierung-in-java/
#Bibliotheken #Java #Annotation #AnnotationProcessor #ByteBuddy #Bytecode #Java #Reflections #ServiceLoader