src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java
changeset 48054 702043a4cdeb
parent 47216 71c04702a3d5
child 49822 53aae0c219e6
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Mon Dec 04 10:13:58 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Mon Dec 04 17:54:49 2017 +0000
@@ -426,7 +426,7 @@
     /** A set of "not-supported-in-source-X" errors produced so far. This is used to only generate
      *  one such error per file.
      */
-    protected Set<Pair<JavaFileObject, String>>  recordedSourceLevelErrors = new HashSet<>();
+    protected Set<Pair<JavaFileObject, List<String>>>  recordedSourceLevelErrors = new HashSet<>();
 
     public boolean hasDiagnosticListener() {
         return diagListener != null;
@@ -521,13 +521,29 @@
         if (!d.isFlagSet(DiagnosticFlag.SOURCE_LEVEL))
             return true;
 
-        Pair<JavaFileObject, String> coords = new Pair<>(file, d.getCode());
+        Pair<JavaFileObject, List<String>> coords = new Pair<>(file, getCode(d));
         boolean shouldReport = !recordedSourceLevelErrors.contains(coords);
         if (shouldReport)
             recordedSourceLevelErrors.add(coords);
         return shouldReport;
     }
 
+    //where
+        private List<String> getCode(JCDiagnostic d) {
+            ListBuffer<String> buf = new ListBuffer<>();
+            getCodeRecursive(buf, d);
+            return buf.toList();
+        }
+
+        private void getCodeRecursive(ListBuffer<String> buf, JCDiagnostic d) {
+            buf.add(d.getCode());
+            for (Object o : d.getArgs()) {
+                if (o instanceof JCDiagnostic) {
+                    getCodeRecursive(buf, (JCDiagnostic)o);
+                }
+            }
+        }
+
     /** Prompt user after an error.
      */
     public void prompt() {