Archiviert
13
0

Remove unneeded Java 1.5 Compat

Dieser Commit ist enthalten in:
Matt 2015-04-29 11:45:43 -04:00 committet von md_5
Ursprung 7722428895
Commit 0a645a2726
4 geänderte Dateien mit 7 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -1,34 +0,0 @@
package org.bukkit.craftbukkit.util;
import java.lang.reflect.Array;
public class Java15Compat {
public static <T> 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();
}
}

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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<V> implements Cloneable, Serializable {
static final long serialVersionUID = 2841537710170573815L;
@ -112,9 +110,9 @@ public class LongObjectHashMap<V> 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++;

Datei anzeigen

@ -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<E> extends AbstractList<E> implements List<E>, 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<E> extends AbstractList<E> implements List<E>, RandomAcc
public Object clone() throws CloneNotSupportedException {
UnsafeList<E> copy = (UnsafeList<E>) 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];