@SuppressWarnings("TypeParameterExtendsFinalClass") private static boolean unsafeByteArrayCopyAvailable(){
  try {
    Class<? extends Unsafe> unsafeCls=Unsafe.class;
    unsafeCls.getMethod("copyMemory",Object.class,long.class,Object.class,long.class,long.class);
    return true;
  }
 catch (  Exception ignored) {
    return false;
  }
}

@ SuppressWarnings ( "TypeParameterExtendsFinalClass" ) private static boolean unsafeByteArrayCopyAvailable ( ) { try { Class < ? extends Unsafe > unsafeCls = Unsafe . class ; unsafeCls . getMethod ( "copyMemory" , Object . class , long . class , Object . class , long . class , long . class ) ; return true ; } catch ( Exception ignored ) { return false ; } }
as long as array copying uses jvm - private api , which is not guaranteed to be available on all jvm , this method should be called to ensure logic could work properly .
