MethodHandle - What is it all about?

后端 未结 4 1942
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 14:15

I am studying new features of JDK 1.7 and I just can\'t get it what MethodHandle is designed for? I understand (direct) invocation of the static method (and use of Core Refl

4条回答
  •  旧时难觅i
    2020-12-04 14:40

    java.lang.reflect.Method is relatively slow and expensive in terms of memory. Method handles are supposed to be a "lightweight" way of passing around pointers to functions that the JVM has a chance of optimising. As of JDK8 method handles aren't that well optimised, and lambdas are likely to be initially implemented in terms of classes (as inner classes are).

提交回复
热议问题