Fixed a NPE in getName().

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@993264 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
index 9e1966b..a8da931 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
@@ -1046,9 +1046,10 @@
     }
 
     public String getName() {
-        if (m_serviceName instanceof String[]) {
+        Object serviceName = m_serviceName;
+        if (serviceName instanceof String[]) {
             StringBuffer sb = new StringBuffer();
-            String[] names = (String[]) m_serviceName;
+            String[] names = (String[]) serviceName;
             for (int i = 0; i < names.length; i++) {
                 if (i > 0) {
                     sb.append(", ");
@@ -1057,11 +1058,17 @@
             }
             return sb.toString();
         }
-        else if (m_serviceName instanceof String) {
-            return m_serviceName.toString();
+        else if (serviceName instanceof String) {
+            return serviceName.toString();
         }
         else {
-            return m_implementation.toString();
+            Object implementation = m_implementation;
+            if (implementation != null) {
+                return implementation.toString();
+            }
+            else {
+                return super.toString();
+            }
         }
     }