Fri, 13 Feb 2009 11:57:33 +0000
6769027: Source line should be displayed immediately after the first diagnostic line
Summary: Added support for customizing diagnostic output via API/command line flags
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java Fri Feb 06 17:24:04 2009 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java Fri Feb 13 11:57:33 2009 +0000 1.3 @@ -25,16 +25,18 @@ 1.4 package com.sun.tools.javac.api; 1.5 1.6 import java.util.Locale; 1.7 +import java.util.Set; 1.8 import javax.tools.Diagnostic; 1.9 +import com.sun.tools.javac.api.DiagnosticFormatter.*; 1.10 1.11 /** 1.12 - * Provides simple functionalities for javac diagnostic formatting 1.13 + * Provides simple functionalities for javac diagnostic formatting. 1.14 * @param <D> type of diagnostic handled by this formatter 1.15 */ 1.16 public interface DiagnosticFormatter<D extends Diagnostic<?>> { 1.17 1.18 /** 1.19 - * Whether the source code output for this diagnostic is to be displayed 1.20 + * Whether the source code output for this diagnostic is to be displayed. 1.21 * 1.22 * @param diag diagnostic to be formatted 1.23 * @return true if the source line this diagnostic refers to is to be displayed 1.24 @@ -42,7 +44,7 @@ 1.25 boolean displaySource(D diag); 1.26 1.27 /** 1.28 - * Format the contents of a diagnostics 1.29 + * Format the contents of a diagnostics. 1.30 * 1.31 * @param diag the diagnostic to be formatted 1.32 * @param l locale object to be used for i18n 1.33 @@ -115,4 +117,97 @@ 1.34 */ 1.35 OFFSET 1.36 } 1.37 + 1.38 + /** 1.39 + * Get a list of all the enabled verbosity options. 1.40 + * @return verbosity options 1.41 + */ 1.42 + public Configuration getConfiguration(); 1.43 + //where 1.44 + 1.45 + /** 1.46 + * This interface provides functionalities for tuning the output of a 1.47 + * diagnostic formatter in multiple ways. 1.48 + */ 1.49 + interface Configuration { 1.50 + /** 1.51 + * Configure the set of diagnostic parts that should be displayed 1.52 + * by the formatter. 1.53 + * @param options options to set 1.54 + */ 1.55 + public void setVisible(Set<DiagnosticPart> visibleParts); 1.56 + 1.57 + /** 1.58 + * Retrieve the set of diagnostic parts that should be displayed 1.59 + * by the formatter. 1.60 + * @return verbosity options 1.61 + */ 1.62 + public Set<DiagnosticPart> getVisible(); 1.63 + 1.64 + //where 1.65 + /** 1.66 + * A given diagnostic message can be divided into sub-parts each of which 1.67 + * might/might not be displayed by the formatter, according to the 1.68 + * current configuration settings. 1.69 + */ 1.70 + public enum DiagnosticPart { 1.71 + /** 1.72 + * Short description of the diagnostic - usually one line long. 1.73 + */ 1.74 + SUMMARY, 1.75 + /** 1.76 + * Longer description that provides additional details w.r.t. the ones 1.77 + * in the diagnostic's description. 1.78 + */ 1.79 + DETAILS, 1.80 + /** 1.81 + * Source line the diagnostic refers to (if applicable). 1.82 + */ 1.83 + SOURCE, 1.84 + /** 1.85 + * Subdiagnostics attached to a given multiline diagnostic. 1.86 + */ 1.87 + SUBDIAGNOSTICS, 1.88 + /** 1.89 + * JLS paragraph this diagnostic might refer to (if applicable). 1.90 + */ 1.91 + JLS; 1.92 + } 1.93 + 1.94 + /** 1.95 + * Set a limit for multiline diagnostics. 1.96 + * Note: Setting a limit has no effect if multiline diagnostics are either 1.97 + * fully enabled or disabled. 1.98 + * 1.99 + * @param limit the kind of limit to be set 1.100 + * @param value the limit value 1.101 + */ 1.102 + public void setMultilineLimit(MultilineLimit limit, int value); 1.103 + 1.104 + /** 1.105 + * Get a multiline diagnostic limit. 1.106 + * 1.107 + * @param limit the kind of limit to be retrieved 1.108 + * @return limit value or -1 if no limit is set 1.109 + */ 1.110 + public int getMultilineLimit(MultilineLimit limit); 1.111 + //where 1.112 + /** 1.113 + * A multiline limit control the verbosity of multiline diagnostics 1.114 + * either by setting a maximum depth of nested multidiagnostics, 1.115 + * or by limiting the amount of subdiagnostics attached to a given 1.116 + * diagnostic (or both). 1.117 + */ 1.118 + public enum MultilineLimit { 1.119 + /** 1.120 + * Controls the maximum depth of nested multiline diagnostics. 1.121 + */ 1.122 + DEPTH, 1.123 + /** 1.124 + * Controls the maximum amount of subdiagnostics that are part of a 1.125 + * given multiline diagnostic. 1.126 + */ 1.127 + LENGTH; 1.128 + } 1.129 + } 1.130 }
2.1 --- a/src/share/classes/com/sun/tools/javac/api/Messages.java Fri Feb 06 17:24:04 2009 -0800 2.2 +++ b/src/share/classes/com/sun/tools/javac/api/Messages.java Fri Feb 13 11:57:33 2009 +0000 2.3 @@ -44,7 +44,7 @@ 2.4 void add(String bundleName) throws MissingResourceException; 2.5 2.6 /** 2.7 - * Get a localized formatted string 2.8 + * Get a localized formatted string. 2.9 * @param l locale in which the text is to be localized 2.10 * @param key locale-independent message key 2.11 * @param args misc message arguments
3.1 --- a/src/share/classes/com/sun/tools/javac/main/OptionName.java Fri Feb 06 17:24:04 2009 -0800 3.2 +++ b/src/share/classes/com/sun/tools/javac/main/OptionName.java Fri Feb 13 11:57:33 2009 +0000 3.3 @@ -40,6 +40,7 @@ 3.4 G_CUSTOM("-g:"), 3.5 XLINT("-Xlint"), 3.6 XLINT_CUSTOM("-Xlint:"), 3.7 + DIAGS("-XDdiags="), 3.8 NOWARN("-nowarn"), 3.9 VERBOSE("-verbose"), 3.10 DEPRECATION("-deprecation"),
4.1 --- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java Fri Feb 06 17:24:04 2009 -0800 4.2 +++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java Fri Feb 13 11:57:33 2009 +0000 4.3 @@ -145,6 +145,7 @@ 4.4 TARGET, 4.5 VERSION, 4.6 FULLVERSION, 4.7 + DIAGS, 4.8 HELP, 4.9 A, 4.10 X, 4.11 @@ -372,6 +373,21 @@ 4.12 return super.process(options, option); 4.13 } 4.14 }, 4.15 + new HiddenOption(DIAGS) { 4.16 + @Override 4.17 + public boolean process(Options options, String option) { 4.18 + Option xd = getOptions(helper, EnumSet.of(XD))[0]; 4.19 + option = option.substring(option.indexOf('=') + 1); 4.20 + String diagsOption = option.contains("%") ? 4.21 + "-XDdiagsFormat=" : 4.22 + "-XDdiags="; 4.23 + diagsOption += option; 4.24 + if (xd.matches(diagsOption)) 4.25 + return xd.process(options, diagsOption); 4.26 + else 4.27 + return false; 4.28 + } 4.29 + }, 4.30 new Option(HELP, "opt.help") { 4.31 @Override 4.32 public boolean process(Options options, String option) {
5.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Feb 06 17:24:04 2009 -0800 5.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Feb 13 11:57:33 2009 +0000 5.3 @@ -907,16 +907,16 @@ 5.4 5.5 compiler.err.prob.found.req=\ 5.6 {0}\n\ 5.7 -found : {1}\n\ 5.8 -required: {2} 5.9 +required: {2}\n\ 5.10 +found: {1} 5.11 compiler.warn.prob.found.req=\ 5.12 {0}\n\ 5.13 -found : {1}\n\ 5.14 -required: {2} 5.15 +required: {2}\n\ 5.16 +found: {1} 5.17 compiler.err.prob.found.req.1=\ 5.18 {0} {3}\n\ 5.19 -found : {1}\n\ 5.20 -required: {2} 5.21 +required: {2}\n\ 5.22 +found: {1} 5.23 5.24 ## The following are all possible strings for the first argument ({0}) of the 5.25 ## above strings. 5.26 @@ -951,8 +951,8 @@ 5.27 5.28 compiler.err.type.found.req=\ 5.29 unexpected type\n\ 5.30 -found : {0}\n\ 5.31 -required: {1} 5.32 +required: {1}\n\ 5.33 +found: {0} 5.34 5.35 ## The following are all possible strings for the first argument ({0}) of the 5.36 ## above string. 5.37 @@ -1003,7 +1003,7 @@ 5.38 compiler.err.unexpected.type=\ 5.39 unexpected type\n\ 5.40 required: {0}\n\ 5.41 -found : {1} 5.42 +found: {1} 5.43 5.44 ## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.) 5.45 ## The second argument {1} is the non-resolved symbol 5.46 @@ -1026,17 +1026,17 @@ 5.47 ## The sixth argument {5} is the location type 5.48 compiler.err.cant.resolve.location=\ 5.49 cannot find symbol\n\ 5.50 - symbol : {0} {1}\n\ 5.51 + symbol: {0} {1}\n\ 5.52 location: {4} {5} 5.53 5.54 compiler.err.cant.resolve.location.args=\ 5.55 cannot find symbol\n\ 5.56 - symbol : {0} {1}({3})\n\ 5.57 + symbol: {0} {1}({3})\n\ 5.58 location: {4} {5} 5.59 5.60 compiler.err.cant.resolve.location.args.params=\ 5.61 cannot find symbol\n\ 5.62 - symbol : {0} <{2}>{1}({3})\n\ 5.63 + symbol: {0} <{2}>{1}({3})\n\ 5.64 location: {4} {5} 5.65 5.66 ## The following are all possible string for "kindname".
6.1 --- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Fri Feb 06 17:24:04 2009 -0800 6.2 +++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Fri Feb 13 11:57:33 2009 +0000 6.3 @@ -24,16 +24,23 @@ 6.4 */ 6.5 package com.sun.tools.javac.util; 6.6 6.7 +import java.util.Arrays; 6.8 import java.util.Collection; 6.9 +import java.util.EnumSet; 6.10 +import java.util.HashMap; 6.11 import java.util.Locale; 6.12 +import java.util.Map; 6.13 +import java.util.Set; 6.14 import javax.tools.JavaFileObject; 6.15 6.16 import com.sun.tools.javac.api.DiagnosticFormatter; 6.17 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart; 6.18 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit; 6.19 +import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind; 6.20 import com.sun.tools.javac.api.Formattable; 6.21 -import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind; 6.22 import com.sun.tools.javac.file.JavacFileManager; 6.23 + 6.24 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; 6.25 -import static com.sun.tools.javac.util.LayoutCharacters.*; 6.26 6.27 /** 6.28 * This abstract class provides a basic implementation of the functionalities that should be provided 6.29 @@ -50,35 +57,19 @@ 6.30 public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter<JCDiagnostic> { 6.31 6.32 /** 6.33 - * JavacMessages object used by this formatter for i18n 6.34 + * JavacMessages object used by this formatter for i18n. 6.35 */ 6.36 protected JavacMessages messages; 6.37 - protected boolean showSource; 6.38 + private SimpleConfiguration config; 6.39 + protected int depth = 0; 6.40 6.41 /** 6.42 - * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object 6.43 + * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object. 6.44 * @param messages 6.45 */ 6.46 - protected AbstractDiagnosticFormatter(JavacMessages messages, Options options, boolean showSource) { 6.47 + protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) { 6.48 this.messages = messages; 6.49 - this.showSource = options.get("showSource") == null ? showSource : 6.50 - options.get("showSource").equals("true"); 6.51 - } 6.52 - 6.53 - protected AbstractDiagnosticFormatter(JavacMessages messages, boolean showSource) { 6.54 - this.messages = messages; 6.55 - this.showSource = showSource; 6.56 - } 6.57 - 6.58 - public String formatMessage(JCDiagnostic d, Locale l) { 6.59 - //this code should rely on the locale settings but it's not! See RFE 6443132 6.60 - StringBuilder buf = new StringBuilder(); 6.61 - Collection<String> args = formatArguments(d, l); 6.62 - buf.append(localize(l, d.getCode(), args.toArray())); 6.63 - if (d.isMultiline()) { 6.64 - buf.append(formatSubdiagnostics(d, l)); 6.65 - } 6.66 - return buf.toString(); 6.67 + this.config = config; 6.68 } 6.69 6.70 public String formatKind(JCDiagnostic d, Locale l) { 6.71 @@ -96,8 +87,8 @@ 6.72 assert (d.getPosition() != Position.NOPOS); 6.73 return String.valueOf(getPosition(d, pk)); 6.74 } 6.75 - //WHERE 6.76 - public long getPosition(JCDiagnostic d, PositionKind pk) { 6.77 + //where 6.78 + private long getPosition(JCDiagnostic d, PositionKind pk) { 6.79 switch (pk) { 6.80 case START: return d.getIntStartPosition(); 6.81 case END: return d.getIntEndPosition(); 6.82 @@ -138,8 +129,17 @@ 6.83 * @return string representation of the diagnostic argument 6.84 */ 6.85 protected String formatArgument(JCDiagnostic d, Object arg, Locale l) { 6.86 - if (arg instanceof JCDiagnostic) 6.87 - return format((JCDiagnostic)arg, l); 6.88 + if (arg instanceof JCDiagnostic) { 6.89 + String s = null; 6.90 + depth++; 6.91 + try { 6.92 + s = formatMessage((JCDiagnostic)arg, l); 6.93 + } 6.94 + finally { 6.95 + depth--; 6.96 + } 6.97 + return s; 6.98 + } 6.99 else if (arg instanceof Iterable<?>) { 6.100 return formatIterable(d, (Iterable<?>)arg, l); 6.101 } 6.102 @@ -171,45 +171,74 @@ 6.103 } 6.104 6.105 /** 6.106 - * Format all the subdiagnostics attached to a given diagnostic 6.107 + * Format all the subdiagnostics attached to a given diagnostic. 6.108 * 6.109 * @param d diagnostic whose subdiagnostics are to be formatted 6.110 * @param l locale object to be used for i18n 6.111 + * @return list of all string representations of the subdiagnostics 6.112 + */ 6.113 + protected List<String> formatSubdiagnostics(JCDiagnostic d, Locale l) { 6.114 + List<String> subdiagnostics = List.nil(); 6.115 + int maxDepth = config.getMultilineLimit(MultilineLimit.DEPTH); 6.116 + if (maxDepth == -1 || depth < maxDepth) { 6.117 + depth++; 6.118 + try { 6.119 + int maxCount = config.getMultilineLimit(MultilineLimit.LENGTH); 6.120 + int count = 0; 6.121 + for (JCDiagnostic d2 : d.getSubdiagnostics()) { 6.122 + if (maxCount == -1 || count < maxCount) { 6.123 + subdiagnostics = subdiagnostics.append(formatSubdiagnostic(d, d2, l)); 6.124 + count++; 6.125 + } 6.126 + else 6.127 + break; 6.128 + } 6.129 + } 6.130 + finally { 6.131 + depth--; 6.132 + } 6.133 + } 6.134 + return subdiagnostics; 6.135 + } 6.136 + 6.137 + /** 6.138 + * Format a subdiagnostics attached to a given diagnostic. 6.139 + * 6.140 + * @param parent multiline diagnostic whose subdiagnostics is to be formatted 6.141 + * @param sub subdiagnostic to be formatted 6.142 + * @param l locale object to be used for i18n 6.143 * @return string representation of the subdiagnostics 6.144 */ 6.145 - protected String formatSubdiagnostics(JCDiagnostic d, Locale l) { 6.146 - StringBuilder buf = new StringBuilder(); 6.147 - for (JCDiagnostic d2 : d.getSubdiagnostics()) { 6.148 - buf.append('\n'); 6.149 - String subdiagMsg = format(d2, l); 6.150 - buf.append(indent(subdiagMsg, DiagInc)); 6.151 - } 6.152 - return buf.toString(); 6.153 + protected String formatSubdiagnostic(JCDiagnostic parent, JCDiagnostic sub, Locale l) { 6.154 + return formatMessage(sub, l); 6.155 } 6.156 6.157 /** Format the faulty source code line and point to the error. 6.158 * @param d The diagnostic for which the error line should be printed 6.159 */ 6.160 - protected String formatSourceLine(JCDiagnostic d) { 6.161 + protected String formatSourceLine(JCDiagnostic d, int nSpaces) { 6.162 StringBuilder buf = new StringBuilder(); 6.163 DiagnosticSource source = d.getDiagnosticSource(); 6.164 int pos = d.getIntPosition(); 6.165 - if (d.getIntPosition() != Position.NOPOS) { 6.166 - String line = (source == null ? null : source.getLine(pos)); 6.167 - if (line == null) 6.168 - return ""; 6.169 - buf.append(line+"\n"); 6.170 - int col = source.getColumnNumber(pos, false); 6.171 + if (d.getIntPosition() == Position.NOPOS) 6.172 + throw new AssertionError(); 6.173 + String line = (source == null ? null : source.getLine(pos)); 6.174 + if (line == null) 6.175 + return ""; 6.176 + buf.append(indent(line, nSpaces)); 6.177 + int col = source.getColumnNumber(pos, false); 6.178 + if (config.isCaretEnabled()) { 6.179 + buf.append("\n"); 6.180 for (int i = 0; i < col - 1; i++) { 6.181 buf.append((line.charAt(i) == '\t') ? "\t" : " "); 6.182 } 6.183 - buf.append("^"); 6.184 - } 6.185 - return buf.toString(); 6.186 + buf.append(indent("^", nSpaces)); 6.187 + } 6.188 + return buf.toString(); 6.189 } 6.190 6.191 /** 6.192 - * Converts a String into a locale-dependent representation accordingly to a given locale 6.193 + * Converts a String into a locale-dependent representation accordingly to a given locale. 6.194 * 6.195 * @param l locale object to be used for i18n 6.196 * @param key locale-independent key used for looking up in a resource file 6.197 @@ -221,7 +250,9 @@ 6.198 } 6.199 6.200 public boolean displaySource(JCDiagnostic d) { 6.201 - return showSource && d.getType() != FRAGMENT; 6.202 + return config.getVisible().contains(DiagnosticPart.SOURCE) && 6.203 + d.getType() != FRAGMENT && 6.204 + d.getIntPosition() != Position.NOPOS; 6.205 } 6.206 6.207 /** 6.208 @@ -245,7 +276,7 @@ 6.209 6.210 /** 6.211 * Indent a string by prepending a given amount of empty spaces to each line 6.212 - * of the string 6.213 + * of the string. 6.214 * 6.215 * @param s the string to be indented 6.216 * @param nSpaces the amount of spaces that should be prepended to each line 6.217 @@ -263,4 +294,114 @@ 6.218 } 6.219 return buf.toString(); 6.220 } 6.221 + 6.222 + public SimpleConfiguration getConfiguration() { 6.223 + return config; 6.224 + } 6.225 + 6.226 + static public class SimpleConfiguration implements Configuration { 6.227 + 6.228 + protected Map<MultilineLimit, Integer> multilineLimits; 6.229 + protected EnumSet<DiagnosticPart> visibleParts; 6.230 + protected boolean caretEnabled; 6.231 + 6.232 + public SimpleConfiguration(Set<DiagnosticPart> parts) { 6.233 + multilineLimits = new HashMap<MultilineLimit, Integer>(); 6.234 + setVisible(parts); 6.235 + setMultilineLimit(MultilineLimit.DEPTH, -1); 6.236 + setMultilineLimit(MultilineLimit.LENGTH, -1); 6.237 + setCaretEnabled(true); 6.238 + } 6.239 + 6.240 + @SuppressWarnings("fallthrough") 6.241 + public SimpleConfiguration(Options options, Set<DiagnosticPart> parts) { 6.242 + this(parts); 6.243 + String showSource = null; 6.244 + if ((showSource = options.get("showSource")) != null) { 6.245 + if (showSource.equals("true")) 6.246 + visibleParts.add(DiagnosticPart.SOURCE); 6.247 + else if (showSource.equals("false")) 6.248 + visibleParts.remove(DiagnosticPart.SOURCE); 6.249 + } 6.250 + String diagOpts = options.get("diags"); 6.251 + if (diagOpts != null) {//override -XDshowSource 6.252 + Collection<String> args = Arrays.asList(diagOpts.split(",")); 6.253 + if (args.contains("short")) { 6.254 + visibleParts.remove(DiagnosticPart.DETAILS); 6.255 + visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS); 6.256 + } 6.257 + if (args.contains("source")) 6.258 + visibleParts.add(DiagnosticPart.SOURCE); 6.259 + if (args.contains("-source")) 6.260 + visibleParts.remove(DiagnosticPart.SOURCE); 6.261 + } 6.262 + String multiPolicy = null; 6.263 + if ((multiPolicy = options.get("multilinePolicy")) != null) { 6.264 + if (multiPolicy.equals("disabled")) 6.265 + visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS); 6.266 + else if (multiPolicy.startsWith("limit:")) { 6.267 + String limitString = multiPolicy.substring("limit:".length()); 6.268 + String[] limits = limitString.split(":"); 6.269 + try { 6.270 + switch (limits.length) { 6.271 + case 2: { 6.272 + if (!limits[1].equals("*")) 6.273 + setMultilineLimit(MultilineLimit.DEPTH, Integer.parseInt(limits[1])); 6.274 + } 6.275 + case 1: { 6.276 + if (!limits[0].equals("*")) 6.277 + setMultilineLimit(MultilineLimit.LENGTH, Integer.parseInt(limits[0])); 6.278 + } 6.279 + } 6.280 + } 6.281 + catch(NumberFormatException ex) { 6.282 + setMultilineLimit(MultilineLimit.DEPTH, -1); 6.283 + setMultilineLimit(MultilineLimit.LENGTH, -1); 6.284 + } 6.285 + } 6.286 + } 6.287 + String showCaret = null; 6.288 + if (((showCaret = options.get("showCaret")) != null) && 6.289 + showCaret.equals("false")) 6.290 + setCaretEnabled(false); 6.291 + else 6.292 + setCaretEnabled(true); 6.293 + } 6.294 + 6.295 + public int getMultilineLimit(MultilineLimit limit) { 6.296 + return multilineLimits.get(limit); 6.297 + } 6.298 + 6.299 + public EnumSet<DiagnosticPart> getVisible() { 6.300 + return EnumSet.copyOf(visibleParts); 6.301 + } 6.302 + 6.303 + public void setMultilineLimit(MultilineLimit limit, int value) { 6.304 + multilineLimits.put(limit, value < -1 ? -1 : value); 6.305 + } 6.306 + 6.307 + 6.308 + public void setVisible(Set<DiagnosticPart> diagParts) { 6.309 + visibleParts = EnumSet.copyOf(diagParts); 6.310 + } 6.311 + 6.312 + /** 6.313 + * Shows a '^' sign under the source line displayed by the formatter 6.314 + * (if applicable). 6.315 + * 6.316 + * @param caretEnabled if true enables caret 6.317 + */ 6.318 + public void setCaretEnabled(boolean caretEnabled) { 6.319 + this.caretEnabled = caretEnabled; 6.320 + } 6.321 + 6.322 + /** 6.323 + * Tells whether the caret display is active or not. 6.324 + * 6.325 + * @param caretEnabled if true the caret is enabled 6.326 + */ 6.327 + public boolean isCaretEnabled() { 6.328 + return caretEnabled; 6.329 + } 6.330 + } 6.331 }
7.1 --- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Fri Feb 06 17:24:04 2009 -0800 7.2 +++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Fri Feb 13 11:57:33 2009 +0000 7.3 @@ -25,13 +25,20 @@ 7.4 7.5 package com.sun.tools.javac.util; 7.6 7.7 +import java.util.Collection; 7.8 +import java.util.EnumSet; 7.9 import java.util.HashMap; 7.10 import java.util.Locale; 7.11 import java.util.Map; 7.12 +import java.util.regex.Matcher; 7.13 import javax.tools.JavaFileObject; 7.14 7.15 -import static com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicFormatKind.*; 7.16 +import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration; 7.17 +import com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicConfiguration; 7.18 + 7.19 import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*; 7.20 +import static com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicConfiguration.*; 7.21 +import static com.sun.tools.javac.util.LayoutCharacters.*; 7.22 7.23 /** 7.24 * A basic formatter for diagnostic messages. 7.25 @@ -53,7 +60,7 @@ 7.26 */ 7.27 public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter { 7.28 7.29 - protected Map<BasicFormatKind, String> availableFormats; 7.30 + protected int currentIndentation = 0; 7.31 7.32 /** 7.33 * Create a basic formatter based on the supplied options. 7.34 @@ -62,21 +69,8 @@ 7.35 * @param msgs JavacMessages object used for i18n 7.36 */ 7.37 @SuppressWarnings("fallthrough") 7.38 - BasicDiagnosticFormatter(Options opts, JavacMessages msgs) { 7.39 - super(msgs, opts, true); 7.40 - initAvailableFormats(); 7.41 - String fmt = opts.get("diags"); 7.42 - if (fmt != null) { 7.43 - String[] formats = fmt.split("\\|"); 7.44 - switch (formats.length) { 7.45 - case 3: 7.46 - availableFormats.put(DEFAULT_CLASS_FORMAT, formats[2]); 7.47 - case 2: 7.48 - availableFormats.put(DEFAULT_NO_POS_FORMAT, formats[1]); 7.49 - default: 7.50 - availableFormats.put(DEFAULT_POS_FORMAT, formats[0]); 7.51 - } 7.52 - } 7.53 + public BasicDiagnosticFormatter(Options options, JavacMessages msgs) { 7.54 + super(msgs, new BasicConfiguration(options)); 7.55 } 7.56 7.57 /** 7.58 @@ -85,15 +79,7 @@ 7.59 * @param msgs JavacMessages object used for i18n 7.60 */ 7.61 public BasicDiagnosticFormatter(JavacMessages msgs) { 7.62 - super(msgs, true); 7.63 - initAvailableFormats(); 7.64 - } 7.65 - 7.66 - public void initAvailableFormats() { 7.67 - availableFormats = new HashMap<BasicFormatKind, String>(); 7.68 - availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m"); 7.69 - availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m"); 7.70 - availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m"); 7.71 + super(msgs, new BasicConfiguration()); 7.72 } 7.73 7.74 public String format(JCDiagnostic d, Locale l) { 7.75 @@ -110,10 +96,55 @@ 7.76 } 7.77 buf.append(meta ? formatMeta(c, d, l) : String.valueOf(c)); 7.78 } 7.79 - if (displaySource(d)) { 7.80 - buf.append("\n" + formatSourceLine(d)); 7.81 + if (depth == 0) 7.82 + return addSourceLineIfNeeded(d, buf.toString()); 7.83 + else 7.84 + return buf.toString(); 7.85 + } 7.86 + 7.87 + public String formatMessage(JCDiagnostic d, Locale l) { 7.88 + int prevIndentation = currentIndentation; 7.89 + try { 7.90 + StringBuilder buf = new StringBuilder(); 7.91 + Collection<String> args = formatArguments(d, l); 7.92 + String msg = localize(l, d.getCode(), args.toArray()); 7.93 + String[] lines = msg.split("\n"); 7.94 + if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { 7.95 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); 7.96 + buf.append(indent(lines[0], currentIndentation)); //summary 7.97 + } 7.98 + if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { 7.99 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); 7.100 + for (int i = 1;i < lines.length; i++) { 7.101 + buf.append("\n" + indent(lines[i], currentIndentation)); 7.102 + } 7.103 + } 7.104 + if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { 7.105 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); 7.106 + for (String sub : formatSubdiagnostics(d, l)) { 7.107 + buf.append("\n" + sub); 7.108 + } 7.109 + } 7.110 + return buf.toString(); 7.111 } 7.112 - return buf.toString(); 7.113 + finally { 7.114 + currentIndentation = prevIndentation; 7.115 + } 7.116 + } 7.117 + 7.118 + protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) { 7.119 + if (!displaySource(d)) 7.120 + return msg; 7.121 + else { 7.122 + BasicConfiguration conf = getConfiguration(); 7.123 + int indentSource = conf.getIndentation(DiagnosticPart.SOURCE); 7.124 + String sourceLine = "\n" + formatSourceLine(d, indentSource); 7.125 + boolean singleLine = msg.indexOf("\n") == -1; 7.126 + if (singleLine || getConfiguration().getSourcePosition() == SourcePosition.BOTTOM) 7.127 + return msg + sourceLine; 7.128 + else 7.129 + return msg.replaceFirst("\n", Matcher.quoteReplacement(sourceLine) + "\n"); 7.130 + } 7.131 } 7.132 7.133 protected String formatMeta(char c, JCDiagnostic d, Locale l) { 7.134 @@ -164,34 +195,199 @@ 7.135 7.136 private String selectFormat(JCDiagnostic d) { 7.137 DiagnosticSource source = d.getDiagnosticSource(); 7.138 - String format = availableFormats.get(DEFAULT_NO_POS_FORMAT); 7.139 + String format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT); 7.140 if (source != null) { 7.141 if (d.getIntPosition() != Position.NOPOS) { 7.142 - format = availableFormats.get(DEFAULT_POS_FORMAT); 7.143 + format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_POS_FORMAT); 7.144 } else if (source.getFile() != null && 7.145 source.getFile().getKind() == JavaFileObject.Kind.CLASS) { 7.146 - format = availableFormats.get(DEFAULT_CLASS_FORMAT); 7.147 + format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT); 7.148 } 7.149 } 7.150 return format; 7.151 } 7.152 7.153 - /** 7.154 - * This enum contains all the kinds of formatting patterns supported 7.155 - * by a basic diagnostic formatter. 7.156 - */ 7.157 - public enum BasicFormatKind { 7.158 + @Override 7.159 + public BasicConfiguration getConfiguration() { 7.160 + return (BasicConfiguration)super.getConfiguration(); 7.161 + } 7.162 + 7.163 + static public class BasicConfiguration extends SimpleConfiguration { 7.164 + 7.165 + protected Map<DiagnosticPart, Integer> indentationLevels; 7.166 + protected Map<BasicFormatKind, String> availableFormats; 7.167 + protected SourcePosition sourcePosition; 7.168 + 7.169 + @SuppressWarnings("fallthrough") 7.170 + public BasicConfiguration(Options options) { 7.171 + super(options, EnumSet.of(DiagnosticPart.SUMMARY, 7.172 + DiagnosticPart.DETAILS, 7.173 + DiagnosticPart.SUBDIAGNOSTICS, 7.174 + DiagnosticPart.SOURCE)); 7.175 + initFormat(); 7.176 + initIndentation(); 7.177 + String fmt = options.get("diagsFormat"); 7.178 + if (fmt != null) { 7.179 + String[] formats = fmt.split("\\|"); 7.180 + switch (formats.length) { 7.181 + case 3: 7.182 + setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]); 7.183 + case 2: 7.184 + setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]); 7.185 + default: 7.186 + setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]); 7.187 + } 7.188 + } 7.189 + String sourcePosition = null; 7.190 + if ((((sourcePosition = options.get("sourcePosition")) != null)) && 7.191 + sourcePosition.equals("bottom")) 7.192 + setSourcePosition(SourcePosition.BOTTOM); 7.193 + else 7.194 + setSourcePosition(SourcePosition.AFTER_SUMMARY); 7.195 + String indent = options.get("diagsIndentation"); 7.196 + if (indent != null) { 7.197 + String[] levels = indent.split("\\|"); 7.198 + try { 7.199 + switch (levels.length) { 7.200 + case 5: 7.201 + setIndentation(DiagnosticPart.JLS, 7.202 + Integer.parseInt(levels[4])); 7.203 + case 4: 7.204 + setIndentation(DiagnosticPart.SUBDIAGNOSTICS, 7.205 + Integer.parseInt(levels[3])); 7.206 + case 3: 7.207 + setIndentation(DiagnosticPart.SOURCE, 7.208 + Integer.parseInt(levels[2])); 7.209 + case 2: 7.210 + setIndentation(DiagnosticPart.DETAILS, 7.211 + Integer.parseInt(levels[1])); 7.212 + default: 7.213 + setIndentation(DiagnosticPart.SUMMARY, 7.214 + Integer.parseInt(levels[0])); 7.215 + } 7.216 + } 7.217 + catch (NumberFormatException ex) { 7.218 + initIndentation(); 7.219 + } 7.220 + } 7.221 + } 7.222 + 7.223 + public BasicConfiguration() { 7.224 + super(EnumSet.of(DiagnosticPart.SUMMARY, 7.225 + DiagnosticPart.DETAILS, 7.226 + DiagnosticPart.SUBDIAGNOSTICS, 7.227 + DiagnosticPart.SOURCE)); 7.228 + initFormat(); 7.229 + initIndentation(); 7.230 + } 7.231 + //where 7.232 + private void initFormat() { 7.233 + availableFormats = new HashMap<BasicFormatKind, String>(); 7.234 + setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%m"); 7.235 + setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%m"); 7.236 + setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%m"); 7.237 + } 7.238 + //where 7.239 + private void initIndentation() { 7.240 + indentationLevels = new HashMap<DiagnosticPart, Integer>(); 7.241 + setIndentation(DiagnosticPart.SUMMARY, 0); 7.242 + setIndentation(DiagnosticPart.DETAILS, DetailsInc); 7.243 + setIndentation(DiagnosticPart.SUBDIAGNOSTICS, DiagInc); 7.244 + setIndentation(DiagnosticPart.SOURCE, 0); 7.245 + } 7.246 + 7.247 /** 7.248 - * A format string to be used for diagnostics with a given position. 7.249 - */ 7.250 - DEFAULT_POS_FORMAT, 7.251 + * Get the amount of spaces for a given indentation kind 7.252 + * @param diagPart the diagnostic part for which the indentation is 7.253 + * to be retrieved 7.254 + * @return the amount of spaces used for the specified indentation kind 7.255 + */ 7.256 + public int getIndentation(DiagnosticPart diagPart) { 7.257 + return indentationLevels.get(diagPart); 7.258 + } 7.259 + 7.260 /** 7.261 - * A format string to be used for diagnostics without a given position. 7.262 - */ 7.263 - DEFAULT_NO_POS_FORMAT, 7.264 + * Set the indentation level for various element of a given diagnostic - 7.265 + * this might lead to more readable diagnostics 7.266 + * 7.267 + * @param indentationKind kind of indentation to be set 7.268 + * @param nSpaces amount of spaces for the specified diagnostic part 7.269 + */ 7.270 + public void setIndentation(DiagnosticPart diagPart, int nSpaces) { 7.271 + indentationLevels.put(diagPart, nSpaces); 7.272 + } 7.273 + 7.274 /** 7.275 - * A format string to be used for diagnostics regarding classfiles 7.276 - */ 7.277 - DEFAULT_CLASS_FORMAT; 7.278 + * Set the source line positioning used by this formatter 7.279 + * 7.280 + * @param sourcePos a positioning value for source line 7.281 + */ 7.282 + public void setSourcePosition(SourcePosition sourcePos) { 7.283 + sourcePosition = sourcePos; 7.284 + } 7.285 + 7.286 + /** 7.287 + * Get the source line positioning used by this formatter 7.288 + * 7.289 + * @return the positioning value used by this formatter 7.290 + */ 7.291 + public SourcePosition getSourcePosition() { 7.292 + return sourcePosition; 7.293 + } 7.294 + //where 7.295 + /** 7.296 + * A source positioning value controls the position (within a given 7.297 + * diagnostic message) in which the source line the diagnostic refers to 7.298 + * should be displayed (if applicable) 7.299 + */ 7.300 + public enum SourcePosition { 7.301 + /** 7.302 + * Source line is displayed after the diagnostic message 7.303 + */ 7.304 + BOTTOM, 7.305 + /** 7.306 + * Source line is displayed after the first line of the diagnostic 7.307 + * message 7.308 + */ 7.309 + AFTER_SUMMARY; 7.310 + } 7.311 + 7.312 + /** 7.313 + * Set a metachar string for a specific format 7.314 + * 7.315 + * @param kind the format kind to be set 7.316 + * @param s the metachar string specifying the format 7.317 + */ 7.318 + public void setFormat(BasicFormatKind kind, String s) { 7.319 + availableFormats.put(kind, s); 7.320 + } 7.321 + 7.322 + /** 7.323 + * Get a metachar string for a specific format 7.324 + * 7.325 + * @param sourcePos a positioning value for source line 7.326 + */ 7.327 + public String getFormat(BasicFormatKind kind) { 7.328 + return availableFormats.get(kind); 7.329 + } 7.330 + //where 7.331 + /** 7.332 + * This enum contains all the kinds of formatting patterns supported 7.333 + * by a basic diagnostic formatter. 7.334 + */ 7.335 + public enum BasicFormatKind { 7.336 + /** 7.337 + * A format string to be used for diagnostics with a given position. 7.338 + */ 7.339 + DEFAULT_POS_FORMAT, 7.340 + /** 7.341 + * A format string to be used for diagnostics without a given position. 7.342 + */ 7.343 + DEFAULT_NO_POS_FORMAT, 7.344 + /** 7.345 + * A format string to be used for diagnostics regarding classfiles 7.346 + */ 7.347 + DEFAULT_CLASS_FORMAT; 7.348 + } 7.349 } 7.350 }
8.1 --- a/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java Fri Feb 06 17:24:04 2009 -0800 8.2 +++ b/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java Fri Feb 13 11:57:33 2009 +0000 8.3 @@ -39,9 +39,13 @@ 8.4 */ 8.5 final static int TabInc = 8; 8.6 8.7 - /** Diagnostic standard indentation 8.8 + /** Standard indentation for subdiagnostics 8.9 */ 8.10 - final static int DiagInc = 2; 8.11 + final static int DiagInc = 4; 8.12 + 8.13 + /** Standard indentation for additional diagnostic lines 8.14 + */ 8.15 + final static int DetailsInc = 2; 8.16 8.17 /** Tabulator character. 8.18 */
9.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java Fri Feb 06 17:24:04 2009 -0800 9.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java Fri Feb 13 11:57:33 2009 +0000 9.3 @@ -93,17 +93,17 @@ 9.4 protected DiagnosticListener<? super JavaFileObject> diagListener; 9.5 9.6 /** 9.7 - * Formatter for diagnostics 9.8 + * Formatter for diagnostics. 9.9 */ 9.10 private DiagnosticFormatter<JCDiagnostic> diagFormatter; 9.11 9.12 /** 9.13 - * Keys for expected diagnostics 9.14 + * Keys for expected diagnostics. 9.15 */ 9.16 public Set<String> expectDiagKeys; 9.17 9.18 /** 9.19 - * JavacMessages object used for localization 9.20 + * JavacMessages object used for localization. 9.21 */ 9.22 private JavacMessages messages; 9.23 9.24 @@ -206,6 +206,18 @@ 9.25 return source == null ? null : source.getFile(); 9.26 } 9.27 9.28 + /** Get the current diagnostic formatter. 9.29 + */ 9.30 + public DiagnosticFormatter<JCDiagnostic> getDiagnosticFormatter() { 9.31 + return diagFormatter; 9.32 + } 9.33 + 9.34 + /** Set the current diagnostic formatter. 9.35 + */ 9.36 + public void setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter) { 9.37 + this.diagFormatter = diagFormatter; 9.38 + } 9.39 + 9.40 /** Flush the logs 9.41 */ 9.42 public void flush() {
10.1 --- a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java Fri Feb 06 17:24:04 2009 -0800 10.2 +++ b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java Fri Feb 13 11:57:33 2009 +0000 10.3 @@ -24,9 +24,14 @@ 10.4 */ 10.5 package com.sun.tools.javac.util; 10.6 10.7 +import java.util.Collection; 10.8 +import java.util.EnumSet; 10.9 import java.util.Locale; 10.10 10.11 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.*; 10.12 import com.sun.tools.javac.api.Formattable; 10.13 +import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration; 10.14 + 10.15 import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*; 10.16 10.17 /** 10.18 @@ -35,14 +40,17 @@ 10.19 * or not the source name and position are set. This formatter provides a standardized, localize-independent 10.20 * implementation of a diagnostic formatter; as such, this formatter is best suited for testing purposes. 10.21 */ 10.22 -public class RawDiagnosticFormatter extends AbstractDiagnosticFormatter { 10.23 +public final class RawDiagnosticFormatter extends AbstractDiagnosticFormatter { 10.24 10.25 /** 10.26 * Create a formatter based on the supplied options. 10.27 * @param msgs 10.28 */ 10.29 - public RawDiagnosticFormatter(Options opts) { 10.30 - super(null, opts, false); 10.31 + public RawDiagnosticFormatter(Options options) { 10.32 + super(null, new SimpleConfiguration(options, 10.33 + EnumSet.of(DiagnosticPart.SUMMARY, 10.34 + DiagnosticPart.DETAILS, 10.35 + DiagnosticPart.SUBDIAGNOSTICS))); 10.36 } 10.37 10.38 //provide common default formats 10.39 @@ -62,7 +70,7 @@ 10.40 buf.append(' '); 10.41 buf.append(formatMessage(d, null)); 10.42 if (displaySource(d)) 10.43 - buf.append("\n" + formatSourceLine(d)); 10.44 + buf.append("\n" + formatSourceLine(d, 0)); 10.45 return buf.toString(); 10.46 } 10.47 catch (Exception e) { 10.48 @@ -71,6 +79,32 @@ 10.49 } 10.50 } 10.51 10.52 + public String formatMessage(JCDiagnostic d, Locale l) { 10.53 + StringBuilder buf = new StringBuilder(); 10.54 + Collection<String> args = formatArguments(d, l); 10.55 + buf.append(d.getCode()); 10.56 + String sep = ": "; 10.57 + for (Object o : args) { 10.58 + buf.append(sep); 10.59 + buf.append(o); 10.60 + sep = ", "; 10.61 + } 10.62 + if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { 10.63 + List<String> subDiags = formatSubdiagnostics(d, null); 10.64 + if (subDiags.nonEmpty()) { 10.65 + sep = ""; 10.66 + buf.append(",{"); 10.67 + for (String sub : formatSubdiagnostics(d, null)) { 10.68 + buf.append(sep); 10.69 + buf.append("(" + sub + ")"); 10.70 + sep = ","; 10.71 + } 10.72 + buf.append('}'); 10.73 + } 10.74 + } 10.75 + return buf.toString(); 10.76 + } 10.77 + 10.78 @Override 10.79 protected String formatArgument(JCDiagnostic diag, Object arg, Locale l) { 10.80 String s; 10.81 @@ -83,31 +117,4 @@ 10.82 else 10.83 return s; 10.84 } 10.85 - 10.86 - @Override 10.87 - protected String formatSubdiagnostics(JCDiagnostic d, Locale l) { 10.88 - StringBuilder buf = new StringBuilder(); 10.89 - String sep = ""; 10.90 - buf.append(",{"); 10.91 - for (JCDiagnostic d2 : d.getSubdiagnostics()) { 10.92 - buf.append(sep); 10.93 - buf.append("(" + format(d2, l) + ")"); 10.94 - sep = ","; 10.95 - } 10.96 - buf.append('}'); 10.97 - return buf.toString(); 10.98 - } 10.99 - 10.100 - @Override 10.101 - protected String localize(Locale l, String s, Object... args) { 10.102 - StringBuffer buf = new StringBuffer(); 10.103 - buf.append(s); 10.104 - String sep = ": "; 10.105 - for (Object o : args) { 10.106 - buf.append(sep); 10.107 - buf.append(o); 10.108 - sep = ", "; 10.109 - } 10.110 - return buf.toString(); 10.111 - } 10.112 }
11.1 --- a/test/tools/javac/6304921/T6304921.out Fri Feb 06 17:24:04 2009 -0800 11.2 +++ b/test/tools/javac/6304921/T6304921.out Fri Feb 13 11:57:33 2009 +0000 11.3 @@ -1,18 +1,18 @@ 11.4 T6304921.java:671/671/680: warning: [rawtypes] found raw type: java.util.ArrayList 11.5 -missing type parameters for generic class java.util.ArrayList<E> 11.6 List<Integer> list = new ArrayList(); 11.7 ^ 11.8 + missing type parameters for generic class java.util.ArrayList<E> 11.9 T6304921.java:667/667/682: warning: [unchecked] unchecked conversion 11.10 -found : java.util.ArrayList 11.11 -required: java.util.List<java.lang.Integer> 11.12 List<Integer> list = new ArrayList(); 11.13 ^ 11.14 + required: java.util.List<java.lang.Integer> 11.15 + found: java.util.ArrayList 11.16 error: warnings found and -Werror specified 11.17 T6304921.java:727/733/737: cannot find symbol 11.18 -symbol : variable orr 11.19 -location: class java.lang.System 11.20 System.orr.println("abc"); // name not found 11.21 ^ 11.22 + symbol: variable orr 11.23 + location: class java.lang.System 11.24 T6304921.java:812/816/822: operator + cannot be applied to int,boolean 11.25 return 123 + true; // bad binary expression 11.26 ^
12.1 --- a/test/tools/javac/6668794/badClass/Test.java Fri Feb 06 17:24:04 2009 -0800 12.2 +++ b/test/tools/javac/6668794/badClass/Test.java Fri Feb 13 11:57:33 2009 +0000 12.3 @@ -54,8 +54,8 @@ 12.4 throw new Error("no diagnostics generated"); 12.5 12.6 String expected = "B.java:6:6: compiler.err.cant.access: p.A, " + 12.7 - "(- compiler.misc.bad.class.file.header: A.class, " + 12.8 - "(- compiler.misc.class.file.wrong.class: q.A))"; 12.9 + "(compiler.misc.bad.class.file.header: A.class, " + 12.10 + "(compiler.misc.class.file.wrong.class: q.A))"; 12.11 12.12 if (!out[0].equals(expected)) { 12.13 System.err.println("expected: " + expected);
13.1 --- a/test/tools/javac/6668794/badSource/Test.out Fri Feb 06 17:24:04 2009 -0800 13.2 +++ b/test/tools/javac/6668794/badSource/Test.out Fri Feb 13 11:57:33 2009 +0000 13.3 @@ -1,1 +1,1 @@ 13.4 -Test.java:10:6: compiler.err.cant.access: p.A, (- compiler.misc.bad.source.file.header: A.java, (- compiler.misc.file.doesnt.contain.class: p.A)) 13.5 +Test.java:10:6: compiler.err.cant.access: p.A, (compiler.misc.bad.source.file.header: A.java, (compiler.misc.file.doesnt.contain.class: p.A))
14.1 --- a/test/tools/javac/6758789/T6758789b.out Fri Feb 06 17:24:04 2009 -0800 14.2 +++ b/test/tools/javac/6758789/T6758789b.out Fri Feb 13 11:57:33 2009 +0000 14.3 @@ -1,4 +1,4 @@ 14.4 -T6758789b.java:39:11: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X> 14.5 +T6758789b.java:39:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X> 14.6 T6758789b.java:39:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a 14.7 - compiler.err.warnings.and.werror 14.8 1 error
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/Diagnostics/6769027/T6769027.java Fri Feb 13 11:57:33 2009 +0000 15.3 @@ -0,0 +1,499 @@ 15.4 +/* 15.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 15.24 + * have any questions. 15.25 + */ 15.26 + 15.27 +/** 15.28 + * @test 15.29 + * @bug 6769027 15.30 + * @summary Source line should be displayed immediately after the first diagnostic line 15.31 + * @author Maurizio Cimadamore 15.32 + * @run main/othervm T6769027 15.33 + */ 15.34 +import java.net.URI; 15.35 +import java.util.regex.Matcher; 15.36 +import javax.tools.*; 15.37 +import com.sun.tools.javac.util.*; 15.38 + 15.39 +public class T6769027 { 15.40 + 15.41 + enum OutputKind { 15.42 + RAW("rawDiagnostics","rawDiagnostics"), 15.43 + BASIC("",""); 15.44 + 15.45 + String key; 15.46 + String value; 15.47 + 15.48 + void init(Options opts) { 15.49 + opts.put(key, value); 15.50 + } 15.51 + 15.52 + OutputKind(String key, String value) { 15.53 + this.key = key; 15.54 + this.value = value; 15.55 + } 15.56 + } 15.57 + 15.58 + enum CaretKind { 15.59 + DEFAULT("", ""), 15.60 + SHOW("showCaret","true"), 15.61 + HIDE("showCaret","false"); 15.62 + 15.63 + String key; 15.64 + String value; 15.65 + 15.66 + void init(Options opts) { 15.67 + opts.put(key, value); 15.68 + } 15.69 + 15.70 + CaretKind(String key, String value) { 15.71 + this.key = key; 15.72 + this.value = value; 15.73 + } 15.74 + 15.75 + boolean isEnabled() { 15.76 + return this == DEFAULT || this == SHOW; 15.77 + } 15.78 + } 15.79 + 15.80 + enum SourceLineKind { 15.81 + DEFAULT("", ""), 15.82 + AFTER_SUMMARY("sourcePosition", "top"), 15.83 + BOTTOM("sourcePosition", "bottom"); 15.84 + 15.85 + String key; 15.86 + String value; 15.87 + 15.88 + void init(Options opts) { 15.89 + opts.put(key, value); 15.90 + } 15.91 + 15.92 + SourceLineKind(String key, String value) { 15.93 + this.key = key; 15.94 + this.value = value; 15.95 + } 15.96 + 15.97 + boolean isAfterSummary() { 15.98 + return this == DEFAULT || this == AFTER_SUMMARY; 15.99 + } 15.100 + } 15.101 + 15.102 + enum XDiagsSource { 15.103 + DEFAULT(""), 15.104 + SOURCE("source"), 15.105 + NO_SOURCE("-source"); 15.106 + 15.107 + String flag; 15.108 + 15.109 + void init(Options opts) { 15.110 + if (this != DEFAULT) { 15.111 + String flags = opts.get("diags"); 15.112 + flags = flags == null ? flag : flags + "," + flag; 15.113 + opts.put("diags", flags); 15.114 + } 15.115 + } 15.116 + 15.117 + XDiagsSource(String flag) { 15.118 + this.flag = flag; 15.119 + } 15.120 + 15.121 + String getOutput(CaretKind caretKind, IndentKind indent, OutputKind outKind) { 15.122 + String spaces = (outKind == OutputKind.BASIC) ? indent.string : ""; 15.123 + return "\n" + spaces + "This is a source line" + 15.124 + (caretKind.isEnabled() ? "\n" + spaces + " ^" : ""); 15.125 + } 15.126 + } 15.127 + 15.128 + enum XDiagsCompact { 15.129 + DEFAULT(""), 15.130 + COMPACT("short"), 15.131 + NO_COMPACT("-short"); 15.132 + 15.133 + String flag; 15.134 + 15.135 + void init(Options opts) { 15.136 + if (this != DEFAULT) { 15.137 + String flags = opts.get("diags"); 15.138 + flags = flags == null ? flag : flags + "," + flag; 15.139 + opts.put("diags", flags); 15.140 + } 15.141 + } 15.142 + 15.143 + XDiagsCompact(String flag) { 15.144 + this.flag = flag; 15.145 + } 15.146 + } 15.147 + 15.148 + enum ErrorKind { 15.149 + SINGLE("single", 15.150 + "compiler.err.single: Hello!", 15.151 + "KXThis is a test error message Hello!"), 15.152 + DOUBLE("double", 15.153 + "compiler.err.double: Hello!", 15.154 + "KXThis is a test error message.\n" + 15.155 + "KXYThis is another line of the above error message Hello!"); 15.156 + 15.157 + String key; 15.158 + String rawOutput; 15.159 + String nonRawOutput; 15.160 + 15.161 + String key() { 15.162 + return key; 15.163 + } 15.164 + 15.165 + ErrorKind(String key, String rawOutput, String nonRawOutput) { 15.166 + this.key = key; 15.167 + this.rawOutput = rawOutput; 15.168 + this.nonRawOutput = nonRawOutput; 15.169 + } 15.170 + 15.171 + String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent) { 15.172 + return outKind == OutputKind.RAW ? 15.173 + rawOutput : 15.174 + nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", ""); 15.175 + } 15.176 + 15.177 + String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent, String indent) { 15.178 + return outKind == OutputKind.RAW ? 15.179 + rawOutput : 15.180 + nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", indent); 15.181 + } 15.182 + } 15.183 + 15.184 + enum MultilineKind { 15.185 + NONE(0), 15.186 + DOUBLE(1), 15.187 + NESTED(2), 15.188 + DOUBLE_NESTED(3); 15.189 + 15.190 + static String[][] rawTemplates = { 15.191 + {"", ",{(E),(E)}", ",{(E,{(E)})}", ",{(E,{(E)}),(E,{(E)})}"}, //ENABLED 15.192 + {"", "", "", "",""}, //DISABLED 15.193 + {"", ",{(E)}", ",{(E,{(E)})}", ",{(E,{(E)})}"}, //LIMIT_LENGTH 15.194 + {"", ",{(E),(E)}", ",{(E)}", ",{(E),(E)}"}, //LIMIT_DEPTH 15.195 + {"", ",{(E)}", ",{(E)}", ",{(E)}"}}; //LIMIT_BOTH 15.196 + 15.197 + static String[][] basicTemplates = { 15.198 + {"", "\nE\nE", "\nE\nQ", "\nE\nQ\nE\nQ"}, //ENABLED 15.199 + {"", "", "", "",""}, //DISABLED 15.200 + {"", "\nE", "\nE\nQ", "\nE\nQ"}, //LIMIT_LENGTH 15.201 + {"", "\nE\nE", "\nE", "\nE\nE"}, //LIMIT_DEPTH 15.202 + {"", "\nE", "\nE", "\nE"}}; //LIMIT_BOTH 15.203 + 15.204 + 15.205 + int index; 15.206 + 15.207 + MultilineKind (int index) { 15.208 + this.index = index; 15.209 + } 15.210 + 15.211 + boolean isDouble() { 15.212 + return this == DOUBLE || this == DOUBLE_NESTED; 15.213 + } 15.214 + 15.215 + boolean isNested() { 15.216 + return this == NESTED || this == DOUBLE_NESTED; 15.217 + } 15.218 + 15.219 + String getOutput(OutputKind outKind, ErrorKind errKind, MultilinePolicy policy, 15.220 + IndentKind summaryIndent, IndentKind detailsIndent, IndentKind multiIndent) { 15.221 + String constIndent = (errKind == ErrorKind.DOUBLE) ? 15.222 + summaryIndent.string + detailsIndent.string : 15.223 + summaryIndent.string; 15.224 + constIndent += multiIndent.string; 15.225 + 15.226 + String errMsg1 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent); 15.227 + String errMsg2 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent + constIndent); 15.228 + 15.229 + errMsg1 = errMsg1.replaceAll("compiler.err", "compiler.misc"); 15.230 + errMsg1 = errMsg1.replaceAll("error message", "subdiagnostic"); 15.231 + errMsg2 = errMsg2.replaceAll("compiler.err", "compiler.misc"); 15.232 + errMsg2 = errMsg2.replaceAll("error message", "subdiagnostic"); 15.233 + 15.234 + String template = outKind == OutputKind.RAW ? 15.235 + rawTemplates[policy.index][index] : 15.236 + basicTemplates[policy.index][index]; 15.237 + 15.238 + template = template.replaceAll("E", errMsg1); 15.239 + return template.replaceAll("Q", errMsg2); 15.240 + } 15.241 + } 15.242 + 15.243 + enum MultilinePolicy { 15.244 + ENABLED(0, "multilinePolicy", "enabled"), 15.245 + DISABLED(1, "multilinePolicy", "disabled"), 15.246 + LIMIT_LENGTH(2, "multilinePolicy", "limit:1:*"), 15.247 + LIMIT_DEPTH(3, "multilinePolicy", "limit:*:1"), 15.248 + LIMIT_BOTH(4, "multilinePolicy", "limit:1:1"); 15.249 + 15.250 + String name; 15.251 + String value; 15.252 + int index; 15.253 + 15.254 + MultilinePolicy(int index, String name, String value) { 15.255 + this.name = name; 15.256 + this.value = value; 15.257 + this.index = index; 15.258 + } 15.259 + 15.260 + void init(Options options) { 15.261 + options.put(name, value); 15.262 + } 15.263 + } 15.264 + 15.265 + enum PositionKind { 15.266 + NOPOS(Position.NOPOS, "- ", "error: "), 15.267 + POS(5, "/Test.java:1:6: ", "myfo:/Test.java:1: "); 15.268 + 15.269 + int pos; 15.270 + String rawOutput; 15.271 + String nonRawOutput; 15.272 + 15.273 + PositionKind(int pos, String rawOutput, String nonRawOutput) { 15.274 + this.pos = pos; 15.275 + this.rawOutput = rawOutput; 15.276 + this.nonRawOutput = nonRawOutput; 15.277 + } 15.278 + 15.279 + JCDiagnostic.DiagnosticPosition pos() { 15.280 + return new JCDiagnostic.SimpleDiagnosticPosition(pos); 15.281 + } 15.282 + 15.283 + String getOutput(OutputKind outputKind) { 15.284 + return outputKind == OutputKind.RAW ? 15.285 + rawOutput : 15.286 + nonRawOutput; 15.287 + } 15.288 + } 15.289 + 15.290 + static class MyFileObject extends SimpleJavaFileObject { 15.291 + private String text; 15.292 + public MyFileObject(String text) { 15.293 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 15.294 + this.text = text; 15.295 + } 15.296 + @Override 15.297 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 15.298 + return text; 15.299 + } 15.300 + } 15.301 + 15.302 + enum IndentKind { 15.303 + NONE(""), 15.304 + CUSTOM(" "); 15.305 + 15.306 + String string; 15.307 + 15.308 + IndentKind(String indent) { 15.309 + string = indent; 15.310 + } 15.311 + } 15.312 + 15.313 + class MyLog extends Log { 15.314 + MyLog(Context ctx) { 15.315 + super(ctx); 15.316 + } 15.317 + 15.318 + @Override 15.319 + protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) { 15.320 + return new java.io.PrintWriter(System.out); 15.321 + } 15.322 + 15.323 + @Override 15.324 + protected boolean shouldReport(JavaFileObject jfo, int pos) { 15.325 + return true; 15.326 + } 15.327 + } 15.328 + 15.329 + int nerrors = 0; 15.330 + 15.331 + void exec(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind, 15.332 + MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource, 15.333 + XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind, 15.334 + IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent, 15.335 + IndentKind subdiagsIndent) { 15.336 + Context ctx = new Context(); 15.337 + Options options = Options.instance(ctx); 15.338 + outputKind.init(options); 15.339 + multiPolicy.init(options); 15.340 + xdiagsSource.init(options); 15.341 + xdiagsCompact.init(options); 15.342 + caretKind.init(options); 15.343 + sourceLineKind.init(options); 15.344 + String indentString = ""; 15.345 + indentString = (summaryIndent == IndentKind.CUSTOM) ? "3" : "0"; 15.346 + indentString += (detailsIndent == IndentKind.CUSTOM) ? "|3" : "|0"; 15.347 + indentString += (sourceIndent == IndentKind.CUSTOM) ? "|3" : "|0"; 15.348 + indentString += (subdiagsIndent == IndentKind.CUSTOM) ? "|3" : "|0"; 15.349 + options.put("diagsIndentation", indentString); 15.350 + MyLog log = new MyLog(ctx); 15.351 + JavacMessages messages = JavacMessages.instance(ctx); 15.352 + messages.add("tester"); 15.353 + JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(ctx); 15.354 + log.useSource(new MyFileObject("This is a source line")); 15.355 + JCDiagnostic d = diags.error(log.currentSource(), 15.356 + posKind.pos(), 15.357 + errorKind.key(), "Hello!"); 15.358 + if (multiKind != MultilineKind.NONE) { 15.359 + JCDiagnostic sub = diags.fragment(errorKind.key(), "Hello!"); 15.360 + if (multiKind.isNested()) 15.361 + sub = new JCDiagnostic.MultilineDiagnostic(sub, List.of(sub)); 15.362 + List<JCDiagnostic> subdiags = multiKind.isDouble() ? 15.363 + List.of(sub, sub) : 15.364 + List.of(sub); 15.365 + d = new JCDiagnostic.MultilineDiagnostic(d, subdiags); 15.366 + } 15.367 + String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale()); 15.368 + checkOutput(diag, 15.369 + outputKind, 15.370 + errorKind, 15.371 + multiKind, 15.372 + multiPolicy, 15.373 + posKind, 15.374 + xdiagsSource, 15.375 + xdiagsCompact, 15.376 + caretKind, 15.377 + sourceLineKind, 15.378 + summaryIndent, 15.379 + detailsIndent, 15.380 + sourceIndent, 15.381 + subdiagsIndent); 15.382 + } 15.383 + 15.384 + void test() { 15.385 + for (OutputKind outputKind : OutputKind.values()) { 15.386 + for (ErrorKind errKind : ErrorKind.values()) { 15.387 + for (MultilineKind multiKind : MultilineKind.values()) { 15.388 + for (MultilinePolicy multiPolicy : MultilinePolicy.values()) { 15.389 + for (PositionKind posKind : PositionKind.values()) { 15.390 + for (XDiagsSource xdiagsSource : XDiagsSource.values()) { 15.391 + for (XDiagsCompact xdiagsCompact : XDiagsCompact.values()) { 15.392 + for (CaretKind caretKind : CaretKind.values()) { 15.393 + for (SourceLineKind sourceLineKind : SourceLineKind.values()) { 15.394 + for (IndentKind summaryIndent : IndentKind.values()) { 15.395 + for (IndentKind detailsIndent : IndentKind.values()) { 15.396 + for (IndentKind sourceIndent : IndentKind.values()) { 15.397 + for (IndentKind subdiagsIndent : IndentKind.values()) { 15.398 + exec(outputKind, 15.399 + errKind, 15.400 + multiKind, 15.401 + multiPolicy, 15.402 + posKind, 15.403 + xdiagsSource, 15.404 + xdiagsCompact, 15.405 + caretKind, 15.406 + sourceLineKind, 15.407 + summaryIndent, 15.408 + detailsIndent, 15.409 + sourceIndent, 15.410 + subdiagsIndent); 15.411 + } 15.412 + } 15.413 + } 15.414 + } 15.415 + } 15.416 + } 15.417 + } 15.418 + } 15.419 + } 15.420 + } 15.421 + } 15.422 + } 15.423 + } 15.424 + if (nerrors != 0) 15.425 + throw new AssertionError(nerrors + " errors found"); 15.426 + } 15.427 + 15.428 + void printInfo(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind, 15.429 + MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource, 15.430 + XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind, 15.431 + IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent, 15.432 + IndentKind subdiagsIndent, String errorLine) { 15.433 + String sep = "*********************************************************"; 15.434 + String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() + 15.435 + " multiline=" + multiKind +" multiPolicy=" + multiPolicy.value + 15.436 + " diags= " + java.util.Arrays.asList(xdiagsSource.flag, xdiagsCompact.flag) + 15.437 + " caret=" + caretKind + " sourcePosition=" + sourceLineKind + 15.438 + " summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent + 15.439 + " sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent; 15.440 + System.out.println(sep); 15.441 + System.out.println(desc); 15.442 + System.out.println(sep); 15.443 + System.out.println(msg); 15.444 + System.out.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine); 15.445 + } 15.446 + 15.447 + void checkOutput(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind, 15.448 + MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource, 15.449 + XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind, 15.450 + IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent, 15.451 + IndentKind subdiagsIndent) { 15.452 + boolean shouldPrintSource = posKind == PositionKind.POS && 15.453 + xdiagsSource != XDiagsSource.NO_SOURCE && 15.454 + (xdiagsSource == XDiagsSource.SOURCE || 15.455 + outputKind == OutputKind.BASIC); 15.456 + String errorLine = posKind.getOutput(outputKind) + 15.457 + errorKind.getOutput(outputKind, summaryIndent, detailsIndent); 15.458 + if (xdiagsCompact != XDiagsCompact.COMPACT) 15.459 + errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent); 15.460 + String[] lines = errorLine.split("\n"); 15.461 + if (xdiagsCompact == XDiagsCompact.COMPACT) { 15.462 + errorLine = lines[0]; 15.463 + lines = new String[] {errorLine}; 15.464 + } 15.465 + if (shouldPrintSource) { 15.466 + if (sourceLineKind.isAfterSummary()) { 15.467 + String sep = "\n"; 15.468 + if (lines.length == 1) { 15.469 + errorLine += "\n"; 15.470 + sep = ""; 15.471 + } 15.472 + errorLine = errorLine.replaceFirst("\n", 15.473 + Matcher.quoteReplacement(xdiagsSource.getOutput(caretKind, sourceIndent, outputKind) + sep)); 15.474 + } 15.475 + else 15.476 + errorLine += xdiagsSource.getOutput(caretKind, sourceIndent, outputKind); 15.477 + } 15.478 + 15.479 + if (!msg.equals(errorLine)) { 15.480 + printInfo(msg, 15.481 + outputKind, 15.482 + errorKind, 15.483 + multiKind, 15.484 + multiPolicy, 15.485 + posKind, 15.486 + xdiagsSource, 15.487 + xdiagsCompact, 15.488 + caretKind, 15.489 + sourceLineKind, 15.490 + summaryIndent, 15.491 + detailsIndent, 15.492 + sourceIndent, 15.493 + subdiagsIndent, 15.494 + errorLine); 15.495 + nerrors++; 15.496 + } 15.497 + } 15.498 + 15.499 + public static void main(String... args) throws Exception { 15.500 + new T6769027().test(); 15.501 + } 15.502 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/Diagnostics/6769027/tester.properties Fri Feb 13 11:57:33 2009 +0000 16.3 @@ -0,0 +1,13 @@ 16.4 +compiler.err.single=\ 16.5 + This is a test error message {0} 16.6 + 16.7 +compiler.err.double=\ 16.8 + This is a test error message.\n\ 16.9 + This is another line of the above error message {0} 16.10 + 16.11 +compiler.misc.single=\ 16.12 + This is a test subdiagnostic {0} 16.13 + 16.14 +compiler.misc.double=\ 16.15 + This is a test subdiagnostic.\n\ 16.16 + This is another line of the above subdiagnostic {0}
17.1 --- a/test/tools/javac/ExtendArray.out Fri Feb 06 17:24:04 2009 -0800 17.2 +++ b/test/tools/javac/ExtendArray.out Fri Feb 13 11:57:33 2009 +0000 17.3 @@ -1,6 +1,6 @@ 17.4 ExtendArray.java:11: unexpected type 17.5 -found : java.lang.Object[] 17.6 -required: class 17.7 public class ExtendArray extends Object[] {} 17.8 ^ 17.9 + required: class 17.10 + found: java.lang.Object[] 17.11 1 error
18.1 --- a/test/tools/javac/T5048776b.out Fri Feb 06 17:24:04 2009 -0800 18.2 +++ b/test/tools/javac/T5048776b.out Fri Feb 13 11:57:33 2009 +0000 18.3 @@ -1,3 +1,3 @@ 18.4 -T5048776.java:12:10: compiler.warn.override.varargs.missing: (- compiler.misc.varargs.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1) 18.5 -T5048776.java:20:10: compiler.warn.override.varargs.extra: (- compiler.misc.varargs.override: foo(java.lang.Object[]), A2a, foo(java.lang.Object...), A2) 18.6 +T5048776.java:12:10: compiler.warn.override.varargs.missing: (compiler.misc.varargs.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1) 18.7 +T5048776.java:20:10: compiler.warn.override.varargs.extra: (compiler.misc.varargs.override: foo(java.lang.Object[]), A2a, foo(java.lang.Object...), A2) 18.8 2 warnings
19.1 --- a/test/tools/javac/T6214885a.out Fri Feb 06 17:24:04 2009 -0800 19.2 +++ b/test/tools/javac/T6214885a.out Fri Feb 13 11:57:33 2009 +0000 19.3 @@ -1,6 +1,6 @@ 19.4 T6214885.java:11 cannot find symbol 19.5 -symbol : variable x 19.6 -location: class T6214885 19.7 x = 1; 19.8 ^ 19.9 + symbol: variable x 19.10 + location: class T6214885 19.11 1 error
20.1 --- a/test/tools/javac/T6214885b.out Fri Feb 06 17:24:04 2009 -0800 20.2 +++ b/test/tools/javac/T6214885b.out Fri Feb 13 11:57:33 2009 +0000 20.3 @@ -1,6 +1,6 @@ 20.4 T6214885.java:11:9 cannot find symbol 20.5 -symbol : variable x 20.6 -location: class T6214885 20.7 x = 1; 20.8 ^ 20.9 + symbol: variable x 20.10 + location: class T6214885 20.11 1 error
21.1 --- a/test/tools/javac/T6230128.out Fri Feb 06 17:24:04 2009 -0800 21.2 +++ b/test/tools/javac/T6230128.out Fri Feb 13 11:57:33 2009 +0000 21.3 @@ -1,2 +1,2 @@ 21.4 -T6230128.java:11:10: compiler.err.override.weaker.access: (- compiler.misc.cant.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1), public 21.5 +T6230128.java:11:10: compiler.err.override.weaker.access: (compiler.misc.cant.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1), public 21.6 1 error
22.1 --- a/test/tools/javac/annotations/6365854/test1.out Fri Feb 06 17:24:04 2009 -0800 22.2 +++ b/test/tools/javac/annotations/6365854/test1.out Fri Feb 13 11:57:33 2009 +0000 22.3 @@ -1,2 +1,2 @@ 22.4 -- compiler.warn.annotation.method.not.found.reason: test.annotation.TestAnnotation, test, (- compiler.misc.class.file.not.found: test.annotation.TestAnnotation) 22.5 +- compiler.warn.annotation.method.not.found.reason: test.annotation.TestAnnotation, test, (compiler.misc.class.file.not.found: test.annotation.TestAnnotation) 22.6 1 warning
23.1 --- a/test/tools/javac/cast/6557182/T6557182.out Fri Feb 06 17:24:04 2009 -0800 23.2 +++ b/test/tools/javac/cast/6557182/T6557182.out Fri Feb 13 11:57:33 2009 +0000 23.3 @@ -1,4 +1,4 @@ 23.4 -T6557182.java:35:56: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T, java.lang.Comparable<java.lang.Integer> 23.5 -T6557182.java:39:56: compiler.warn.prob.found.req: (- compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable<java.lang.Integer> 23.6 +T6557182.java:35:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T, java.lang.Comparable<java.lang.Integer> 23.7 +T6557182.java:39:56: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable<java.lang.Integer> 23.8 1 error 23.9 1 warning
24.1 --- a/test/tools/javac/cast/6665356/T6665356.out Fri Feb 06 17:24:04 2009 -0800 24.2 +++ b/test/tools/javac/cast/6665356/T6665356.out Fri Feb 13 11:57:33 2009 +0000 24.3 @@ -1,8 +1,8 @@ 24.4 -T6665356.java:54:55: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<java.lang.Long> 24.5 -T6665356.java:58:58: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.Number> 24.6 -T6665356.java:62:65: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<? super java.lang.Number> 24.7 -T6665356.java:66:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? extends java.lang.String>.Inner<java.lang.Long> 24.8 -T6665356.java:70:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? extends java.lang.String> 24.9 -T6665356.java:74:55: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.String>.Inner<java.lang.Long> 24.10 -T6665356.java:78:58: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.String> 24.11 +T6665356.java:54:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<java.lang.Long> 24.12 +T6665356.java:58:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.Number> 24.13 +T6665356.java:62:65: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<? super java.lang.Number> 24.14 +T6665356.java:66:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? extends java.lang.String>.Inner<java.lang.Long> 24.15 +T6665356.java:70:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? extends java.lang.String> 24.16 +T6665356.java:74:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.String>.Inner<java.lang.Long> 24.17 +T6665356.java:78:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.String> 24.18 7 errors 24.19 \ No newline at end of file
25.1 --- a/test/tools/javac/cast/6795580/T6795580.out Fri Feb 06 17:24:04 2009 -0800 25.2 +++ b/test/tools/javac/cast/6795580/T6795580.out Fri Feb 13 11:57:33 2009 +0000 25.3 @@ -1,8 +1,8 @@ 25.4 -T6795580.java:54:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<java.lang.Long>[] 25.5 -T6795580.java:58:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.Number>[] 25.6 -T6795580.java:62:67: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>[] 25.7 -T6795580.java:66:59: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? extends java.lang.String>.Inner<java.lang.Long>[] 25.8 -T6795580.java:70:62: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? extends java.lang.String>[] 25.9 -T6795580.java:74:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.String>.Inner<java.lang.Long>[] 25.10 -T6795580.java:78:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.String>[] 25.11 +T6795580.java:54:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<java.lang.Long>[] 25.12 +T6795580.java:58:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.Number>[] 25.13 +T6795580.java:62:67: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>[] 25.14 +T6795580.java:66:59: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? extends java.lang.String>.Inner<java.lang.Long>[] 25.15 +T6795580.java:70:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? extends java.lang.String>[] 25.16 +T6795580.java:74:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.String>.Inner<java.lang.Long>[] 25.17 +T6795580.java:78:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.String>[] 25.18 7 errors
26.1 --- a/test/tools/javac/generics/6207386/T6207386.out Fri Feb 06 17:24:04 2009 -0800 26.2 +++ b/test/tools/javac/generics/6207386/T6207386.out Fri Feb 13 11:57:33 2009 +0000 26.3 @@ -1,2 +1,2 @@ 26.4 -T6207386.java:13:30: compiler.err.prob.found.req: (- compiler.misc.incompatible.types), X, T6207386.F<? super X> 26.5 +T6207386.java:13:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), X, T6207386.F<? super X> 26.6 1 error
27.1 --- a/test/tools/javac/generics/inference/6315770/T6315770.out Fri Feb 06 17:24:04 2009 -0800 27.2 +++ b/test/tools/javac/generics/inference/6315770/T6315770.out Fri Feb 13 11:57:33 2009 +0000 27.3 @@ -1,3 +1,3 @@ 27.4 -T6315770.java:39:42: compiler.err.undetermined.type.1: <T>T6315770<T>, (- compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) 27.5 -T6315770.java:40:40: compiler.err.prob.found.req: (- compiler.misc.incompatible.types.1: (- compiler.misc.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String> 27.6 +T6315770.java:39:42: compiler.err.undetermined.type.1: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) 27.7 +T6315770.java:40:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String> 27.8 2 errors
28.1 --- a/test/tools/javac/generics/inference/6718364/T6718364.out Fri Feb 06 17:24:04 2009 -0800 28.2 +++ b/test/tools/javac/generics/inference/6718364/T6718364.out Fri Feb 13 11:57:33 2009 +0000 28.3 @@ -1,3 +1,3 @@ 28.4 -T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer> 28.5 +T6718364.java:36:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer> 28.6 T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X<T>,T, T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X, kindname.class, T6718364 28.7 2 warnings 28.8 \ No newline at end of file
29.1 --- a/test/tools/javac/generics/typevars/6680106/T6680106.out Fri Feb 06 17:24:04 2009 -0800 29.2 +++ b/test/tools/javac/generics/typevars/6680106/T6680106.out Fri Feb 13 11:57:33 2009 +0000 29.3 @@ -1,13 +1,13 @@ 29.4 -T6680106.java:34:25: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.5 -T6680106.java:35:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) 29.6 -T6680106.java:35:40: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.7 -T6680106.java:36:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) 29.8 -T6680106.java:36:40: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class) 29.9 -T6680106.java:36:55: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.10 -T6680106.java:37:30: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.11 -T6680106.java:38:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) 29.12 -T6680106.java:38:50: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.13 -T6680106.java:39:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) 29.14 -T6680106.java:39:50: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class) 29.15 -T6680106.java:39:70: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) 29.16 +T6680106.java:34:25: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.17 +T6680106.java:35:25: compiler.err.type.found.req: S[], (compiler.misc.type.req.class) 29.18 +T6680106.java:35:40: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.19 +T6680106.java:36:25: compiler.err.type.found.req: S[], (compiler.misc.type.req.class) 29.20 +T6680106.java:36:40: compiler.err.type.found.req: U[], (compiler.misc.type.req.class) 29.21 +T6680106.java:36:55: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.22 +T6680106.java:37:30: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.23 +T6680106.java:38:30: compiler.err.type.found.req: S[], (compiler.misc.type.req.class) 29.24 +T6680106.java:38:50: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.25 +T6680106.java:39:30: compiler.err.type.found.req: S[], (compiler.misc.type.req.class) 29.26 +T6680106.java:39:50: compiler.err.type.found.req: U[], (compiler.misc.type.req.class) 29.27 +T6680106.java:39:70: compiler.err.type.found.req: T[], (compiler.misc.type.req.class) 29.28 12 errors 29.29 \ No newline at end of file
30.1 --- a/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out Fri Feb 06 17:24:04 2009 -0800 30.2 +++ b/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out Fri Feb 13 11:57:33 2009 +0000 30.3 @@ -1,5 +1,5 @@ 30.4 MissingSuperRecovery.java:15: cannot access base 30.5 -class file for base not found 30.6 public class MissingSuperRecovery extends impl { 30.7 ^ 30.8 + class file for base not found 30.9 1 error
31.1 --- a/test/tools/javac/unicode/UnicodeNewline.out Fri Feb 06 17:24:04 2009 -0800 31.2 +++ b/test/tools/javac/unicode/UnicodeNewline.out Fri Feb 13 11:57:33 2009 +0000 31.3 @@ -1,6 +1,6 @@ 31.4 UnicodeNewline.java:11: cannot find symbol 31.5 -symbol : class xyzzy 31.6 -location: class UnicodeNewline 31.7 xyzzy plugh; // error should be HERE 31.8 ^ 31.9 + symbol: class xyzzy 31.10 + location: class UnicodeNewline 31.11 1 error