diff --git a/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java b/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java deleted file mode 100644 index c9c5f284df..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import java.lang.reflect.Array; - -public class Java15Compat { - public static T[] Arrays_copyOf(T[] original, int newLength) { - if (0 <= newLength) { - return org.bukkit.util.Java15Compat.Arrays_copyOfRange(original, 0, newLength); - } - throw new NegativeArraySizeException(); - } - - public static long[] Arrays_copyOf(long[] original, int newLength) { - if (0 <= newLength) { - return Arrays_copyOfRange(original, 0, newLength); - } - throw new NegativeArraySizeException(); - } - - private static long[] Arrays_copyOfRange(long[] original, int start, int end) { - if (original.length >= start && 0 <= start) { - if (start <= end) { - int length = end - start; - int copyLength = Math.min(length, original.length - start); - long[] copy = (long[]) Array.newInstance(original.getClass().getComponentType(), length); - System.arraycopy(original, start, copy, 0, copyLength); - return copy; - } - throw new IllegalArgumentException(); - } - throw new ArrayIndexOutOfBoundsException(); - } - -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java index 22c96c5ab5..a213579220 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java +++ b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java @@ -16,6 +16,7 @@ package org.bukkit.craftbukkit.util; +import java.util.Arrays; import java.util.Iterator; import java.util.ConcurrentModificationException; import java.util.NoSuchElementException; @@ -165,7 +166,7 @@ public class LongHashSet { public long[] toArray() { long[] result = new long[elements]; - long[] values = Java15Compat.Arrays_copyOf(this.values, this.values.length); + long[] values = Arrays.copyOf(this.values, this.values.length); int pos = 0; for (long value : values) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java b/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java index 01861ccff8..0cd430a3ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java +++ b/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java @@ -15,8 +15,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; -import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf; - @SuppressWarnings("unchecked") public class LongObjectHashMap implements Cloneable, Serializable { static final long serialVersionUID = 2841537710170573815L; @@ -112,9 +110,9 @@ public class LongObjectHashMap implements Cloneable, Serializable { } // chain is full, resize it and add our new entry - keys[index] = innerKeys = Arrays_copyOf(innerKeys, i << 1); + keys[index] = innerKeys = Arrays.copyOf(innerKeys, i << 1); Arrays.fill(innerKeys, i, innerKeys.length, EMPTY_KEY); - values[index] = innerValues = Arrays_copyOf(innerValues, i << 1); + values[index] = innerValues = Arrays.copyOf(innerValues, i << 1); innerKeys[i] = key; innerValues[i] = value; size++; diff --git a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java index 1351ecd83b..08d105603c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java +++ b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java @@ -5,6 +5,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.AbstractList; +import java.util.Arrays; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.List; @@ -129,7 +130,7 @@ public class UnsafeList extends AbstractList implements List, RandomAcc int old = data.length; int rounded = Integer.highestOneBit(size - 1) << 1; if (rounded < old) { - data = Java15Compat.Arrays_copyOf(data, rounded); + data = Arrays.copyOf(data, rounded); } } @@ -143,7 +144,7 @@ public class UnsafeList extends AbstractList implements List, RandomAcc public Object clone() throws CloneNotSupportedException { UnsafeList copy = (UnsafeList) super.clone(); - copy.data = Java15Compat.Arrays_copyOf(data, size); + copy.data = Arrays.copyOf(data, size); copy.size = size; copy.initialCapacity = initialCapacity; copy.iterPool = new Iterator[1];