KryoCloneUtils { @SuppressWarnings("unchecked") public T[] getClones(int num) { T[] ts = (T[])Array.newInstance(clazz, num); try (Input input = new Input(bin)) { for (int i = 0; i < ts.length; i++) { input.rewind(); ts[i] = kryo.readObject(input, clazz); } } return ts; } @SuppressWarnings("unchecked") private  KryoCloneUtils(Kryo kryo, T t); T getClone(); @SuppressWarnings("unchecked") T[] getClones(int num); @SuppressWarnings("unchecked") static SRC cloneObject(Kryo kryo, SRC src); static SRC cloneObject(SRC src); static KryoCloneUtils<SRC> createCloneUtils(SRC template); static KryoCloneUtils<SRC> createCloneUtils(Kryo kryo, SRC template);  }
@Test public void testGetClones() throws Exception { TestEntity from = getTestEntity(5); KryoCloneUtils<TestEntity> cloneUtils = KryoCloneUtils.createCloneUtils(from); TestEntity[] to = cloneUtils.getClones(10); for (TestEntity te : to) { assertFalse(te == from); assertEquals(from, te); assertFalse(from.transientProp.equals(te.transientProp)); } }