How can I react to the activation of a class in ABAP?

I’d like to write custom metadata and generate other classes when an ABAP class gets changed and activated. For example, I’d like to scan the class’s source code for TODO comments and store them in a custom table.

Is there a way to detect that a class is activated and react to it?

I looked for BAdIs, but in vain. There are BAdIs to react to transport releases, of course, but that happens much later.

I see only two ways to “solve” this, both bad: either I plan a recurring job and do that there (would have to run very often to get near real-time), or I illegally invade the activation code with extension points and cross fingers that it won’t break.