I would like to be able to implement a method at runtime that is called before an object runs the initializers. This will allow me to set fields that are used during initia
It sounds like what you want are Dynamic Proxies, which have been available since Java 1.3.
Edit: I looked into mockito to see how they managed to mock concrete classes and it turns out they create byte code and then load it with a class loader. Not only does that not really get what you want, but it is more complex than it necessary.
I agree with Stephen C: Why do you want to do this? I suspect there may be an easier way. I suspect what may work better for you is the Strategy or Command pattern. In that case, the custom code is in its own little class:
public class Initializer {
public (abstract) void initialize(A parent);
}
final String args[] = ...;
Initializer initializer = new Initializer() {
public void initialize(A parent) {
parent.setMessage(args);
}
};
which is either assigned to the main class or wraps the main class (depending on the need).