Bug 578490 - NPE in CPListElement.toString()

Avoid throwing a NPE in CPListElement.toString() if the classpath entry
could not be created (e.g. due to entry kind set to -1).

Change-Id: Ie6092f5dde61122bfd264de98c7486bec17b7b20
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/190208
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
index 263a966..e539ffa 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
@@ -632,7 +632,11 @@
 
 	@Override
 	public String toString() {
-		return getClasspathEntry().toString();
+		IClasspathEntry classpathEntry= getClasspathEntry();
+		if (classpathEntry != null) {
+			return classpathEntry.toString();
+		}
+		return "null"; //$NON-NLS-1$
 	}
 
 	/**