6722234: javac diagnostics need better integration with the type-system

Thu, 21 May 2009 10:56:36 +0100

author
mcimadamore
date
Thu, 21 May 2009 10:56:36 +0100
changeset 288
d402db1005ad
parent 287
44eaac2b4501
child 289
84061bd68019

6722234: javac diagnostics need better integration with the type-system
Summary: Added RichDiagnosticFormatter which provides better formatting capabilities for javac types/symbols
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Printer.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/code/Type.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/resources/compiler.properties file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/ForwardingDiagnosticFormatter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java file | annotate | diff | comparison | revisions
test/tools/javac/6304921/T6304921.java file | annotate | diff | comparison | revisions
test/tools/javac/6304921/T6304921.out file | annotate | diff | comparison | revisions
test/tools/javac/6491592/T6491592.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234a.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234a_1.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234a_2.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234b.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234b_1.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234b_2.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234c.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234c.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234d.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234d_1.out file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6722234/T6722234d_2.out file | annotate | diff | comparison | revisions
test/tools/javac/ExtendArray.java file | annotate | diff | comparison | revisions
test/tools/javac/ExtendArray.out file | annotate | diff | comparison | revisions
test/tools/javac/OverridePosition.java file | annotate | diff | comparison | revisions
test/tools/javac/OverridePosition.out file | annotate | diff | comparison | revisions
test/tools/javac/T4093617/T4093617.java file | annotate | diff | comparison | revisions
test/tools/javac/T4093617/T4093617.out file | annotate | diff | comparison | revisions
test/tools/javac/T5003235/T5003235c.java file | annotate | diff | comparison | revisions
test/tools/javac/T5003235/T5003235c.out file | annotate | diff | comparison | revisions
test/tools/javac/miranda/T4666866.java file | annotate | diff | comparison | revisions
test/tools/javac/miranda/T4666866.out file | annotate | diff | comparison | revisions
test/tools/javac/protectedAccess/ProtectedMemberAccess2.java file | annotate | diff | comparison | revisions
test/tools/javac/protectedAccess/ProtectedMemberAccess3.java file | annotate | diff | comparison | revisions
test/tools/javac/protectedAccess/ProtectedMemberAccess4.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Printer.java	Wed May 20 19:10:06 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Printer.java	Thu May 21 10:56:36 2009 +0100
     1.3 @@ -43,6 +43,9 @@
     1.4   */
     1.5  public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Visitor<String, Locale> {
     1.6  
     1.7 +    List<Type> seenCaptured = List.nil();
     1.8 +    static final int PRIME = 997;  // largest prime less than 1000
     1.9 +
    1.10      /**
    1.11       * This method should be overriden in order to provide proper i18n support.
    1.12       *
    1.13 @@ -54,7 +57,18 @@
    1.14      protected abstract String localize(Locale locale, String key, Object... args);
    1.15  
    1.16      /**
    1.17 -     * Create a printer with default i18n support provided my Messages.
    1.18 +     * Maps a captured type into an unique identifier.
    1.19 +     *
    1.20 +     * @param t the captured type for which an id is to be retrieved
    1.21 +     * @param locale locale settings
    1.22 +     * @return unique id representing this captured type
    1.23 +     */
    1.24 +    protected abstract String capturedVarId(CapturedType t, Locale locale);
    1.25 +
    1.26 +    /**
    1.27 +     * Create a printer with default i18n support provided by Messages. By default,
    1.28 +     * captured types ids are generated using hashcode.
    1.29 +     *
    1.30       * @param messages Messages class to be used for i18n
    1.31       * @return printer visitor instance
    1.32       */
    1.33 @@ -63,6 +77,11 @@
    1.34              @Override
    1.35              protected String localize(Locale locale, String key, Object... args) {
    1.36                  return messages.getLocalizedString(locale, key, args);
    1.37 +            }
    1.38 +
    1.39 +            @Override
    1.40 +            protected String capturedVarId(CapturedType t, Locale locale) {
    1.41 +                return (t.hashCode() & 0xFFFFFFFFL) % PRIME + "";
    1.42          }};
    1.43      }
    1.44  
    1.45 @@ -120,9 +139,20 @@
    1.46  
    1.47      @Override
    1.48      public String visitCapturedType(CapturedType t, Locale locale) {
    1.49 -        return localize(locale, "compiler.misc.type.captureof",
    1.50 -            (t.hashCode() & 0xFFFFFFFFL) % Type.CapturedType.PRIME,
    1.51 -            visit(t.wildcard, locale));
    1.52 +        if (seenCaptured.contains(t))
    1.53 +            return localize(locale, "compiler.misc.type.captureof.1",
    1.54 +                capturedVarId(t, locale));
    1.55 +        else {
    1.56 +            try {
    1.57 +                seenCaptured = seenCaptured.prepend(t);
    1.58 +                return localize(locale, "compiler.misc.type.captureof",
    1.59 +                    capturedVarId(t, locale),
    1.60 +                    visit(t.wildcard, locale));
    1.61 +            }
    1.62 +            finally {
    1.63 +                seenCaptured = seenCaptured.tail;
    1.64 +            }
    1.65 +        }
    1.66      }
    1.67  
    1.68      @Override
     2.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed May 20 19:10:06 2009 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Thu May 21 10:56:36 2009 +0100
     2.3 @@ -1008,11 +1008,10 @@
     2.4          @Override
     2.5          public String toString() {
     2.6              return "capture#"
     2.7 -                + (hashCode() & 0xFFFFFFFFL) % PRIME
     2.8 +                + (hashCode() & 0xFFFFFFFFL) % Printer.PRIME
     2.9                  + " of "
    2.10                  + wildcard;
    2.11          }
    2.12 -        static final int PRIME = 997;  // largest prime less than 1000
    2.13      }
    2.14  
    2.15      public static abstract class DelegatedType extends Type {
     3.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed May 20 19:10:06 2009 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu May 21 10:56:36 2009 +0100
     3.3 @@ -391,6 +391,8 @@
     3.4              (options.get("shouldStopPolicy") != null)
     3.5              ? CompileState.valueOf(options.get("shouldStopPolicy"))
     3.6              : null;
     3.7 +        if (options.get("oldDiags") == null)
     3.8 +            log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context));
     3.9      }
    3.10  
    3.11      /* Switches:
     4.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed May 20 19:10:06 2009 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu May 21 10:56:36 2009 +0100
     4.3 @@ -1165,3 +1165,64 @@
     4.4  compiler.err.enums.not.supported.in.source=\
     4.5      enums are not supported in -source {0}\n\
     4.6  (use -source 5 or higher to enable enums)
     4.7 +
     4.8 +########################################
     4.9 +# Diagnostics for where clause implementation
    4.10 +# used by the RichDiagnosticFormatter.
    4.11 +########################################
    4.12 +
    4.13 +compiler.misc.type.null=\
    4.14 +    <null>
    4.15 +
    4.16 +# X#n (where n is an int id) is disambiguated tvar name
    4.17 +compiler.misc.type.var=\
    4.18 +    {0}#{1}
    4.19 +
    4.20 +# CAP#n (where n is an int id) is an abbreviation for 'captured type'
    4.21 +compiler.misc.captured.type=\
    4.22 +    CAP#{0}
    4.23 +
    4.24 +# <INT#n> (where n is an int id) is an abbreviation for 'intersection type'
    4.25 +compiler.misc.intersection.type=\
    4.26 +    INT#{0}
    4.27 +
    4.28 +# where clause for captured type: contains upper ('extends {1}') and lower
    4.29 +# ('super {2}') bound along with the wildcard that generated this captured type ({3})
    4.30 +compiler.misc.where.captured=\
    4.31 +    {0} extends {1} super: {2} from capture of {3}
    4.32 +
    4.33 +# compact where clause for captured type: contains upper ('extends {1}') along
    4.34 +# with the wildcard that generated this captured type ({3})
    4.35 +compiler.misc.where.captured.1=\
    4.36 +    {0} extends {1} from capture of {3}
    4.37 +
    4.38 +# where clause for type variable: contains upper bound(s) ('extends {1}') along with
    4.39 +# the kindname ({2}) and location ({3}) in which the typevar has been declared
    4.40 +compiler.misc.where.typevar=\
    4.41 +    {0} extends {1} declared in {2} {3}
    4.42 +
    4.43 +# compact where clause for type variable: contains the kindname ({2}) and location ({3})
    4.44 +# in which the typevar has been declared
    4.45 +compiler.misc.where.typevar.1=\
    4.46 +    {0} declared in {2} {3}
    4.47 +
    4.48 +# where clause for type variable: contains all the upper bound(s) ('extends {1}')
    4.49 +# of this intersection type
    4.50 +compiler.misc.where.intersection=\
    4.51 +    {0} extends {1}
    4.52 +
    4.53 +### Where clause headers ###
    4.54 +compiler.misc.where.description.captured=\
    4.55 +    where {0} is a fresh type-variable:
    4.56 +compiler.misc.where.description.typevar=\
    4.57 +    where {0} is a type-variable:
    4.58 +compiler.misc.where.description.intersection=\
    4.59 +    where {0} is an intersection type:
    4.60 +compiler.misc.where.description.captured.1=\
    4.61 +    where {0} are fresh type-variables:
    4.62 +compiler.misc.where.description.typevar.1=\
    4.63 +    where {0} are type-variables:
    4.64 +compiler.misc.where.description.intersection.1=\
    4.65 +    where {0} are intersection types:
    4.66 +
    4.67 +
     5.1 --- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Wed May 20 19:10:06 2009 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Thu May 21 10:56:36 2009 +0100
     5.3 @@ -77,9 +77,11 @@
     5.4      protected int depth = 0;
     5.5  
     5.6      /**
     5.7 -     * Printer instance to be used for formatting types/symbol
     5.8 +     * All captured types that have been encountered during diagnostic formatting.
     5.9 +     * This info is used by the FormatterPrinter in order to print friendly unique
    5.10 +     * ids for captured types
    5.11       */
    5.12 -    protected Printer printer;
    5.13 +    private List<Type> allCaptured = List.nil();
    5.14  
    5.15      /**
    5.16       * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object.
    5.17 @@ -88,7 +90,6 @@
    5.18      protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) {
    5.19          this.messages = messages;
    5.20          this.config = config;
    5.21 -        this.printer = new FormatterPrinter();
    5.22      }
    5.23  
    5.24      public String formatKind(JCDiagnostic d, Locale l) {
    5.25 @@ -104,7 +105,7 @@
    5.26  
    5.27      @Override
    5.28      public String format(JCDiagnostic d, Locale locale) {
    5.29 -        printer = new FormatterPrinter();
    5.30 +        allCaptured = List.nil();
    5.31          return formatDiagnostic(d, locale);
    5.32      }
    5.33  
    5.34 @@ -171,6 +172,9 @@
    5.35              return formatIterable(d, (Iterable<?>)arg, l);
    5.36          }
    5.37          else if (arg instanceof Type) {
    5.38 +            if (!allCaptured.contains(arg)) {
    5.39 +                allCaptured = allCaptured.append((Type)arg);
    5.40 +            }
    5.41              return printer.visit((Type)arg, l);
    5.42          }
    5.43          else if (arg instanceof Symbol) {
    5.44 @@ -291,6 +295,10 @@
    5.45                  d.getIntPosition() != Position.NOPOS;
    5.46      }
    5.47  
    5.48 +    public boolean isRaw() {
    5.49 +        return false;
    5.50 +    }
    5.51 +
    5.52      /**
    5.53       * Creates a string with a given amount of empty spaces. Useful for
    5.54       * indenting the text of a diagnostic message.
    5.55 @@ -355,26 +363,26 @@
    5.56              String showSource = null;
    5.57              if ((showSource = options.get("showSource")) != null) {
    5.58                  if (showSource.equals("true"))
    5.59 -                    visibleParts.add(DiagnosticPart.SOURCE);
    5.60 +                    setVisiblePart(DiagnosticPart.SOURCE, true);
    5.61                  else if (showSource.equals("false"))
    5.62 -                    visibleParts.remove(DiagnosticPart.SOURCE);
    5.63 +                    setVisiblePart(DiagnosticPart.SOURCE, false);
    5.64              }
    5.65              String diagOpts = options.get("diags");
    5.66              if (diagOpts != null) {//override -XDshowSource
    5.67                  Collection<String> args = Arrays.asList(diagOpts.split(","));
    5.68                  if (args.contains("short")) {
    5.69 -                    visibleParts.remove(DiagnosticPart.DETAILS);
    5.70 -                    visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS);
    5.71 +                    setVisiblePart(DiagnosticPart.DETAILS, false);
    5.72 +                    setVisiblePart(DiagnosticPart.SUBDIAGNOSTICS, false);
    5.73                  }
    5.74                  if (args.contains("source"))
    5.75 -                    visibleParts.add(DiagnosticPart.SOURCE);
    5.76 +                    setVisiblePart(DiagnosticPart.SOURCE, true);
    5.77                  if (args.contains("-source"))
    5.78 -                    visibleParts.remove(DiagnosticPart.SOURCE);
    5.79 +                    setVisiblePart(DiagnosticPart.SOURCE, false);
    5.80              }
    5.81              String multiPolicy = null;
    5.82              if ((multiPolicy = options.get("multilinePolicy")) != null) {
    5.83                  if (multiPolicy.equals("disabled"))
    5.84 -                    visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS);
    5.85 +                    setVisiblePart(DiagnosticPart.SUBDIAGNOSTICS, false);
    5.86                  else if (multiPolicy.startsWith("limit:")) {
    5.87                      String limitString = multiPolicy.substring("limit:".length());
    5.88                      String[] limits = limitString.split(":");
    5.89 @@ -421,6 +429,13 @@
    5.90              visibleParts = EnumSet.copyOf(diagParts);
    5.91          }
    5.92  
    5.93 +        public void setVisiblePart(DiagnosticPart diagParts, boolean enabled) {
    5.94 +            if (enabled)
    5.95 +                visibleParts.add(diagParts);
    5.96 +            else
    5.97 +                visibleParts.remove(diagParts);
    5.98 +        }
    5.99 +
   5.100          /**
   5.101           * Shows a '^' sign under the source line displayed by the formatter
   5.102           * (if applicable).
   5.103 @@ -441,6 +456,14 @@
   5.104          }
   5.105      }
   5.106  
   5.107 +    public Printer getPrinter() {
   5.108 +        return printer;
   5.109 +    }
   5.110 +
   5.111 +    public void setPrinter(Printer printer) {
   5.112 +        this.printer = printer;
   5.113 +    }
   5.114 +
   5.115      /**
   5.116       * An enhanced printer for formatting types/symbols used by
   5.117       * AbstractDiagnosticFormatter. Provides alternate numbering of captured
   5.118 @@ -450,33 +473,14 @@
   5.119       * type referred by a given captured type C contains C itself) which might
   5.120       * lead to infinite loops.
   5.121       */
   5.122 -    protected class FormatterPrinter extends Printer {
   5.123 -
   5.124 -        List<Type> allCaptured = List.nil();
   5.125 -        List<Type> seenCaptured = List.nil();
   5.126 -
   5.127 +    protected Printer printer = new Printer() {
   5.128          @Override
   5.129          protected String localize(Locale locale, String key, Object... args) {
   5.130              return AbstractDiagnosticFormatter.this.localize(locale, key, args);
   5.131          }
   5.132 -
   5.133          @Override
   5.134 -        public String visitCapturedType(CapturedType t, Locale locale) {
   5.135 -            if (seenCaptured.contains(t))
   5.136 -                return localize(locale, "compiler.misc.type.captureof.1",
   5.137 -                    allCaptured.indexOf(t) + 1);
   5.138 -            else {
   5.139 -                try {
   5.140 -                    seenCaptured = seenCaptured.prepend(t);
   5.141 -                    allCaptured = allCaptured.append(t);
   5.142 -                    return localize(locale, "compiler.misc.type.captureof",
   5.143 -                        allCaptured.indexOf(t) + 1,
   5.144 -                        visit(t.wildcard, locale));
   5.145 -                }
   5.146 -                finally {
   5.147 -                    seenCaptured = seenCaptured.tail;
   5.148 -                }
   5.149 -            }
   5.150 +        protected String capturedVarId(CapturedType t, Locale locale) {
   5.151 +            return "" + (allCaptured.indexOf(t) + 1);
   5.152          }
   5.153 -    }
   5.154 +    };
   5.155  }
     6.1 --- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Wed May 20 19:10:06 2009 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Thu May 21 10:56:36 2009 +0100
     6.3 @@ -209,6 +209,7 @@
     6.4  
     6.5      @Override
     6.6      public BasicConfiguration getConfiguration() {
     6.7 +        //the following cast is always safe - see init
     6.8          return (BasicConfiguration)super.getConfiguration();
     6.9      }
    6.10  
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/javac/util/ForwardingDiagnosticFormatter.java	Thu May 21 10:56:36 2009 +0100
     7.3 @@ -0,0 +1,132 @@
     7.4 +/*
     7.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Sun designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Sun in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    7.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    7.26 + * have any questions.
    7.27 + */
    7.28 +package com.sun.tools.javac.util;
    7.29 +
    7.30 +import java.util.Set;
    7.31 +import java.util.Locale;
    7.32 +import javax.tools.Diagnostic;
    7.33 +
    7.34 +import com.sun.tools.javac.api.DiagnosticFormatter;
    7.35 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration;
    7.36 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart;
    7.37 +import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit;
    7.38 +import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind;
    7.39 +
    7.40 +/**
    7.41 + * A delegated diagnostic formatter delegates all formatting
    7.42 + * actions to an underlying formatter (aka the delegated formatter).
    7.43 + */
    7.44 +public class ForwardingDiagnosticFormatter<D extends Diagnostic<?>, F extends DiagnosticFormatter<D>>
    7.45 +        implements DiagnosticFormatter<D> {
    7.46 +
    7.47 +    /**
    7.48 +     * The delegated formatter
    7.49 +     */
    7.50 +    protected F formatter;
    7.51 +
    7.52 +    /*
    7.53 +     * configuration object used by this formatter
    7.54 +     */
    7.55 +    protected ForwardingConfiguration configuration;
    7.56 +
    7.57 +    public ForwardingDiagnosticFormatter(F formatter) {
    7.58 +        this.formatter = formatter;
    7.59 +        this.configuration = new ForwardingConfiguration(formatter.getConfiguration());
    7.60 +    }
    7.61 +
    7.62 +    /**
    7.63 +     * Returns the underlying delegated formatter
    7.64 +     * @return delegate formatter
    7.65 +     */
    7.66 +    public F getDelegatedFormatter() {
    7.67 +        return formatter;
    7.68 +    }
    7.69 +
    7.70 +    public Configuration getConfiguration() {
    7.71 +        return configuration;
    7.72 +    }
    7.73 +
    7.74 +    public boolean displaySource(D diag) {
    7.75 +        return formatter.displaySource(diag);
    7.76 +    }
    7.77 +
    7.78 +    public String format(D diag, Locale l) {
    7.79 +        return formatter.format(diag, l);
    7.80 +    }
    7.81 +
    7.82 +    public String formatKind(D diag, Locale l) {
    7.83 +        return formatter.formatKind(diag, l);
    7.84 +    }
    7.85 +
    7.86 +    public String formatMessage(D diag, Locale l) {
    7.87 +        return formatter.formatMessage(diag, l);
    7.88 +    }
    7.89 +
    7.90 +    public String formatPosition(D diag, PositionKind pk, Locale l) {
    7.91 +        return formatter.formatPosition(diag, pk, l);
    7.92 +    }
    7.93 +
    7.94 +    public String formatSource(D diag, boolean fullname, Locale l) {
    7.95 +        return formatter.formatSource(diag, fullname, l);
    7.96 +    }
    7.97 +
    7.98 +    /**
    7.99 +     * A delegated formatter configuration delegates all configurations settings
   7.100 +     * to an underlying configuration object (aka the delegated configuration).
   7.101 +     */
   7.102 +    public static class ForwardingConfiguration implements DiagnosticFormatter.Configuration {
   7.103 +
   7.104 +        /** The configurationr object to which the forwarding configuration delegates some settings */
   7.105 +        protected Configuration configuration;
   7.106 +
   7.107 +        public ForwardingConfiguration(Configuration configuration) {
   7.108 +            this.configuration = configuration;
   7.109 +        }
   7.110 +
   7.111 +        /**
   7.112 +         * Returns the underlying delegated configuration.
   7.113 +         * @return delegated configuration
   7.114 +         */
   7.115 +        public Configuration getDelegatedConfiguration() {
   7.116 +            return configuration;
   7.117 +        }
   7.118 +
   7.119 +        public int getMultilineLimit(MultilineLimit limit) {
   7.120 +            return configuration.getMultilineLimit(limit);
   7.121 +        }
   7.122 +
   7.123 +        public Set<DiagnosticPart> getVisible() {
   7.124 +            return configuration.getVisible();
   7.125 +        }
   7.126 +
   7.127 +        public void setMultilineLimit(MultilineLimit limit, int value) {
   7.128 +            configuration.setMultilineLimit(limit, value);
   7.129 +        }
   7.130 +
   7.131 +        public void setVisible(Set<DiagnosticPart> diagParts) {
   7.132 +            configuration.setVisible(diagParts);
   7.133 +        }
   7.134 +    }
   7.135 +}
     8.1 --- a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Wed May 20 19:10:06 2009 -0700
     8.2 +++ b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Thu May 21 10:56:36 2009 +0100
     8.3 @@ -124,4 +124,9 @@
     8.4          }
     8.5          return buf.toString();
     8.6      }
     8.7 +
     8.8 +    @Override
     8.9 +    public boolean isRaw() {
    8.10 +        return true;
    8.11 +    }
    8.12  }
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu May 21 10:56:36 2009 +0100
     9.3 @@ -0,0 +1,648 @@
     9.4 +/*
     9.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.  Sun designates this
    9.11 + * particular file as subject to the "Classpath" exception as provided
    9.12 + * by Sun in the LICENSE file that accompanied this code.
    9.13 + *
    9.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.17 + * version 2 for more details (a copy is included in the LICENSE file that
    9.18 + * accompanied this code).
    9.19 + *
    9.20 + * You should have received a copy of the GNU General Public License version
    9.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.23 + *
    9.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    9.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    9.26 + * have any questions.
    9.27 + */
    9.28 +package com.sun.tools.javac.util;
    9.29 +
    9.30 +import java.util.EnumSet;
    9.31 +import java.util.HashMap;
    9.32 +import java.util.LinkedHashMap;
    9.33 +import java.util.Locale;
    9.34 +import java.util.Map;
    9.35 +
    9.36 +import com.sun.tools.javac.code.Kinds;
    9.37 +import com.sun.tools.javac.code.Printer;
    9.38 +import com.sun.tools.javac.code.Symbol;
    9.39 +import com.sun.tools.javac.code.Symbol.*;
    9.40 +import com.sun.tools.javac.code.Symtab;
    9.41 +import com.sun.tools.javac.code.Type;
    9.42 +import com.sun.tools.javac.code.Type.*;
    9.43 +import com.sun.tools.javac.code.Types;
    9.44 +
    9.45 +import static com.sun.tools.javac.code.TypeTags.*;
    9.46 +import static com.sun.tools.javac.code.Flags.*;
    9.47 +import static com.sun.tools.javac.util.LayoutCharacters.*;
    9.48 +import static com.sun.tools.javac.util.RichDiagnosticFormatter.RichConfiguration.*;
    9.49 +
    9.50 +/**
    9.51 + * A rich diagnostic formatter is a formatter that provides better integration
    9.52 + * with javac's type system. A diagostic is first preprocessed in order to keep
    9.53 + * track of each types/symbols in it; after these informations are collected,
    9.54 + * the diagnostic is rendered using a standard formatter, whose type/symbol printer
    9.55 + * has been replaced by a more refined version provided by this rich formatter.
    9.56 + * The rich formatter currently enables three different features: (i) simple class
    9.57 + * names - that is class names are displayed used a non qualified name (thus
    9.58 + * omitting package info) whenever possible - (ii) where clause list - a list of
    9.59 + * additional subdiagnostics that provide specific info about type-variables,
    9.60 + * captured types, intersection types that occur in the diagnostic that is to be
    9.61 + * formatted and (iii) type-variable disambiguation - when the diagnostic refers
    9.62 + * to two different type-variables with the same name, their representation is
    9.63 + * disambiguated by appending an index to the type variable name.
    9.64 + */
    9.65 +public class RichDiagnosticFormatter extends
    9.66 +        ForwardingDiagnosticFormatter<JCDiagnostic, AbstractDiagnosticFormatter> {
    9.67 +
    9.68 +    final Symtab syms;
    9.69 +    final Types types;
    9.70 +    final JCDiagnostic.Factory diags;
    9.71 +    final JavacMessages messages;
    9.72 +
    9.73 +    /* name simplifier used by this formatter */
    9.74 +    ClassNameSimplifier nameSimplifier;
    9.75 +
    9.76 +    /* map for keeping track of a where clause associated to a given type */
    9.77 +    Map<WhereClauseKind, Map<Type, JCDiagnostic>> whereClauses;
    9.78 +
    9.79 +    /** Get the DiagnosticFormatter instance for this context. */
    9.80 +    public static RichDiagnosticFormatter instance(Context context) {
    9.81 +        RichDiagnosticFormatter instance = context.get(RichDiagnosticFormatter.class);
    9.82 +        if (instance == null)
    9.83 +            instance = new RichDiagnosticFormatter(context);
    9.84 +        return instance;
    9.85 +    }
    9.86 +
    9.87 +    protected RichDiagnosticFormatter(Context context) {
    9.88 +        super((AbstractDiagnosticFormatter)Log.instance(context).getDiagnosticFormatter());
    9.89 +        this.formatter.setPrinter(printer);
    9.90 +        this.syms = Symtab.instance(context);
    9.91 +        this.diags = JCDiagnostic.Factory.instance(context);
    9.92 +        this.types = Types.instance(context);
    9.93 +        this.messages = JavacMessages.instance(context);
    9.94 +        whereClauses = new LinkedHashMap<WhereClauseKind, Map<Type, JCDiagnostic>>();
    9.95 +        configuration = new RichConfiguration(Options.instance(context), formatter);
    9.96 +        for (WhereClauseKind kind : WhereClauseKind.values())
    9.97 +            whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>());
    9.98 +    }
    9.99 +
   9.100 +    @Override
   9.101 +    public String format(JCDiagnostic diag, Locale l) {
   9.102 +        StringBuilder sb = new StringBuilder();
   9.103 +        nameSimplifier = new ClassNameSimplifier();
   9.104 +        for (WhereClauseKind kind : WhereClauseKind.values())
   9.105 +            whereClauses.get(kind).clear();
   9.106 +        preprocessDiagnostic(diag);
   9.107 +        sb.append(formatter.format(diag, l));
   9.108 +        if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
   9.109 +            List<JCDiagnostic> clauses = getWhereClauses();
   9.110 +            String indent = formatter.isRaw() ? "" :
   9.111 +                formatter.indentString(DetailsInc);
   9.112 +            for (JCDiagnostic d : clauses) {
   9.113 +                String whereClause = formatter.format(d, l);
   9.114 +                if (whereClause.length() > 0) {
   9.115 +                    sb.append('\n' + indent + whereClause);
   9.116 +                }
   9.117 +            }
   9.118 +        }
   9.119 +        return sb.toString();
   9.120 +    }
   9.121 +
   9.122 +    /**
   9.123 +     * Preprocess a given diagnostic by looking both into its arguments and into
   9.124 +     * its subdiagnostics (if any). This preprocessing is responsible for
   9.125 +     * generating info corresponding to features like where clauses, name
   9.126 +     * simplification, etc.
   9.127 +     *
   9.128 +     * @param diag the diagnostic to be preprocessed
   9.129 +     */
   9.130 +    protected void preprocessDiagnostic(JCDiagnostic diag) {
   9.131 +        for (Object o : diag.getArgs()) {
   9.132 +            if (o != null) {
   9.133 +                preprocessArgument(o);
   9.134 +            }
   9.135 +        }
   9.136 +        if (diag.isMultiline()) {
   9.137 +            for (JCDiagnostic d : diag.getSubdiagnostics())
   9.138 +                preprocessDiagnostic(d);
   9.139 +        }
   9.140 +    }
   9.141 +
   9.142 +    /**
   9.143 +     * Preprocess a diagnostic argument. A type/symbol argument is
   9.144 +     * preprocessed by specialized type/symbol preprocessors.
   9.145 +     *
   9.146 +     * @param arg the argument to be translated
   9.147 +     */
   9.148 +    protected void preprocessArgument(Object arg) {
   9.149 +        if (arg instanceof Type) {
   9.150 +            preprocessType((Type)arg);
   9.151 +        }
   9.152 +        else if (arg instanceof Symbol) {
   9.153 +            preprocessSymbol((Symbol)arg);
   9.154 +        }
   9.155 +        else if (arg instanceof JCDiagnostic) {
   9.156 +            preprocessDiagnostic((JCDiagnostic)arg);
   9.157 +        }
   9.158 +        else if (arg instanceof Iterable<?>) {
   9.159 +            for (Object o : (Iterable<?>)arg) {
   9.160 +                preprocessArgument(o);
   9.161 +            }
   9.162 +        }
   9.163 +    }
   9.164 +
   9.165 +    /**
   9.166 +     * Build a list of multiline diagnostics containing detailed info about
   9.167 +     * type-variables, captured types, and intersection types
   9.168 +     *
   9.169 +     * @return where clause list
   9.170 +     */
   9.171 +    protected List<JCDiagnostic> getWhereClauses() {
   9.172 +        List<JCDiagnostic> clauses = List.nil();
   9.173 +        for (WhereClauseKind kind : WhereClauseKind.values()) {
   9.174 +            List<JCDiagnostic> lines = List.nil();
   9.175 +            for (Map.Entry<Type, JCDiagnostic> entry : whereClauses.get(kind).entrySet()) {
   9.176 +                lines = lines.prepend(entry.getValue());
   9.177 +            }
   9.178 +            if (!lines.isEmpty()) {
   9.179 +                String key = kind.key();
   9.180 +                if (lines.size() > 1)
   9.181 +                    key += ".1";
   9.182 +                JCDiagnostic d = diags.fragment(key, whereClauses.get(kind).keySet());
   9.183 +                d = new JCDiagnostic.MultilineDiagnostic(d, lines.reverse());
   9.184 +                clauses = clauses.prepend(d);
   9.185 +            }
   9.186 +        }
   9.187 +        return clauses.reverse();
   9.188 +    }
   9.189 +    //where
   9.190 +    /**
   9.191 +     * This enum defines all posssible kinds of where clauses that can be
   9.192 +     * attached by a rich diagnostic formatter to a given diagnostic
   9.193 +     */
   9.194 +    enum WhereClauseKind {
   9.195 +
   9.196 +        /** where clause regarding a type variable */
   9.197 +        TYPEVAR("where.description.typevar"),
   9.198 +        /** where clause regarding a captured type */
   9.199 +        CAPTURED("where.description.captured"),
   9.200 +        /** where clause regarding an intersection type */
   9.201 +        INTERSECTION("where.description.intersection");
   9.202 +
   9.203 +        /** resource key for this where clause kind */
   9.204 +        private String key;
   9.205 +
   9.206 +        WhereClauseKind(String key) {
   9.207 +            this.key = key;
   9.208 +        }
   9.209 +
   9.210 +        String key() {
   9.211 +            return key;
   9.212 +        }
   9.213 +    }
   9.214 +
   9.215 +    // <editor-fold defaultstate="collapsed" desc="name simplifier">
   9.216 +    /**
   9.217 +     * A name simplifier keeps track of class names usages in order to determine
   9.218 +     * whether a class name can be compacted or not. Short names are not used
   9.219 +     * if a conflict is detected, e.g. when two classes with the same simple
   9.220 +     * name belong to different packages - in this case the formatter reverts
   9.221 +     * to fullnames as compact names might lead to a confusing diagnostic.
   9.222 +     */
   9.223 +    class ClassNameSimplifier {
   9.224 +
   9.225 +        /* table for keeping track of all short name usages */
   9.226 +        Map<Name, List<Symbol>> nameClashes = new HashMap<Name, List<Symbol>>();
   9.227 +
   9.228 +        /**
   9.229 +         * Add a name usage to the simplifier's internal cache
   9.230 +         */
   9.231 +        protected void addUsage(Symbol sym) {
   9.232 +            Name n = sym.getSimpleName();
   9.233 +            List<Symbol> conflicts = nameClashes.get(n);
   9.234 +            if (conflicts == null) {
   9.235 +                conflicts = List.nil();
   9.236 +            }
   9.237 +            if (!conflicts.contains(sym))
   9.238 +                nameClashes.put(n, conflicts.append(sym));
   9.239 +        }
   9.240 +
   9.241 +        public String simplify(Symbol s) {
   9.242 +            String name = s.getQualifiedName().toString();
   9.243 +            if (!s.type.isCompound()) {
   9.244 +                List<Symbol> conflicts = nameClashes.get(s.getSimpleName());
   9.245 +                if (conflicts == null ||
   9.246 +                    (conflicts.size() == 1 &&
   9.247 +                    conflicts.contains(s))) {
   9.248 +                    List<Name> l = List.nil();
   9.249 +                    Symbol s2 = s;
   9.250 +                    while (s2.type.getEnclosingType().tag == CLASS
   9.251 +                            && s2.owner.kind == Kinds.TYP) {
   9.252 +                        l = l.prepend(s2.getSimpleName());
   9.253 +                        s2 = s2.owner;
   9.254 +                    }
   9.255 +                    l = l.prepend(s2.getSimpleName());
   9.256 +                    StringBuilder buf = new StringBuilder();
   9.257 +                    String sep = "";
   9.258 +                    for (Name n2 : l) {
   9.259 +                        buf.append(sep);
   9.260 +                        buf.append(n2);
   9.261 +                        sep = ".";
   9.262 +                    }
   9.263 +                    name = buf.toString();
   9.264 +                }
   9.265 +            }
   9.266 +            return name;
   9.267 +        }
   9.268 +    };
   9.269 +    // </editor-fold>
   9.270 +
   9.271 +    // <editor-fold defaultstate="collapsed" desc="rich printer">
   9.272 +    /**
   9.273 +     * Enhanced type/symbol printer that provides support for features like simple names
   9.274 +     * and type variable disambiguation. This enriched printer exploits the info
   9.275 +     * discovered during type/symbol preprocessing. This printer is set on the delegate
   9.276 +     * formatter so that rich type/symbol info can be properly rendered.
   9.277 +     */
   9.278 +    protected Printer printer = new Printer() {
   9.279 +
   9.280 +        @Override
   9.281 +        public String localize(Locale locale, String key, Object... args) {
   9.282 +            return formatter.localize(locale, key, args);
   9.283 +        }
   9.284 +
   9.285 +        @Override
   9.286 +        public String capturedVarId(CapturedType t, Locale locale) {
   9.287 +            return indexOf(t, WhereClauseKind.CAPTURED) + "";
   9.288 +        }
   9.289 +
   9.290 +        @Override
   9.291 +        public String visitType(Type t, Locale locale) {
   9.292 +            String s = super.visitType(t, locale);
   9.293 +            if (t == syms.botType)
   9.294 +                s = localize(locale, "compiler.misc.type.null");
   9.295 +            return s;
   9.296 +        }
   9.297 +
   9.298 +        @Override
   9.299 +        public String visitCapturedType(CapturedType t, Locale locale) {
   9.300 +            if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
   9.301 +                return localize(locale,
   9.302 +                    "compiler.misc.captured.type",
   9.303 +                    indexOf(t, WhereClauseKind.CAPTURED));
   9.304 +            }
   9.305 +            else
   9.306 +                return super.visitCapturedType(t, locale);
   9.307 +        }
   9.308 +
   9.309 +        @Override
   9.310 +        public String visitClassType(ClassType t, Locale locale) {
   9.311 +            if (t.isCompound() &&
   9.312 +                    getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
   9.313 +                return localize(locale,
   9.314 +                        "compiler.misc.intersection.type",
   9.315 +                        indexOf(t, WhereClauseKind.INTERSECTION));
   9.316 +            }
   9.317 +            else
   9.318 +                return super.visitClassType(t, locale);
   9.319 +        }
   9.320 +
   9.321 +        @Override
   9.322 +        protected String className(ClassType t, boolean longform, Locale locale) {
   9.323 +            Symbol sym = t.tsym;
   9.324 +            if (sym.name.length() == 0 ||
   9.325 +                    !getConfiguration().isEnabled(RichFormatterFeature.SIMPLE_NAMES)) {
   9.326 +                return super.className(t, longform, locale);
   9.327 +            }
   9.328 +            else if (longform)
   9.329 +                return nameSimplifier.simplify(sym).toString();
   9.330 +            else
   9.331 +                return sym.name.toString();
   9.332 +        }
   9.333 +
   9.334 +        @Override
   9.335 +        public String visitTypeVar(TypeVar t, Locale locale) {
   9.336 +            if (unique(t) ||
   9.337 +                    !getConfiguration().isEnabled(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES)) {
   9.338 +                return t.toString();
   9.339 +            }
   9.340 +            else {
   9.341 +                return localize(locale,
   9.342 +                        "compiler.misc.type.var",
   9.343 +                        t.toString(), indexOf(t, WhereClauseKind.TYPEVAR));
   9.344 +            }
   9.345 +        }
   9.346 +
   9.347 +        private int indexOf(Type type, WhereClauseKind kind) {
   9.348 +            int index = 0;
   9.349 +            boolean found = false;
   9.350 +            for (Type t : whereClauses.get(kind).keySet()) {
   9.351 +                if (t == type) {
   9.352 +                    found = true;
   9.353 +                    break;
   9.354 +                }
   9.355 +                index++;
   9.356 +            }
   9.357 +            if (!found)
   9.358 +                throw new AssertionError("Missing symbol in where clause " + type);
   9.359 +            return index + 1;
   9.360 +        }
   9.361 +
   9.362 +        private boolean unique(TypeVar typevar) {
   9.363 +            int found = 0;
   9.364 +            for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) {
   9.365 +                if (t.toString().equals(typevar.toString())) {
   9.366 +                    found++;
   9.367 +                }
   9.368 +            }
   9.369 +            if (found < 1)
   9.370 +                throw new AssertionError("Missing type variable in where clause " + typevar);
   9.371 +            return found == 1;
   9.372 +        }
   9.373 +
   9.374 +        @Override
   9.375 +        protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
   9.376 +            return super.printMethodArgs(args, varArgs, locale);
   9.377 +        }
   9.378 +
   9.379 +        @Override
   9.380 +        public String visitClassSymbol(ClassSymbol s, Locale locale) {
   9.381 +            String name = nameSimplifier.simplify(s);
   9.382 +            if (name.length() == 0 ||
   9.383 +                    !getConfiguration().isEnabled(RichFormatterFeature.SIMPLE_NAMES)) {
   9.384 +                return super.visitClassSymbol(s, locale);
   9.385 +            }
   9.386 +            else {
   9.387 +                return name;
   9.388 +            }
   9.389 +        }
   9.390 +
   9.391 +        @Override
   9.392 +        public String visitMethodSymbol(MethodSymbol s, Locale locale) {
   9.393 +            String ownerName = visit(s.owner, locale);
   9.394 +            if ((s.flags() & BLOCK) != 0) {
   9.395 +               return ownerName;
   9.396 +            } else {
   9.397 +                String ms = (s.name == s.name.table.names.init)
   9.398 +                    ? ownerName
   9.399 +                    : s.name.toString();
   9.400 +                if (s.type != null) {
   9.401 +                    if (s.type.tag == FORALL) {
   9.402 +                        ms = "<" + visitTypes(s.type.getTypeArguments(), locale) + ">" + ms;
   9.403 +                    }
   9.404 +                    ms += "(" + printMethodArgs(
   9.405 +                            s.type.getParameterTypes(),
   9.406 +                            (s.flags() & VARARGS) != 0,
   9.407 +                            locale) + ")";
   9.408 +                }
   9.409 +                return ms;
   9.410 +            }
   9.411 +        }
   9.412 +    };
   9.413 +    // </editor-fold>
   9.414 +
   9.415 +    // <editor-fold defaultstate="collapsed" desc="type scanner">
   9.416 +    /**
   9.417 +     * Preprocess a given type looking for (i) additional info (where clauses) to be
   9.418 +     * added to the main diagnostic (ii) names to be compacted.
   9.419 +     */
   9.420 +    protected void preprocessType(Type t) {
   9.421 +        typePreprocessor.visit(t);
   9.422 +    }
   9.423 +    //where
   9.424 +    protected Types.UnaryVisitor<Void> typePreprocessor =
   9.425 +            new Types.UnaryVisitor<Void>() {
   9.426 +
   9.427 +        public Void visit(List<Type> ts) {
   9.428 +            for (Type t : ts)
   9.429 +                visit(t);
   9.430 +            return null;
   9.431 +        }
   9.432 +
   9.433 +        @Override
   9.434 +        public Void visitForAll(ForAll t, Void ignored) {
   9.435 +            visit(t.tvars);
   9.436 +            visit(t.qtype);
   9.437 +            return null;
   9.438 +        }
   9.439 +
   9.440 +        @Override
   9.441 +        public Void visitMethodType(MethodType t, Void ignored) {
   9.442 +            visit(t.argtypes);
   9.443 +            visit(t.restype);
   9.444 +            return null;
   9.445 +        }
   9.446 +
   9.447 +        @Override
   9.448 +        public Void visitErrorType(ErrorType t, Void ignored) {
   9.449 +            Type ot = t.getOriginalType();
   9.450 +            if (ot != null)
   9.451 +                visit(ot);
   9.452 +            return null;
   9.453 +        }
   9.454 +
   9.455 +        @Override
   9.456 +        public Void visitArrayType(ArrayType t, Void ignored) {
   9.457 +            visit(t.elemtype);
   9.458 +            return null;
   9.459 +        }
   9.460 +
   9.461 +        @Override
   9.462 +        public Void visitWildcardType(WildcardType t, Void ignored) {
   9.463 +            visit(t.type);
   9.464 +            return null;
   9.465 +        }
   9.466 +
   9.467 +        public Void visitType(Type t, Void ignored) {
   9.468 +            return null;
   9.469 +        }
   9.470 +
   9.471 +        @Override
   9.472 +        public Void visitCapturedType(CapturedType t, Void ignored) {
   9.473 +            if (!whereClauses.get(WhereClauseKind.CAPTURED).containsKey(t)) {
   9.474 +                String suffix = t.lower == syms.botType ? ".1" : "";
   9.475 +                JCDiagnostic d = diags.fragment("where.captured"+ suffix, t, t.bound, t.lower, t.wildcard);
   9.476 +                whereClauses.get(WhereClauseKind.CAPTURED).put(t, d);
   9.477 +                visit(t.wildcard);
   9.478 +                visit(t.lower);
   9.479 +                visit(t.bound);
   9.480 +            }
   9.481 +            return null;
   9.482 +        }
   9.483 +
   9.484 +        @Override
   9.485 +        public Void visitClassType(ClassType t, Void ignored) {
   9.486 +            if (t.isCompound()) {
   9.487 +                if (!whereClauses.get(WhereClauseKind.INTERSECTION).containsKey(t)) {
   9.488 +                    Type supertype = types.supertype(t);
   9.489 +                    List<Type> interfaces = types.interfaces(t);
   9.490 +                    JCDiagnostic d = diags.fragment("where.intersection", t, interfaces.prepend(supertype));
   9.491 +                    whereClauses.get(WhereClauseKind.INTERSECTION).put(t, d);
   9.492 +                    visit(supertype);
   9.493 +                    visit(interfaces);
   9.494 +                }
   9.495 +            }
   9.496 +            nameSimplifier.addUsage(t.tsym);
   9.497 +            visit(t.getTypeArguments());
   9.498 +            if (t.getEnclosingType() != Type.noType)
   9.499 +                visit(t.getEnclosingType());
   9.500 +            return null;
   9.501 +        }
   9.502 +
   9.503 +        @Override
   9.504 +        public Void visitTypeVar(TypeVar t, Void ignored) {
   9.505 +            if (!whereClauses.get(WhereClauseKind.TYPEVAR).containsKey(t)) {
   9.506 +                Type bound = t.bound;
   9.507 +                while ((bound instanceof ErrorType))
   9.508 +                    bound = ((ErrorType)bound).getOriginalType();
   9.509 +                List<Type> bounds  = types.getBounds(t);
   9.510 +                nameSimplifier.addUsage(t.tsym);
   9.511 +
   9.512 +                boolean boundErroneous = bounds.head == null ||
   9.513 +                                         bounds.head.tag == NONE ||
   9.514 +                                         bounds.head.tag == ERROR;
   9.515 +
   9.516 +
   9.517 +                JCDiagnostic d = diags.fragment("where.typevar" +
   9.518 +                        (boundErroneous ? ".1" : ""), t, bounds,
   9.519 +                        Kinds.kindName(t.tsym.location()), t.tsym.location());
   9.520 +                whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
   9.521 +                symbolPreprocessor.visit(t.tsym.location(), null);
   9.522 +                visit(bounds);
   9.523 +            }
   9.524 +            return null;
   9.525 +        }
   9.526 +    };
   9.527 +    // </editor-fold>
   9.528 +
   9.529 +    // <editor-fold defaultstate="collapsed" desc="symbol scanner">
   9.530 +    /**
   9.531 +     * Preprocess a given symbol looking for (i) additional info (where clauses) to be
   9.532 +     * asdded to the main diagnostic (ii) names to be compacted
   9.533 +     */
   9.534 +    protected void preprocessSymbol(Symbol s) {
   9.535 +        symbolPreprocessor.visit(s, null);
   9.536 +    }
   9.537 +    //where
   9.538 +    protected Types.DefaultSymbolVisitor<Void, Void> symbolPreprocessor =
   9.539 +            new Types.DefaultSymbolVisitor<Void, Void>() {
   9.540 +
   9.541 +        @Override
   9.542 +        public Void visitClassSymbol(ClassSymbol s, Void ignored) {
   9.543 +            nameSimplifier.addUsage(s);
   9.544 +            return null;
   9.545 +        }
   9.546 +
   9.547 +        @Override
   9.548 +        public Void visitSymbol(Symbol s, Void ignored) {
   9.549 +            return null;
   9.550 +        }
   9.551 +
   9.552 +        @Override
   9.553 +        public Void visitMethodSymbol(MethodSymbol s, Void ignored) {
   9.554 +            visit(s.owner, null);
   9.555 +            typePreprocessor.visit(s.type);
   9.556 +            return null;
   9.557 +        }
   9.558 +    };
   9.559 +    // </editor-fold>
   9.560 +
   9.561 +    @Override
   9.562 +    public RichConfiguration getConfiguration() {
   9.563 +        //the following cast is always safe - see init
   9.564 +        return (RichConfiguration)configuration;
   9.565 +    }
   9.566 +
   9.567 +    /**
   9.568 +     * Configuration object provided by the rich formatter.
   9.569 +     */
   9.570 +    public static class RichConfiguration extends ForwardingDiagnosticFormatter.ForwardingConfiguration {
   9.571 +
   9.572 +        /** set of enabled rich formatter's features */
   9.573 +        protected java.util.EnumSet<RichFormatterFeature> features;
   9.574 +
   9.575 +        @SuppressWarnings("fallthrough")
   9.576 +        public RichConfiguration(Options options, AbstractDiagnosticFormatter formatter) {
   9.577 +            super(formatter.getConfiguration());
   9.578 +            features = formatter.isRaw() ? EnumSet.noneOf(RichFormatterFeature.class) :
   9.579 +                EnumSet.of(RichFormatterFeature.SIMPLE_NAMES,
   9.580 +                    RichFormatterFeature.WHERE_CLAUSES,
   9.581 +                    RichFormatterFeature.UNIQUE_TYPEVAR_NAMES);
   9.582 +            String diagOpts = options.get("diags");
   9.583 +            if (diagOpts != null) {
   9.584 +                for (String args: diagOpts.split(",")) {
   9.585 +                    if (args.equals("-where")) {
   9.586 +                        features.remove(RichFormatterFeature.WHERE_CLAUSES);
   9.587 +                    }
   9.588 +                    else if (args.equals("where")) {
   9.589 +                        features.add(RichFormatterFeature.WHERE_CLAUSES);
   9.590 +                    }
   9.591 +                    if (args.equals("-simpleNames")) {
   9.592 +                        features.remove(RichFormatterFeature.SIMPLE_NAMES);
   9.593 +                    }
   9.594 +                    else if (args.equals("simpleNames")) {
   9.595 +                        features.add(RichFormatterFeature.SIMPLE_NAMES);
   9.596 +                    }
   9.597 +                    if (args.equals("-disambiguateTvars")) {
   9.598 +                        features.remove(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES);
   9.599 +                    }
   9.600 +                    else if (args.equals("disambiguateTvars")) {
   9.601 +                        features.add(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES);
   9.602 +                    }
   9.603 +                }
   9.604 +            }
   9.605 +        }
   9.606 +
   9.607 +        /**
   9.608 +         * Returns a list of all the features supported by the rich formatter.
   9.609 +         * @return list of supported features
   9.610 +         */
   9.611 +        public RichFormatterFeature[] getAvailableFeatures() {
   9.612 +            return RichFormatterFeature.values();
   9.613 +        }
   9.614 +
   9.615 +        /**
   9.616 +         * Enable a specific feature on this rich formatter.
   9.617 +         * @param feature feature to be enabled
   9.618 +         */
   9.619 +        public void enable(RichFormatterFeature feature) {
   9.620 +            features.add(feature);
   9.621 +        }
   9.622 +
   9.623 +        /**
   9.624 +         * Disable a specific feature on this rich formatter.
   9.625 +         * @param feature feature to be disabled
   9.626 +         */
   9.627 +        public void disable(RichFormatterFeature feature) {
   9.628 +            features.remove(feature);
   9.629 +        }
   9.630 +
   9.631 +        /**
   9.632 +         * Is a given feature enabled on this formatter?
   9.633 +         * @param feature feature to be tested
   9.634 +         */
   9.635 +        public boolean isEnabled(RichFormatterFeature feature) {
   9.636 +            return features.contains(feature);
   9.637 +        }
   9.638 +
   9.639 +        /**
   9.640 +         * The advanced formatting features provided by the rich formatter
   9.641 +         */
   9.642 +        public enum RichFormatterFeature {
   9.643 +            /** a list of additional info regarding a given type/symbol */
   9.644 +            WHERE_CLAUSES,
   9.645 +            /** full class names simplification (where possible) */
   9.646 +            SIMPLE_NAMES,
   9.647 +            /** type-variable names disambiguation */
   9.648 +            UNIQUE_TYPEVAR_NAMES;
   9.649 +        }
   9.650 +    }
   9.651 +}
    10.1 --- a/test/tools/javac/6304921/T6304921.java	Wed May 20 19:10:06 2009 -0700
    10.2 +++ b/test/tools/javac/6304921/T6304921.java	Thu May 21 10:56:36 2009 +0100
    10.3 @@ -1,7 +1,7 @@
    10.4  /*
    10.5   * @test (important: no SCCS keywords to affect offsets in golden file.)  /nodynamiccopyright/
    10.6   * @bug 6304921
    10.7 - * @compile/fail/ref=T6304921.out -XDstdout -XDcompilePolicy=bytodo -XDdiags=%b:%s/%o/%e:%_%t%m|%p%m -Xjcov -Xlint:all,-path -Werror T6304921.java
    10.8 + * @compile/fail/ref=T6304921.out -XDstdout -XDcompilePolicy=bytodo -XDrawDiagnostics -Xjcov -Xlint:all,-path -Werror T6304921.java
    10.9   */
   10.10  
   10.11  import java.util.ArrayList;
    11.1 --- a/test/tools/javac/6304921/T6304921.out	Wed May 20 19:10:06 2009 -0700
    11.2 +++ b/test/tools/javac/6304921/T6304921.out	Thu May 21 10:56:36 2009 +0100
    11.3 @@ -1,20 +1,7 @@
    11.4 -T6304921.java:671/671/680: warning: [rawtypes] found raw type: java.util.ArrayList
    11.5 -        List<Integer> list = new ArrayList();
    11.6 -                                 ^
    11.7 -  missing type parameters for generic class java.util.ArrayList<E>
    11.8 -T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
    11.9 -        List<Integer> list = new ArrayList();
   11.10 -                             ^
   11.11 -  required: java.util.List<java.lang.Integer>
   11.12 -  found:    java.util.ArrayList
   11.13 -error: warnings found and -Werror specified
   11.14 -T6304921.java:727/733/737: cannot find symbol
   11.15 -        System.orr.println("abc"); // name not found
   11.16 -              ^
   11.17 -  symbol:   variable orr
   11.18 -  location: class java.lang.System
   11.19 -T6304921.java:812/816/822: operator + cannot be applied to int,boolean
   11.20 -        return 123 + true; // bad binary expression
   11.21 -                   ^
   11.22 +T6304921.java:29:34: compiler.warn.raw.class.use: java.util.ArrayList, java.util.ArrayList<E>
   11.23 +T6304921.java:29:30: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.ArrayList, java.util.List<java.lang.Integer>
   11.24 +- compiler.err.warnings.and.werror
   11.25 +T6304921.java:35:15: compiler.err.cant.resolve.location: kindname.variable, orr, , , kindname.class, java.lang.System
   11.26 +T6304921.java:38:20: compiler.err.operator.cant.be.applied: +, int,boolean
   11.27  3 errors
   11.28  2 warnings
    12.1 --- a/test/tools/javac/6491592/T6491592.out	Wed May 20 19:10:06 2009 -0700
    12.2 +++ b/test/tools/javac/6491592/T6491592.out	Thu May 21 10:56:36 2009 +0100
    12.3 @@ -1,2 +1,2 @@
    12.4 -T6491592.java:12:11: compiler.err.operator.cant.be.applied: +, java.lang.Object,<nulltype>
    12.5 +T6491592.java:12:11: compiler.err.operator.cant.be.applied: +, java.lang.Object,compiler.misc.type.null
    12.6  1 error
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234a.java	Thu May 21 10:56:36 2009 +0100
    13.3 @@ -0,0 +1,38 @@
    13.4 +/*
    13.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   13.24 + * have any questions.
   13.25 + */
   13.26 +
   13.27 +/**
   13.28 + * @test
   13.29 + * @bug     6722234
   13.30 + * @summary javac diagnostics need better integration with the type-system
   13.31 + * @author  mcimadamore
   13.32 + * @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics -XDdiags=disambiguateTvars T6722234a.java
   13.33 + * @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6722234a.java
   13.34 + */
   13.35 +
   13.36 +class T6722234a<T extends String> {
   13.37 +    <T extends Integer> void test(T t) {
   13.38 +        m(t);
   13.39 +    }
   13.40 +    void m(T t) {}
   13.41 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Thu May 21 10:56:36 2009 +0100
    14.3 @@ -0,0 +1,2 @@
    14.4 +T6722234a.java:35:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null
    14.5 +1 error
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Thu May 21 10:56:36 2009 +0100
    15.3 @@ -0,0 +1,3 @@
    15.4 +T6722234a.java:35:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null
    15.5 +- compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, <compiler.misc.type.var: T, 2>test(compiler.misc.type.var: T, 2))}
    15.6 +1 error
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b.java	Thu May 21 10:56:36 2009 +0100
    16.3 @@ -0,0 +1,41 @@
    16.4 +/*
    16.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   16.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   16.24 + * have any questions.
   16.25 + */
   16.26 +
   16.27 +/**
   16.28 + * @test
   16.29 + * @bug     6722234
   16.30 + * @summary javac diagnostics need better integration with the type-system
   16.31 + * @author  mcimadamore
   16.32 + * @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics -XDdiags=simpleNames T6722234b.java
   16.33 + * @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics -XDdiags=simpleNames,where T6722234b.java
   16.34 + */
   16.35 +
   16.36 +import java.util.*;
   16.37 +
   16.38 +class T6722234b {
   16.39 +    <T> void m(List<T> l1, List<T> l2) {}
   16.40 +
   16.41 +    void test(List<? extends T6722234b> list) {
   16.42 +        m(list, list);
   16.43 +    }
   16.44 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Thu May 21 10:56:36 2009 +0100
    17.3 @@ -0,0 +1,2 @@
    17.4 +T6722234b.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, null
    17.5 +1 error
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Thu May 21 10:56:36 2009 +0100
    18.3 @@ -0,0 +1,4 @@
    18.4 +T6722234b.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, null
    18.5 +- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))}
    18.6 +- compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)}
    18.7 +1 error
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234c.java	Thu May 21 10:56:36 2009 +0100
    19.3 @@ -0,0 +1,39 @@
    19.4 +/*
    19.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   19.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   19.24 + * have any questions.
   19.25 + */
   19.26 +
   19.27 +/**
   19.28 + * @test
   19.29 + * @bug     6722234
   19.30 + * @summary javac diagnostics need better integration with the type-system
   19.31 + * @author  mcimadamore
   19.32 + * @compile/fail/ref=T6722234c.out -XDrawDiagnostics -XDdiags=simpleNames T6722234c.java
   19.33 + */
   19.34 +
   19.35 +class T6722234c {
   19.36 +    static class String {}
   19.37 +    <T> void m(String s2) {}
   19.38 +
   19.39 +    void test() {
   19.40 +        m("");
   19.41 +    }
   19.42 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out	Thu May 21 10:56:36 2009 +0100
    20.3 @@ -0,0 +1,2 @@
    20.4 +T6722234c.java:37:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, null
    20.5 +1 error
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234d.java	Thu May 21 10:56:36 2009 +0100
    21.3 @@ -0,0 +1,44 @@
    21.4 +/*
    21.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   21.24 + * have any questions.
   21.25 + */
   21.26 +
   21.27 +/**
   21.28 + * @test
   21.29 + * @bug     6722234
   21.30 + * @summary javac diagnostics need better integration with the type-system
   21.31 + * @author  mcimadamore
   21.32 + * @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics -XDdiags=where T6722234d.java
   21.33 + * @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics -XDdiags=where,simpleNames T6722234d.java
   21.34 + */
   21.35 +
   21.36 +class T6722234d {
   21.37 +    interface I1 {}
   21.38 +    interface I2 {}
   21.39 +    class A implements I1, I2 {}
   21.40 +    class B implements I1, I2 {}
   21.41 +    class Test {
   21.42 +        <Z> Z m(Z z1, Z z2) { return null; }
   21.43 +        void main(){
   21.44 +            A a = m(new A(), new B());
   21.45 +        }
   21.46 +    }
   21.47 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234d_1.out	Thu May 21 10:56:36 2009 +0100
    22.3 @@ -0,0 +1,3 @@
    22.4 +T6722234d.java:41:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A
    22.5 +- compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, java.lang.Object,T6722234d.I1,T6722234d.I2)}
    22.6 +1 error
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234d_2.out	Thu May 21 10:56:36 2009 +0100
    23.3 @@ -0,0 +1,3 @@
    23.4 +T6722234d.java:41:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A
    23.5 +- compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, Object,I1,I2)}
    23.6 +1 error
    24.1 --- a/test/tools/javac/ExtendArray.java	Wed May 20 19:10:06 2009 -0700
    24.2 +++ b/test/tools/javac/ExtendArray.java	Thu May 21 10:56:36 2009 +0100
    24.3 @@ -3,7 +3,7 @@
    24.4   * @bug 4336282 4785453
    24.5   * @summary Verify that extending an erray class does not crash the compiler.
    24.6   *
    24.7 - * @compile/fail/ref=ExtendArray.out -XDstdout -XDdiags=%b:%l:%_%m ExtendArray.java
    24.8 + * @compile/fail/ref=ExtendArray.out -XDstdout -XDrawDiagnostics ExtendArray.java
    24.9   */
   24.10  
   24.11  // Note that an error is expected, but not a crash.
    25.1 --- a/test/tools/javac/ExtendArray.out	Wed May 20 19:10:06 2009 -0700
    25.2 +++ b/test/tools/javac/ExtendArray.out	Thu May 21 10:56:36 2009 +0100
    25.3 @@ -1,6 +1,2 @@
    25.4 -ExtendArray.java:11: unexpected type
    25.5 -public class ExtendArray extends Object[] {}
    25.6 -                                       ^
    25.7 -  required: class
    25.8 -  found:    java.lang.Object[]
    25.9 +ExtendArray.java:11:40: compiler.err.type.found.req: java.lang.Object[], (compiler.misc.type.req.class)
   25.10  1 error
    26.1 --- a/test/tools/javac/OverridePosition.java	Wed May 20 19:10:06 2009 -0700
    26.2 +++ b/test/tools/javac/OverridePosition.java	Thu May 21 10:56:36 2009 +0100
    26.3 @@ -4,7 +4,7 @@
    26.4   * @summary "attemping to assign weaker access" message doesn't give method line number
    26.5   * @author Neal Gafter
    26.6   *
    26.7 - * @compile/fail/ref=OverridePosition.out -XDstdout -XDdiags=%b:%l:%_%m OverridePosition.java
    26.8 + * @compile/fail/ref=OverridePosition.out -XDstdout -XDrawDiagnostics OverridePosition.java
    26.9   */
   26.10  
   26.11  package T4524388;
    27.1 --- a/test/tools/javac/OverridePosition.out	Wed May 20 19:10:06 2009 -0700
    27.2 +++ b/test/tools/javac/OverridePosition.out	Thu May 21 10:56:36 2009 +0100
    27.3 @@ -1,7 +1,3 @@
    27.4 -OverridePosition.java:17: method() in T4524388.Testa cannot implement method() in T4524388.Interface; attempting to assign weaker access privileges; was public
    27.5 -    void method() {}
    27.6 -         ^
    27.7 -OverridePosition.java:24: method() in T4524388.A cannot implement method() in T4524388.Interface; attempting to assign weaker access privileges; was public
    27.8 -class B extends A implements Interface {
    27.9 -^
   27.10 +OverridePosition.java:17:10: compiler.err.override.weaker.access: (compiler.misc.cant.implement: method(), T4524388.Testa, method(), T4524388.Interface), public
   27.11 +OverridePosition.java:24:1: compiler.err.override.weaker.access: (compiler.misc.cant.implement: method(), T4524388.A, method(), T4524388.Interface), public
   27.12  2 errors
    28.1 --- a/test/tools/javac/T4093617/T4093617.java	Wed May 20 19:10:06 2009 -0700
    28.2 +++ b/test/tools/javac/T4093617/T4093617.java	Thu May 21 10:56:36 2009 +0100
    28.3 @@ -3,7 +3,7 @@
    28.4   * @bug     4093617
    28.5   * @summary Object has no superclass
    28.6   * @author  Peter von der Ah\u00e9
    28.7 - * @compile/fail/ref=T4093617.out -XDstdout -XDdiags=%b:%l:%_%m T4093617.java
    28.8 + * @compile/fail/ref=T4093617.out -XDstdout -XDrawDiagnostics T4093617.java
    28.9   */
   28.10  
   28.11  package java.lang;
    29.1 --- a/test/tools/javac/T4093617/T4093617.out	Wed May 20 19:10:06 2009 -0700
    29.2 +++ b/test/tools/javac/T4093617/T4093617.out	Thu May 21 10:56:36 2009 +0100
    29.3 @@ -1,4 +1,2 @@
    29.4 -T4093617.java:12: java.lang.Object has no superclass
    29.5 -    Object() { super(); }
    29.6 -               ^
    29.7 +T4093617.java:12:16: compiler.err.no.superclass: java.lang.Object
    29.8  1 error
    30.1 --- a/test/tools/javac/T5003235/T5003235c.java	Wed May 20 19:10:06 2009 -0700
    30.2 +++ b/test/tools/javac/T5003235/T5003235c.java	Thu May 21 10:56:36 2009 +0100
    30.3 @@ -3,7 +3,7 @@
    30.4   * @bug     5003235
    30.5   * @summary Access to private inner classes
    30.6   * @author  Peter von der Ah\u00e9
    30.7 - * @compile/fail/ref=T5003235c.out -XDstdout -XDdiags=%b:%l:%_%m T5003235c.java
    30.8 + * @compile/fail/ref=T5003235c.out -XDstdout -XDrawDiagnostics T5003235c.java
    30.9   */
   30.10  
   30.11  class T5003235c {
    31.1 --- a/test/tools/javac/T5003235/T5003235c.out	Wed May 20 19:10:06 2009 -0700
    31.2 +++ b/test/tools/javac/T5003235/T5003235c.out	Thu May 21 10:56:36 2009 +0100
    31.3 @@ -1,4 +1,2 @@
    31.4 -T5003235c.java:15: T5003235c.B has private access in T5003235c
    31.5 -class C extends T5003235c.B.Inner {}
    31.6 -                         ^
    31.7 +T5003235c.java:15:26: compiler.err.report.access: T5003235c.B, private, T5003235c
    31.8  1 error
    32.1 --- a/test/tools/javac/miranda/T4666866.java	Wed May 20 19:10:06 2009 -0700
    32.2 +++ b/test/tools/javac/miranda/T4666866.java	Thu May 21 10:56:36 2009 +0100
    32.3 @@ -4,7 +4,7 @@
    32.4   * @summary REGRESSION: Generated error message unhelpful for missing methods
    32.5   * @author gafter
    32.6   *
    32.7 - * @compile/fail/ref=T4666866.out -XDstdout -XDdiags=%b:%l:%_%m T4666866.java
    32.8 + * @compile/fail/ref=T4666866.out -XDstdout -XDrawDiagnostics T4666866.java
    32.9   */
   32.10  
   32.11  class t implements Runnable {}
    33.1 --- a/test/tools/javac/miranda/T4666866.out	Wed May 20 19:10:06 2009 -0700
    33.2 +++ b/test/tools/javac/miranda/T4666866.out	Thu May 21 10:56:36 2009 +0100
    33.3 @@ -1,4 +1,2 @@
    33.4 -T4666866.java:10: t is not abstract and does not override abstract method run() in java.lang.Runnable
    33.5 -class t implements Runnable {}
    33.6 -^
    33.7 +T4666866.java:10:1: compiler.err.does.not.override.abstract: t, run(), java.lang.Runnable
    33.8  1 error
    34.1 --- a/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java	Wed May 20 19:10:06 2009 -0700
    34.2 +++ b/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java	Thu May 21 10:56:36 2009 +0100
    34.3 @@ -4,7 +4,7 @@
    34.4   * @summary Verify correct implementation of JLS2e 6.6.2.1
    34.5   * @author maddox
    34.6   *
    34.7 - * @compile/fail/ref=ProtectedMemberAccess2.out -XDstdout -XDdiags=%b:%l:%_%m ProtectedMemberAccess2.java
    34.8 + * @compile/fail/ref=ProtectedMemberAccess2.out -XDstdout -XDdiags=-simpleNames -XDdiagsFormat=%b:%l:%_%m ProtectedMemberAccess2.java
    34.9   */
   34.10  
   34.11  // 71 errors expected.
    35.1 --- a/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java	Wed May 20 19:10:06 2009 -0700
    35.2 +++ b/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java	Thu May 21 10:56:36 2009 +0100
    35.3 @@ -4,7 +4,7 @@
    35.4   * @summary Verify correct implementation of JLS2e 6.6.2.1
    35.5   * @author maddox
    35.6   *
    35.7 - * @compile/fail/ref=ProtectedMemberAccess3.out -XDstdout -XDdiags=%b:%l:%_%m ProtectedMemberAccess3.java
    35.8 + * @compile/fail/ref=ProtectedMemberAccess3.out -XDstdout -XDdiags=-simpleNames -XDdiagsFormat=%b:%l:%_%m ProtectedMemberAccess3.java
    35.9   */
   35.10  
   35.11  // 46 errors expected.
    36.1 --- a/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java	Wed May 20 19:10:06 2009 -0700
    36.2 +++ b/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java	Thu May 21 10:56:36 2009 +0100
    36.3 @@ -4,7 +4,7 @@
    36.4   * @summary Verify correct implementation of JLS2e 6.6.2.1
    36.5   * @author maddox
    36.6   *
    36.7 - * @compile/fail/ref=ProtectedMemberAccess4.out -XDstdout -XDdiags=%b:%l:%_%m ProtectedMemberAccess4.java
    36.8 + * @compile/fail/ref=ProtectedMemberAccess4.out -XDstdout -XDdiags=-simpleNames -XDdiagsFormat=%b:%l:%_%m ProtectedMemberAccess4.java
    36.9   */
   36.10  
   36.11  // 33 errors expected.

mercurial