diff -r 41fe3e16698a -r 9d5584396849 langtools/test/tools/javac/diags/Example.java --- a/langtools/test/tools/javac/diags/Example.java Wed Aug 31 16:15:19 2011 +0100 +++ b/langtools/test/tools/javac/diags/Example.java Wed Aug 31 15:39:00 2011 -0700 @@ -21,10 +21,12 @@ * questions. */ -import com.sun.tools.javac.file.JavacFileManager; import java.io.*; +import java.net.URL; +import java.net.URLClassLoader; import java.util.*; import java.util.regex.*; +import javax.annotation.processing.Processor; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; @@ -37,12 +39,11 @@ // import com.sun.tools.javac.Main // import com.sun.tools.javac.main.Main +import com.sun.tools.javac.api.ClientCodeWrapper; +import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.JCDiagnostic; -import java.net.URL; -import java.net.URLClassLoader; -import javax.annotation.processing.Processor; /** * Class to handle example code designed to illustrate javac diagnostic messages. @@ -397,7 +398,7 @@ if (keys != null) { for (Diagnostic d: dc.getDiagnostics()) { - scanForKeys((JCDiagnostic) d, keys); + scanForKeys(unwrap(d), keys); } } @@ -418,6 +419,14 @@ for (JCDiagnostic sd: d.getSubdiagnostics()) scanForKeys(sd, keys); } + + private JCDiagnostic unwrap(Diagnostic diagnostic) { + if (diagnostic instanceof JCDiagnostic) + return (JCDiagnostic) diagnostic; + if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper) + return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d; + throw new IllegalArgumentException(); + } } /**