langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
changeset 42258 a1aafd5ea6ec
parent 41865 3ef02797070d
child 42261 bb52b5514ad5
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Jul 05 22:27:20 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Nov 16 17:48:43 2016 +0100
@@ -1341,9 +1341,9 @@
                                 .collect(joining(" & "));
             }
             case FIELD:
-                return elementHeader(at, el.getEnclosingElement(), includeParameterNames, false) + "." + el.getSimpleName() + ":" + el.asType();
+                return appendDot(elementHeader(at, el.getEnclosingElement(), includeParameterNames, false)) + el.getSimpleName() + ":" + el.asType();
             case ENUM_CONSTANT:
-                return elementHeader(at, el.getEnclosingElement(), includeParameterNames, false) + "." + el.getSimpleName();
+                return appendDot(elementHeader(at, el.getEnclosingElement(), includeParameterNames, false)) + el.getSimpleName();
             case EXCEPTION_PARAMETER: case LOCAL_VARIABLE: case PARAMETER: case RESOURCE_VARIABLE:
                 return el.getSimpleName() + ":" + el.asType();
             case CONSTRUCTOR: case METHOD: {
@@ -1407,6 +1407,9 @@
                 return el.toString();
         }
     }
+    private String appendDot(String fqn) {
+        return fqn.isEmpty() ? fqn : fqn + ".";
+    }
     private TypeMirror unwrapArrayType(TypeMirror arrayType) {
         if (arrayType.getKind() == TypeKind.ARRAY) {
             return ((ArrayType)arrayType).getComponentType();