Bug 526055 - NPE when rebuilding projects or launching junit

arrayCopy messed up src/trg.
Changing to Array#copyOf as this is less error-prone.

Change-Id: I293c2465de3a9cae9d7295774ada500bea65ecbc
Signed-off-by: Frank Benoit <frank.benoit.ext@valeo.com>
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
index 2038cf4..8ce2c34 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
@@ -14,6 +14,8 @@
 package org.eclipse.jdt.internal.launching;
 
 
+import java.util.Arrays;
+
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -674,14 +676,12 @@
 	private static IClasspathAttribute[] setClasspathAttribute(IClasspathAttribute[] attributes, String name, String value) {
 		for (int i = attributes.length; --i >= 0;) {
 			if (name.equals(attributes[i].getName())) {
-				IClasspathAttribute[] nw = new IClasspathAttribute[attributes.length];
-				System.arraycopy(nw, 0, attributes, 0, attributes.length);
+				IClasspathAttribute[] nw = Arrays.copyOf(attributes, attributes.length);
 				nw[i] = JavaCore.newClasspathAttribute(name, value);
 				return nw;
 			}
 		}
-		IClasspathAttribute[] nw = new IClasspathAttribute[attributes.length + 1];
-		System.arraycopy(nw, 0, attributes, 0, attributes.length);
+		IClasspathAttribute[] nw = Arrays.copyOf(attributes, attributes.length + 1);
 		nw[attributes.length] = JavaCore.newClasspathAttribute(name, value);
 		return nw;
 	}