001 package org.bukkit.util; 002 003 import java.lang.reflect.Array; 004 005 public class Java15Compat { 006 @SuppressWarnings("unchecked") 007 public static <T> T[] Arrays_copyOfRange(T[] original, int start, int end) { 008 if (original.length >= start && 0 <= start) { 009 if (start <= end) { 010 int length = end - start; 011 int copyLength = Math.min(length, original.length - start); 012 T[] copy = (T[]) Array.newInstance(original.getClass().getComponentType(), length); 013 014 System.arraycopy(original, start, copy, 0, copyLength); 015 return copy; 016 } 017 throw new IllegalArgumentException(); 018 } 019 throw new ArrayIndexOutOfBoundsException(); 020 } 021 }