diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilsTest.java
index 707785be1e5..0e3f6c0be87 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilsTest.java
@@ -30,9 +30,9 @@ public class ArrayUtilsTest extends TestCase {
assertEquals(o2, array[1]);
assertEquals(o3, array[2]);
- array= ArrayUtil.append(Object.class, null, 0, o1);
- array= ArrayUtil.append(Object.class, array, 1, o2);
- array= ArrayUtil.append(Object.class, array, 2, o3);
+ array= ArrayUtil.appendAt(Object.class, null, 0, o1);
+ array= ArrayUtil.appendAt(Object.class, array, 1, o2);
+ array= ArrayUtil.appendAt(Object.class, array, 2, o3);
assertEquals(o1, array[0]);
assertEquals(o2, array[1]);
assertEquals(o3, array[2]);
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
index 10c87060341..bf5b479e6bf 100644
--- a/core/org.eclipse.cdt.core/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -1,17 +1,55 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java
index 029c609b77e..5bd2d9863ba 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java
@@ -16,6 +16,8 @@ package org.eclipse.cdt.core.parser.util;
import java.lang.reflect.Array;
+import org.eclipse.core.runtime.Assert;
+
/**
* @noextend This class is not intended to be subclassed by clients.
*/
@@ -28,11 +30,12 @@ public abstract class ArrayUtil {
* If the array is null or not large enough, a larger one is allocated, using
* the given class object.
*/
- static public Object[] append(Class> c, Object[] array, Object obj) {
+ @SuppressWarnings("unchecked")
+ static public T[] append(Class extends T> c, T[] array, T obj) {
if (obj == null)
return array;
if (array == null || array.length == 0) {
- array = (Object[]) Array.newInstance(c, DEFAULT_LENGTH);
+ array = (T[]) Array.newInstance(c, DEFAULT_LENGTH);
array[0] = obj;
return array;
}
@@ -43,7 +46,7 @@ public abstract class ArrayUtil {
return array;
}
- Object[] temp = (Object[]) Array.newInstance(c, Math.max(array.length * 2, DEFAULT_LENGTH));
+ T[] temp = (T[]) Array.newInstance(c, Math.max(array.length * 2, DEFAULT_LENGTH));
System.arraycopy(array, 0, temp, 0, array.length);
temp[array.length] = obj;
return temp;
@@ -69,38 +72,12 @@ public abstract class ArrayUtil {
return haveNull ? right + 1 : -1;
}
- /**
- * Assumes that array contains nulls at the end, only.
- * Appends object using the current length of the array.
- * @since 4.0
- */
- static public Object[] append(Class> c, Object[] array, int currentLength, Object obj) {
- if (obj == null)
- return array;
- if (array == null || array.length == 0) {
- array = (Object[]) Array.newInstance(c, DEFAULT_LENGTH);
- array[0] = obj;
- return array;
- }
-
- if (currentLength < array.length) {
- assert array[currentLength] == null;
- assert currentLength == 0 || array[currentLength - 1] != null;
- array[currentLength]= obj;
- return array;
- }
-
- Object[] temp = (Object[]) Array.newInstance(c, array.length * 2);
- System.arraycopy(array, 0, temp, 0, array.length);
- temp[array.length] = obj;
- return temp;
- }
-
/**
* Assumes that array contains nulls at the end, only.
* Appends element after the last non-null element.
* If the array is not large enough, a larger one is allocated.
- * Null array
is supported for backward compatibility only and only when T is Object.
+ * Null array
is supported for backward compatibility only and only when T is
+ * Object.
*/
@SuppressWarnings("unchecked")
static public T[] append(T[] array, T obj) {
@@ -127,12 +104,41 @@ public abstract class ArrayUtil {
}
/**
- * Type safe version of {@link #append(Class, Object[], int, Object)}
+ * @deprecated Use {@link #appendAt(Class, Object[], int, Object)} instead.
+ * @since 4.0
+ */
+ @Deprecated
+ @SuppressWarnings("unchecked")
+ static public Object[] append(Class> c, Object[] array, int currentLength, Object obj) {
+ return appendAt((Class