Bug 499738 - Enrich IAEs with information about actual arguments

Change-Id: I4b37c927cfabc87e2f98be9b38b82716432b2a79
Signed-off-by: Andreas Sewe <sewe@cqse.eu>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 35d46dd..c5ef13b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -5799,10 +5799,14 @@
 			case 'S':
 				return index;
 			default:
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(methodSignature, index);
 		}
 	}
 
+	private static IllegalArgumentException newIllegalArgumentException(char[] string, int index) {
+		return new IllegalArgumentException("\"" + String.valueOf(string) + "\" at " + index); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
 	/**
 	 * INTERNAL USE-ONLY
 	 * This methods leaves the space for method counts recording.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
index 8d094df..3458a75 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -1257,7 +1257,7 @@
 			int count = 0;
 			int i = CharOperation.indexOf(C_PARAM_START, methodSignature);
 			if (i < 0) {
-				throw new IllegalArgumentException();
+				throw new IllegalArgumentException(String.valueOf(methodSignature));
 			} else {
 				i++;
 			}
@@ -1267,14 +1267,14 @@
 				}
 				int e= Util.scanTypeSignature(methodSignature, i);
 				if (e < 0) {
-					throw new IllegalArgumentException();
+					throw new IllegalArgumentException(String.valueOf(methodSignature));
 				} else {
 					i = e + 1;
 				}
 				count++;
 			}
 		} catch (ArrayIndexOutOfBoundsException e) {
-			throw new IllegalArgumentException(e);
+			throw new IllegalArgumentException(String.valueOf(methodSignature), e);
 		}
 	}
 
@@ -1297,7 +1297,7 @@
 	public static int scanTypeSignature(char[] string, int start) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		switch (c) {
@@ -1325,7 +1325,7 @@
 			case C_STAR:
 				return scanTypeBoundSignature(string, start);
 			default :
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 		}
 	}
 
@@ -1349,13 +1349,13 @@
 	public static int scanBaseTypeSignature(char[] string, int start) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if ("BCDFIJSVZ".indexOf(c) >= 0) { //$NON-NLS-1$
 			return start;
 		} else {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 	}
 
@@ -1376,18 +1376,18 @@
 		int length = string.length;
 		// need a minimum 2 char
 		if (start >= length - 1) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != C_ARRAY) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 	
 		c = string[++start];
 		while(c == C_ARRAY) {
 			// need a minimum 2 char
 			if (start >= length - 1) {
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[++start];
 		}
@@ -1410,11 +1410,11 @@
 	public static int scanCaptureTypeSignature(char[] string, int start) {
 		// need a minimum 2 char
 		if (start >= string.length - 1) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != C_CAPTURE) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		return scanTypeBoundSignature(string, start + 1);
 	}
@@ -1435,19 +1435,19 @@
 	public static int scanTypeVariableSignature(char[] string, int start) {
 		// need a minimum 3 chars "Tx;"
 		if (start >= string.length - 2) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		// must start in "T"
 		char c = string[start];
 		if (c != C_TYPE_VARIABLE) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		int id = scanIdentifier(string, start + 1);
 		c = string[id + 1];
 		if (c == C_SEMICOLON) {
 			return id + 1;
 		} else {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 	}
 
@@ -1464,7 +1464,7 @@
 	public static int scanIdentifier(char[] string, int start) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		int p = start;
 		while (true) {
@@ -1500,7 +1500,7 @@
 	public static int scanClassTypeSignature(char[] string, int start) {
 		// need a minimum 3 chars "Lx;"
 		if (start >= string.length - 2) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		// must start in "L" or "Q"
 		char c = string[start];
@@ -1510,7 +1510,7 @@
 		int p = start + 1;
 		while (true) {
 			if (p >= string.length) {
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[p];
 			if (c == C_SEMICOLON) {
@@ -1544,7 +1544,7 @@
 	public static int scanTypeBoundSignature(char[] string, int start) {
 		// need a minimum 1 char for wildcard
 		if (start >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		switch (c) {
@@ -1555,8 +1555,7 @@
 				break;
 			default :
 				// must start in "+/-"
-				throw new IllegalArgumentException();
-	
+				throw newIllegalArgumentException(string, start);
 		}
 		c = string[++start];
 		if (c != C_STAR && start >= string.length -1) { // unless "-*" we need at least one more char, e.g. after "+[", other variants are even longer
@@ -1578,7 +1577,7 @@
 			case C_STAR:
 				return start;
 			default:
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 		}
 	}
 
@@ -1602,16 +1601,16 @@
 	public static int scanTypeArgumentSignatures(char[] string, int start) {
 		// need a minimum 2 char "<>"
 		if (start >= string.length - 1) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != C_GENERIC_START) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		int p = start + 1;
 		while (true) {
 			if (p >= string.length) {
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[p];
 			if (c == C_GENERIC_END) {
@@ -1643,7 +1642,7 @@
 	public static int scanTypeArgumentSignature(char[] string, int start) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		switch (c) {
@@ -1719,4 +1718,8 @@
 				}
 		}
 	}
+
+	private static IllegalArgumentException newIllegalArgumentException(char[] string, int start) {
+		return new IllegalArgumentException("\"" + String.valueOf(string) + "\" at " + start); //$NON-NLS-1$ //$NON-NLS-2$
+	}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
index 13b1f94..b9ec8ef 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
@@ -533,11 +533,11 @@
 	int length = string.length;
 	// need a minimum 2 char
 	if (start >= length - 1) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	if (c != C_ARRAY) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 
 	int index = start;
@@ -545,7 +545,7 @@
 	while(c == C_ARRAY) {
 		// need a minimum 2 char
 		if (index >= length - 1) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		c = string[++index];
 	}
@@ -579,11 +579,11 @@
 private static int appendCaptureTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer) {
 	// need a minimum 2 char
 	if (start >= string.length - 1) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	if (c != C_CAPTURE) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	buffer.append(CAPTURE).append(' ');
 	return appendTypeArgumentSignature(string, start + 1, fullyQualifyTypeNames, buffer);
@@ -605,12 +605,12 @@
 private static int appendClassTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer) {
 	// need a minimum 3 chars "Lx;"
 	if (start >= string.length - 2) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	// must start in "L" or "Q"
 	char c = string[start];
 	if (c != C_RESOLVED && c != C_UNRESOLVED) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	boolean resolved = (c == C_RESOLVED);
 	boolean removePackageQualifiers = !fullyQualifyTypeNames;
@@ -624,7 +624,7 @@
 	boolean inAnonymousType = false;
 	while (true) {
 		if (p >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		c = string[p];
 		switch(c) {
@@ -698,11 +698,11 @@
 private static int appendIntersectionTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer) {
 	// need a minimum 2 char
 	if (start >= string.length - 1) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	if (c != C_INTERSECTION) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	start = appendClassTypeSignature(string, start + 1, fullyQualifyTypeNames, buffer);
 	if (start < string.length - 1) {
@@ -795,7 +795,7 @@
 private static int appendTypeArgumentSignature(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer) {
 	// need a minimum 1 char
 	if (start >= string.length) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	switch(c) {
@@ -831,18 +831,18 @@
 private static int appendTypeArgumentSignatures(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer) {
 	// need a minimum 2 char "<>"
 	if (start >= string.length - 1) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	if (c != C_GENERIC_START) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	buffer.append('<');
 	int p = start + 1;
 	int count = 0;
 	while (true) {
 		if (p >= string.length) {
-			throw new IllegalArgumentException();
+			throw newIllegalArgumentException(string, start);
 		}
 		c = string[p];
 		if (c == C_GENERIC_END) {
@@ -895,7 +895,7 @@
 private static int appendTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, StringBuffer buffer, boolean isVarArgs) {
 	// need a minimum 1 char
 	if (start >= string.length) {
-		throw new IllegalArgumentException();
+		throw newIllegalArgumentException(string, start);
 	}
 	char c = string[start];
 	if (isVarArgs) {
@@ -920,7 +920,7 @@
 			case C_CAPTURE:
 			case C_INTERSECTION :
 			default:
-				throw new IllegalArgumentException(); // a var args is an array type
+				throw newIllegalArgumentException(string, start); // a var args is an array type
 		}
 	} else {
 		switch (c) {
@@ -969,7 +969,7 @@
 			case C_SUPER:
 				return appendTypeArgumentSignature(string, start, fullyQualifyTypeNames, buffer);
 			default :
-				throw new IllegalArgumentException();
+				throw newIllegalArgumentException(string, start);
 		}
 	}
 }
@@ -1022,7 +1022,7 @@
     pos = consumeWhitespace(typeName, pos, length);
     if (pos < length && typeName[pos] == expectedChar)
         return pos + 1;
-    if (!isOptional) throw new IllegalArgumentException(new String(typeName));
+    if (!isOptional) throw new IllegalArgumentException(String.valueOf(typeName));
     return -1;
 }
 
@@ -1089,11 +1089,11 @@
 public static char[] createCharArrayTypeSignature(char[] typeName, boolean isResolved) {
 	if (typeName == null) throw new IllegalArgumentException("null"); //$NON-NLS-1$
 	int length = typeName.length;
-	if (length == 0) throw new IllegalArgumentException(new String(typeName));
+	if (length == 0) throw new IllegalArgumentException(String.valueOf(typeName));
 	StringBuffer buffer = new StringBuffer(5);
 	int pos = encodeTypeSignature(typeName, 0, isResolved, length, buffer);
 	pos = consumeWhitespace(typeName, pos, length);
-	if (pos < length) throw new IllegalArgumentException(new String(typeName));
+	if (pos < length) throw new IllegalArgumentException(String.valueOf(typeName));
 	char[] result = new char[length = buffer.length()];
 	buffer.getChars(0, length, result, 0);
 	return result;
@@ -1368,14 +1368,14 @@
 		}
 	    pos++;
     }
-    if (count == 0) throw new IllegalArgumentException(new String(typeName));
+    if (count == 0) throw new IllegalArgumentException(String.valueOf(typeName));
 	return pos;
 }
 
 private static int encodeTypeSignature(char[] typeName, int start, boolean isResolved, int length, StringBuffer buffer) {
     int pos = start;
     pos = consumeWhitespace(typeName, pos, length);
-    if (pos >= length) throw new IllegalArgumentException(new String(typeName));
+    if (pos >= length) throw new IllegalArgumentException(String.valueOf(typeName));
     int checkPos;
     char currentChar = typeName[pos];
     switch (currentChar) {
@@ -1536,7 +1536,7 @@
 		}
 		return count;
 	} catch (ArrayIndexOutOfBoundsException e) { // signature is syntactically incorrect if last character is C_ARRAY
-		throw new IllegalArgumentException(e);
+		throw new IllegalArgumentException(String.valueOf(typeSignature));
 	}
 }
 
@@ -1698,7 +1698,7 @@
 		int count = 0;
 		int i = CharOperation.indexOf(C_PARAM_START, methodSignature);
 		if (i < 0) {
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(methodSignature));
 		} else {
 			i++;
 		}
@@ -1708,14 +1708,14 @@
 			}
 			int e= Util.scanTypeSignature(methodSignature, i);
 			if (e < 0) {
-				throw new IllegalArgumentException();
+				throw new IllegalArgumentException(String.valueOf(methodSignature));
 			} else {
 				i = e + 1;
 			}
 			count++;
 		}
 	} catch (ArrayIndexOutOfBoundsException e) {
-		throw new IllegalArgumentException(e);
+		throw new IllegalArgumentException(String.valueOf(methodSignature), e);
 	}
 }
 
@@ -1751,7 +1751,7 @@
 		}
 		int i = CharOperation.indexOf(C_PARAM_START, methodSignature);
 		if (i < 0) {
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(methodSignature));
 		} else {
 			i++;
 		}
@@ -1762,14 +1762,14 @@
 			}
 			int e = Util.scanTypeSignature(methodSignature, i);
 			if (e < 0) {
-				throw new IllegalArgumentException();
+				throw new IllegalArgumentException(String.valueOf(methodSignature));
 			}
 			result[t] = CharOperation.subarray(methodSignature, i, e + 1);
 			t++;
 			i = e + 1;
 		}
 	} catch (ArrayIndexOutOfBoundsException e) {
-		throw new IllegalArgumentException(e);
+		throw new IllegalArgumentException(String.valueOf(methodSignature), e);
 	}
 }
 /**
@@ -1853,7 +1853,7 @@
 	// skip type parameters
 	int paren = CharOperation.lastIndexOf(C_PARAM_END, methodSignature);
 	if (paren == -1) {
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(methodSignature));
 	}
 	// there could be thrown exceptions behind, thus scan one type exactly
 	int last = Util.scanTypeSignature(methodSignature, paren+1);
@@ -2210,13 +2210,13 @@
 	if (exceptionStart == -1) {
 		int paren = CharOperation.lastIndexOf(C_PARAM_END, methodSignature);
 		if (paren == -1) {
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(methodSignature));
 		}
 		// ignore return type
 		exceptionStart = Util.scanTypeSignature(methodSignature, paren+1) + 1;
 		int length = methodSignature.length;
 		if (exceptionStart == length) return CharOperation.NO_CHAR_CHAR;
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(methodSignature));
 	}
 	int length = methodSignature.length;
 	int i = exceptionStart;
@@ -2226,7 +2226,7 @@
 			exceptionStart++;
 			i++;
 		} else {
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(methodSignature));
 		}
 		i = Util.scanTypeSignature(methodSignature, i) + 1;
 		exceptionList.add(CharOperation.subarray(methodSignature, exceptionStart,i));
@@ -2279,12 +2279,12 @@
 		}
 	}
 	if (start < 0) // invalid number of generic start/end
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(parameterizedTypeSignature));
 	ArrayList args = new ArrayList();
 	int p = start + 1;
 	while (true) {
 		if (p >= parameterizedTypeSignature.length) {
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(parameterizedTypeSignature));
 		}
 		char c = parameterizedTypeSignature[p];
 		if (c == C_GENERIC_END) {
@@ -2344,12 +2344,12 @@
 				break;
 			case C_GENERIC_END:
 				deep--;
-				if (deep < 0) throw new IllegalArgumentException();
+				if (deep < 0) throw new IllegalArgumentException(String.valueOf(parameterizedTypeSignature));
 				if (deep == 0) start = idx+1;
 				break;
 		}
 	}
-	if (deep > 0) throw new IllegalArgumentException();
+	if (deep > 0) throw new IllegalArgumentException(String.valueOf(parameterizedTypeSignature));
 	int size = pos+length-start;
 	char[] resized = new char[size];
 	System.arraycopy(result, 0, resized, 0, pos);
@@ -2388,7 +2388,7 @@
 	int p1 = CharOperation.indexOf(C_COLON, formalTypeParameterSignature);
 	if (p1 < 0) {
 		// no ":" means can't be a formal type parameter signature
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(formalTypeParameterSignature));
 	}
 	if (p1 == formalTypeParameterSignature.length - 1) {
 		// no class or interface bounds
@@ -2456,14 +2456,14 @@
 		while (i < length) {
 			if (methodOrTypeSignature[i] == C_GENERIC_END) {
 				int size = paramList.size();
-				if (size == 0) throw new IllegalArgumentException();
+				if (size == 0) throw new IllegalArgumentException(String.valueOf(methodOrTypeSignature));
 				char[][] result;
 				paramList.toArray(result = new char[size][]);
 				return result;
 			}
 			i = CharOperation.indexOf(C_COLON, methodOrTypeSignature, i);
 			if (i < 0 || i >= length)
-				throw new IllegalArgumentException();
+				throw new IllegalArgumentException(String.valueOf(methodOrTypeSignature));
 			// iterate over bounds
 			while (methodOrTypeSignature[i] == ':') {
 				i++; // skip colon
@@ -2514,7 +2514,7 @@
 	} catch (ArrayIndexOutOfBoundsException e) {
 		// invalid signature, fall through
 	}
-	throw new IllegalArgumentException();
+	throw new IllegalArgumentException(String.valueOf(methodOrTypeSignature));
 }
 /**
  * Extracts the type parameter signatures from the given method or type signature.
@@ -2596,7 +2596,7 @@
 		case C_UNION :
 			return UNION_TYPE_SIGNATURE;
 		default :
-			throw new IllegalArgumentException();
+			throw new IllegalArgumentException(String.valueOf(typeSignature));
 	}
 }
 
@@ -2629,7 +2629,7 @@
 	int p = CharOperation.indexOf(C_COLON, formalTypeParameterSignature);
 	if (p < 0) {
 		// no ":" means can't be a formal type parameter signature
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(formalTypeParameterSignature));
 	}
 	return CharOperation.subarray(formalTypeParameterSignature, 0, p);
 }
@@ -2799,7 +2799,7 @@
 public static char[] toCharArray(char[] methodSignature, char[] methodName, char[][] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVargArgs) {
 	int firstParen = CharOperation.indexOf(C_PARAM_START, methodSignature);
 	if (firstParen == -1) {
-		throw new IllegalArgumentException();
+		throw new IllegalArgumentException(String.valueOf(methodSignature));
 	}
 
 	StringBuffer buffer = new StringBuffer(methodSignature.length + 10);
@@ -2996,6 +2996,11 @@
 	}
 	return new String(toCharArray(methodSignature.toCharArray(), methodName == null ? null : methodName.toCharArray(), params, fullyQualifyTypeNames, includeReturnType, isVarArgs));
 }
+
+private static IllegalArgumentException newIllegalArgumentException(char[] string, int start) {
+	return new IllegalArgumentException("\"" + String.valueOf(string) + "\" at " + start); //$NON-NLS-1$ //$NON-NLS-2$
+}
+
 private Signature() {
 	// Not instantiable
 }
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
index cd53f09..2b323ea 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -2515,11 +2515,11 @@
 		int length = string.length;
 		// need a minimum 2 char
 		if (start >= length - 1) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != Signature.C_ARRAY) {
-			throw raiseUnexpectedCharacterException(string, start, c);
+			throw newUnexpectedCharacterException(string, start, c);
 		}
 
 		int index = start;
@@ -2527,7 +2527,7 @@
 		while(c == Signature.C_ARRAY) {
 			// need a minimum 2 char
 			if (index >= length - 1) {
-				throw raiseIllegalSignatureException(string, start);
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[++index];
 		}
@@ -3023,7 +3023,7 @@
 	public static char[] toAnchor(int startingIndex, char[] methodSignature, char[] methodName, boolean isVargArgs) {
 		int firstParen = CharOperation.indexOf(Signature.C_PARAM_START, methodSignature);
 		if (firstParen == -1) {
-			throw new IllegalArgumentException(new String(methodSignature));
+			throw new IllegalArgumentException(String.valueOf(methodSignature));
 		}
 
 		StringBuffer buffer = new StringBuffer(methodSignature.length + 10);
@@ -3056,7 +3056,7 @@
 	private static int appendTypeSignatureForAnchor(char[] string, int start, StringBuffer buffer, boolean isVarArgs) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (isVarArgs) {
@@ -3080,7 +3080,7 @@
 				case Signature.C_CAPTURE:
 				default:
 					// a var args is an array type
-					throw raiseUnexpectedCharacterException(string, start, c);
+					throw newUnexpectedCharacterException(string, start, c);
 			}
 		} else {
 			switch (c) {
@@ -3126,7 +3126,7 @@
 				case Signature.C_SUPER:
 					return appendTypeArgumentSignatureForAnchor(string, start, buffer);
 				default :
-					throw raiseIllegalSignatureException(string, start);
+					throw newIllegalArgumentException(string, start);
 			}
 		}
 	}
@@ -3134,7 +3134,7 @@
 	private static int appendTypeArgumentSignatureForAnchor(char[] string, int start, StringBuffer buffer) {
 		// need a minimum 1 char
 		if (start >= string.length) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		switch(c) {
@@ -3151,11 +3151,11 @@
 	private static int appendCaptureTypeSignatureForAnchor(char[] string, int start, StringBuffer buffer) {
 		// need a minimum 2 char
 		if (start >= string.length - 1) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != Signature.C_CAPTURE) {
-			throw raiseUnexpectedCharacterException(string, start, c);
+			throw newUnexpectedCharacterException(string, start, c);
 		}
 		return appendTypeArgumentSignatureForAnchor(string, start + 1, buffer);
 	}
@@ -3163,11 +3163,11 @@
 		int length = string.length;
 		// need a minimum 2 char
 		if (start >= length - 1) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		char c = string[start];
 		if (c != Signature.C_ARRAY) {
-			throw raiseUnexpectedCharacterException(string, start, c);
+			throw newUnexpectedCharacterException(string, start, c);
 		}
 
 		int index = start;
@@ -3175,7 +3175,7 @@
 		while(c == Signature.C_ARRAY) {
 			// need a minimum 2 char
 			if (index >= length - 1) {
-				throw raiseIllegalSignatureException(string, start);
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[++index];
 		}
@@ -3196,17 +3196,17 @@
 	private static int appendClassTypeSignatureForAnchor(char[] string, int start, StringBuffer buffer) {
 		// need a minimum 3 chars "Lx;"
 		if (start >= string.length - 2) {
-			throw raiseIllegalSignatureException(string, start);
+			throw newIllegalArgumentException(string, start);
 		}
 		// must start in "L" or "Q"
 		char c = string[start];
 		if (c != Signature.C_RESOLVED && c != Signature.C_UNRESOLVED) {
-			throw raiseUnexpectedCharacterException(string, start, c);
+			throw newUnexpectedCharacterException(string, start, c);
 		}
 		int p = start + 1;
 		while (true) {
 			if (p >= string.length) {
-				throw raiseIllegalSignatureException(string, start);
+				throw newIllegalArgumentException(string, start);
 			}
 			c = string[p];
 			switch(c) {
@@ -3241,12 +3241,12 @@
 		}
 	}
 
-	private static IllegalArgumentException raiseIllegalSignatureException(char[] string, int start) {
-		throw new IllegalArgumentException("\"" + new String(string) + "\" starting at " + start); //$NON-NLS-1$ //$NON-NLS-2$
+	private static IllegalArgumentException newIllegalArgumentException(char[] string, int index) {
+		return new IllegalArgumentException("\"" + String.valueOf(string) + "\" at " + index); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	private static IllegalArgumentException raiseUnexpectedCharacterException(char[] string, int start, char unexpected) {
-		throw new IllegalArgumentException("Unexpected '" + unexpected + "' in \"" + new String(string) + "\" starting at " + start); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	private static IllegalArgumentException newUnexpectedCharacterException(char[] string, int start, char unexpected) {
+		return new IllegalArgumentException("Unexpected '" + unexpected + "' in \"" + String.valueOf(string) + "\" starting at " + start); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
 	private static int scanGenericEnd(char[] string, int start) {