@NotNull @Override public BytesStore<NativeBytesStore<Underlying>, Underlying> copy() throws IllegalStateException { if (underlyingObject == null) { NativeBytesStore<Void> copy = of(realCapacity(), false, true); OS.memory().copyMemory(address, copy.address, capacity()); return (BytesStore) copy; } else if (underlyingObject instanceof ByteBuffer) { ByteBuffer bb = ByteBuffer.allocateDirect(Maths.toInt32(capacity())); bb.put((ByteBuffer) underlyingObject); bb.clear(); return (BytesStore) wrap(bb); } else { throw new UnsupportedOperationException(); } }