code: public final void copyTo(int offset, MemorySegment target, int targetOffset, int numBytes) {
  		final byte[] thisHeapRef = this.heapMemory;
  		final byte[] otherHeapRef = target.heapMemory;
  		final long thisPointer = this.address + offset;
  		final long otherPointer = target.address + targetOffset;
  
  		if ((numBytes | offset | targetOffset) >= 0 &&
  				thisPointer <= this.addressLimit - numBytes && otherPointer <= target.addressLimit - numBytes) {
  			UNSAFE.copyMemory(thisHeapRef, thisPointer, otherHeapRef, otherPointer, numBytes);
  		}
  		else if (this.address > this.addressLimit) {
  			throw new IllegalStateException("this memory segment has been freed.");
  		}
  		else if (target.address > target.addressLimit) {
  			throw new IllegalStateException("target memory segment has been freed.");
  		}
  		else {
  			throw new IndexOutOfBoundsException(
  					String.format("offset=%d, targetOffset=%d, numBytes=%d, address=%d, targetAddress=%d",
  					offset, targetOffset, numBytes, this.address, target.address));
  		}
  	}
docs: Bulk copy method. Copies {@code numBytes} bytes from this memory segment, starting at position
  {@code offset} to the target memory segment. The bytes will be put into the target segment
  starting at position {@code targetOffset}.
  
  @param offset The position where the bytes are started to be read from in this memory segment.
  @param target The memory segment to copy the bytes to.
  @param targetOffset The position in the target memory segment to copy the chunk to.
  @param numBytes The number of bytes to copy.
  
  @throws IndexOutOfBoundsException If either of the offsets is invalid, or the source segment does not
  contain the given number of bytes (starting from offset), or the target segment does
  not have enough space for the bytes (counting from targetOffset).