So, this is a bit esoteric, and I can’t quite figure out if it’s even possible.
In the project I’m working on at the moment, I have a legacy mechanism for dependency injection that I’m gradually refactoring out. This mechanism is based on calling a particular static method on a class - let’s say MyInjector.getInstance(SomeClass.class)
I would like to write a rule that says that this method can only be called from Constructors, or from @Deprecated methods. This way I can start a process of moving from ad-hoc injection to Constructor injection - and eventually move entirely away from this legacy system.
I’ve managed to create a simple rule that says “Only classes that are deprecated should access MyInjector.getInstance“, but I can’t figure out any way of saying it should only be called from methods that are @Deprecated...
Is what I’m trying to do even possible?