UnrolledUnsafeCopierBuilder { 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); } UnrolledUnsafeCopierBuilder(); UnrolledUnsafeCopierBuilder of(Class clazz); UnrolledUnsafeCopierBuilder offset(long offset); UnrolledUnsafeCopierBuilder length(long length); UnsafeCopier build(Unsafe unsafe);  }
@Test(expected = IllegalArgumentException.class) public void testNoSetup() throws Exception { new UnrolledUnsafeCopierBuilder().build(null); }