I want to replace a function with a class where I know the source code. The problem is that I cannot redefine the function because it is closed, and I also cannot extend the class and redefine all the functionality, because bad calls are in all possible constructors.
Now I'm completely lost. I donβt know how I can implement this desired functionality (for controlling Android VideoView controls like MediaController). Is there a way to replace the function with reflection or something like that? Or is it even possible not to call the constructor of a superclass, but a super superclass?
Here is a very simple class that shows my problem:
public class Base { public Base(int state) { // must be called } } public class Example extends Base { public Example(int state, boolean bla) { super(state); badCall(); } public Example(int state) { this(state, false); } private badCall() { // doing bad things } }
Also note that I need to have an instance of Example , so I cannot just copy the class.
source share