As I will show, you can implement the interface above using a proxy. A more meaningful question is why are you trying to make an unimplementable interface? Even as a philosophical moment, it seems rather petty.
import java.lang.reflect.Proxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; class NoFinal { public static void main(String[] a) throws Throwable { FinalInterface o = (FinalInterface) Proxy.newProxyInstance(FinalInterface.class.getClassLoader(), new Class[]{FinalInterface.class}, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) { System.out.println(method); return null; } }); Method[] methods = FinalInterface.class.getDeclaredMethods(); methods[0].invoke(o, new Object[]{null}); methods[1].invoke(o, new Object[]{null}); } }
This will not give a compilation error or runtime, and it shows that you can create a real instance of this interface using both methods called.
source share