public UnsafeCopier build ( Unsafe unsafe ) throws IllegalAccessException , InstantiationException , NoSuchMethodException , InvocationTargetException { checkArgument ( offset >= 0 , "Offset must be set" ) ; checkArgument ( length >= 0 , "Length must be set" ) ; checkNotNull ( unsafe ) ; Class < ? > dynamicType = new ByteBuddy ( ) . subclass ( UnsafeCopier . class ) . method ( named ( "copy" ) ) . intercept ( new CopierImplementation ( offset , length ) ) . make ( ) . load ( getClass ( ) . getClassLoader ( ) , ClassLoadingStrategy . Default . WRAPPER ) . getLoaded ( ) ; return ( UnsafeCopier ) dynamicType . getDeclaredConstructor ( Unsafe . class ) . newInstance ( unsafe ) ; }
Constructs a new Copier using the passed in Unsafe instance