vendredi 15 juin 2018

Change import static statement object instance via reflection

There is a Basic interface Basic.java as:

public interface Basic {
    public void doWork();
}

Another interface extends Basic interface as, where Factory.getMessageInstance() return an instance of type interface A.

public interface A extends Basic {
    A InstanceA = Factory.getMessageInstance();
}

In my Foo.java method bar()

import static org.company.InstanceA;

public void bar(){
    InstanceA.doWork();
}

Is that possible to override InstanceA or its doWork() implementation via Java reflection?





Aucun commentaire:

Enregistrer un commentaire