Is it possible to override a method at runtime?

java, overriding

Solution

With plain Java, no.

With ByteBuddy(preferred), asm, cglib or aspectj, yes.

In plain Java, the thing to do in a situation like that is to create an interface-based proxy that handles the method invocation and delegates to the original object (or not).

Problem

Is there anyway to override a method at run time? Even if it requires dynamically creating a subclass from that instance?

Original source