Does Java optimize method calls via an interface which has a single implementor marked as final?

后端 未结 4 1182
名媛妹妹
名媛妹妹 2021-02-08 15:03

If I have a reference to a class and invoke a method on it, and the class or the method is final, my understanding is that the compiler or the JVM would replace the dynamic disp

4条回答
  •  温柔的废话
    2021-02-08 15:43

    The JIT-compiler cannot do this, since it is quite common to create proxies for interfaces at runtime, so the JIT-compiler can never be sure that there won't be a dynamic proxy that implements a certain interface.

提交回复
热议问题