@ SuppressWarnings ( "all" ) public static boolean register ( ClassFileTransformer classFileTransformer , Object classFileFactory ) { try { TypeDescription typeDescription = TypeDescription . ForLoadedType . of ( LambdaFactory . class ) ; Class < ? > lambdaFactory = ClassInjector . UsingReflection . ofSystemClassLoader ( ) . inject ( Collections . singletonMap ( typeDescription , ClassFileLocator . ForClassLoader . read ( LambdaFactory . class ) ) ) . get ( typeDescription ) ; @ SuppressWarnings ( "unchecked" ) Map < ClassFileTransformer , Object > classFileTransformers = ( Map < ClassFileTransformer , Object > ) lambdaFactory . getField ( FIELD_NAME ) . get ( null ) ; synchronized ( classFileTransformers ) { try { return classFileTransformers . isEmpty ( ) ; } finally { classFileTransformers . put ( classFileTransformer , lambdaFactory . getConstructor ( Object . class , Method . class ) . newInstance ( classFileFactory , classFileFactory . getClass ( ) . getMethod ( "make" , Object . class , String . class , Object . class , Object . class , Object . class , Object . class , boolean . class , List . class , List . class , Collection . class ) ) ) ; } } } catch ( RuntimeException exception ) { throw exception ; } catch ( Exception exception ) { throw new IllegalStateException ( "Could not register class file transformer" , exception ) ; } }
Registers a class file transformer together with a factory for creating a lambda expression . It is possible to call this method independently of the class loader s context as the supplied injector makes sure that the manipulated collection is the one that is held by the system class loader .