Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 75 inside the jvm method types to ensure static type safety along with a method handle pointing at the private static method containing the lambda method body It returns a callsite that will lace in the lambda body if it is ever called public static CallSite metafactory MethodHandles Lookup caller String invokedName MethodType invokedType MethodType samMethodType MethodHandle implMethod MethodType instantiatedMethodType throws LambdaConversionException AbstractValidatingLambdaMetafactory mf mf new InnerClassLambdaMetafactory caller invokedType invokedName samMethodType implMethod instantiatedMethodType false EMPTY_ CLASS_ ARRAY EMPTY_ MT_ ARRAY mf validateMetafactoryArgs return mf buildCallSite The current implementation uses a private metafactory that will still create an inner class per lambda but the classes are dynamically created and are never written to disk This means that the implementation mechanism could change with a future release of Java and any existing lambdas will be able to take advantage of the new mechanism In Java 8 and Java 9 the implementation based on the InnerClassLambdaMetafactory class makes use of a slightly modified version of the ASM bytecode manipulation library that ships in the package jdk internal org objectweb asm
You must have JavaScript enabled to view digital editions.