I understand that left side of the arrow has the arguments and right side of the arrow is the function where the arguments go to. But, I would like to know how does java 8 map the left side and right side and convert into a Function. What happens there and where can I find the information?
When you have an ->
the javac compiler adds a static method with the contents of the code. It also adds dynamic call side information to the class so the JVM can map the interface the lambda implements to the arguments and return type. The JVM generates code at runtime to bind the interface to the generated method.
A difference with lambdas and anonymous classes is that implict variables only need to be effectively final (as in could have been made final) and member variables are copied i.e. it doesn't keep a reference to the this
of an outer class.
It can tell the difference between Runnable
and Callable<void>
even though both take no arguments. For more details http://vanillajava.blogspot.com/2014/09/lambdas-and-side-effects.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With