1.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java Fri Jan 16 14:05:55 2009 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java Mon Jan 19 19:36:14 2009 -0800 1.3 @@ -26,6 +26,7 @@ 1.4 package com.sun.tools.javac.util; 1.5 1.6 import java.io.*; 1.7 +import java.util.Arrays; 1.8 import java.util.HashSet; 1.9 import java.util.Map; 1.10 import java.util.Set; 1.11 @@ -97,6 +98,11 @@ 1.12 private DiagnosticFormatter<JCDiagnostic> diagFormatter; 1.13 1.14 /** 1.15 + * Keys for expected diagnostics 1.16 + */ 1.17 + public Set<String> expectDiagKeys; 1.18 + 1.19 + /** 1.20 * JavacMessages object used for localization 1.21 */ 1.22 private JavacMessages messages; 1.23 @@ -123,9 +129,13 @@ 1.24 this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) : 1.25 new BasicDiagnosticFormatter(options, messages); 1.26 @SuppressWarnings("unchecked") // FIXME 1.27 - DiagnosticListener<? super JavaFileObject> diagListener = 1.28 + DiagnosticListener<? super JavaFileObject> dl = 1.29 context.get(DiagnosticListener.class); 1.30 - this.diagListener = diagListener; 1.31 + this.diagListener = dl; 1.32 + 1.33 + String ek = options.get("expectKeys"); 1.34 + if (ek != null) 1.35 + expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *"))); 1.36 } 1.37 // where 1.38 private int getIntOption(Options options, String optionName, int defaultValue) { 1.39 @@ -291,6 +301,9 @@ 1.40 * reported so far, the diagnostic may be handed off to writeDiagnostic. 1.41 */ 1.42 public void report(JCDiagnostic diagnostic) { 1.43 + if (expectDiagKeys != null) 1.44 + expectDiagKeys.remove(diagnostic.getCode()); 1.45 + 1.46 switch (diagnostic.getType()) { 1.47 case FRAGMENT: 1.48 throw new IllegalArgumentException();