langtools/src/share/classes/com/sun/tools/javac/util/Log.java
author mcimadamore
Fri, 13 Feb 2009 11:57:33 +0000
changeset 2085 4792e12a8ca2
parent 1866 734286a0cc38
child 2212 1d3dc0e0ba0c
permissions -rw-r--r--
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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
735
372aa565a221 6719955: Update copyright year
xdono
parents: 731
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.*;
1866
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
    29
import java.util.Arrays;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.HashSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import javax.tools.DiagnosticListener;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import javax.tools.JavaFileObject;
731
1dd22bdb9ca5 6714364: refactor javac File handling code into new javac.file package
jjg
parents: 167
diff changeset
    35
1dd22bdb9ca5 6714364: refactor javac File handling code into new javac.file package
jjg
parents: 167
diff changeset
    36
import com.sun.tools.javac.file.JavacFileManager;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.tree.JCTree;
942
98e1d4f8aacd 6720185: DiagnosticFormatter refactoring
mcimadamore
parents: 867
diff changeset
    38
import com.sun.tools.javac.api.DiagnosticFormatter;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
/** A class for error logs. Reports errors and warnings, and
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *  keeps track of error numbers and positions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *  you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 */
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
    50
public class Log extends AbstractLog {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /** The context key for the log. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public static final Context.Key<Log> logKey
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        = new Context.Key<Log>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /** The context key for the output PrintWriter. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public static final Context.Key<PrintWriter> outKey =
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        new Context.Key<PrintWriter>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    //@Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    public final PrintWriter errWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    //@Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public final PrintWriter warnWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    //@Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    public final PrintWriter noticeWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    /** The maximum number of errors/warnings that are reported.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    public final int MaxErrors;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    public final int MaxWarnings;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /** Switch: prompt user on each error.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    public boolean promptOnError;
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /** Switch: emit warning messages.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    public boolean emitWarnings;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /** Print stack trace on errors?
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public boolean dumpOnError;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /** Print multiple errors for same source locations.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public boolean multipleErrors;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * Diagnostic listener, if provided through programmatic
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * interface to javac (JSR 199).
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    protected DiagnosticListener<? super JavaFileObject> diagListener;
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
    94
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
    96
     * Formatter for diagnostics.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
942
98e1d4f8aacd 6720185: DiagnosticFormatter refactoring
mcimadamore
parents: 867
diff changeset
    98
    private DiagnosticFormatter<JCDiagnostic> diagFormatter;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   100
    /**
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   101
     * Keys for expected diagnostics.
1866
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   102
     */
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   103
    public Set<String> expectDiagKeys;
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   104
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   105
    /**
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   106
     * JavacMessages object used for localization.
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   107
     */
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   108
    private JavacMessages messages;
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   109
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /** Construct a log with given I/O redirections.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    @Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   114
        super(JCDiagnostic.Factory.instance(context));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        context.put(logKey, this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        this.errWriter = errWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        this.warnWriter = warnWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        this.noticeWriter = noticeWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        Options options = Options.instance(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        this.dumpOnError = options.get("-doe") != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        this.promptOnError = options.get("-prompt") != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        this.emitWarnings = options.get("-Xlint:none") == null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        this.MaxErrors = getIntOption(options, "-Xmaxerrs", 100);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        this.MaxWarnings = getIntOption(options, "-Xmaxwarns", 100);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
942
98e1d4f8aacd 6720185: DiagnosticFormatter refactoring
mcimadamore
parents: 867
diff changeset
   127
        boolean rawDiagnostics = options.get("rawDiagnostics") != null;
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   128
        messages = JavacMessages.instance(context);
1472
1e09e143438c 6731573: diagnostic output should optionally include source line
mcimadamore
parents: 1471
diff changeset
   129
        this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   130
                                              new BasicDiagnosticFormatter(options, messages);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        @SuppressWarnings("unchecked") // FIXME
1866
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   132
        DiagnosticListener<? super JavaFileObject> dl =
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
            context.get(DiagnosticListener.class);
1866
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   134
        this.diagListener = dl;
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   135
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   136
        String ek = options.get("expectKeys");
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   137
        if (ek != null)
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   138
            expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    // where
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        private int getIntOption(Options options, String optionName, int defaultValue) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            String s = options.get(optionName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
                if (s != null) return Integer.parseInt(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            } catch (NumberFormatException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                // silently ignore ill-formed numbers
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            return defaultValue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    /** The default writer for diagnostics
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    static final PrintWriter defaultWriter(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        PrintWriter result = context.get(outKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        if (result == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
            context.put(outKey, result = new PrintWriter(System.err));
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /** Construct a log with default settings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    protected Log(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        this(context, defaultWriter(context));
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /** Construct a log with all output redirected.
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    protected Log(Context context, PrintWriter defaultWriter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        this(context, defaultWriter, defaultWriter, defaultWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    /** Get the Log instance for this context. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    public static Log instance(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        Log instance = context.get(logKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        if (instance == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            instance = new Log(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        return instance;
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    /** The number of errors encountered so far.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    public int nerrors = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    /** The number of warnings encountered so far.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public int nwarnings = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /** A set of all errors generated so far. This is used to avoid printing an
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *  error message more than once. For each error, a pair consisting of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     *  source file name and source code position of the error is added to the set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    private Set<Pair<JavaFileObject, Integer>> recorded = new HashSet<Pair<JavaFileObject,Integer>>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    public boolean hasDiagnosticListener() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        return diagListener != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    public void setEndPosTable(JavaFileObject name, Map<JCTree, Integer> table) {
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   199
        name.getClass(); // null check
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   200
        getSource(name).setEndPosTable(table);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
1591
e5a618442f5f 6768932: Add support for multiline diagnostics
mcimadamore
parents: 1472
diff changeset
   203
    /** Return current sourcefile.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     */
1591
e5a618442f5f 6768932: Add support for multiline diagnostics
mcimadamore
parents: 1472
diff changeset
   205
    public JavaFileObject currentSourceFile() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        return source == null ? null : source.getFile();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   209
    /** Get the current diagnostic formatter.
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   210
     */
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   211
    public DiagnosticFormatter<JCDiagnostic> getDiagnosticFormatter() {
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   212
        return diagFormatter;
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   213
    }
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   214
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   215
    /** Set the current diagnostic formatter.
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   216
     */
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   217
    public void setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter) {
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   218
        this.diagFormatter = diagFormatter;
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   219
    }
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1866
diff changeset
   220
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    /** Flush the logs
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public void flush() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        errWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        warnWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        noticeWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    /** Returns true if an error needs to be reported for a given
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     * source name and pos.
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    protected boolean shouldReport(JavaFileObject file, int pos) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        if (multipleErrors || file == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        Pair<JavaFileObject,Integer> coords = new Pair<JavaFileObject,Integer>(file, pos);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        boolean shouldReport = !recorded.contains(coords);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        if (shouldReport)
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            recorded.add(coords);
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        return shouldReport;
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    /** Prompt user after an error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    public void prompt() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        if (promptOnError) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
            System.err.println(getLocalizedString("resume.abort"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
            char ch;
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
                while (true) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
                    switch (System.in.read()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                    case 'a': case 'A':
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
                        System.exit(-1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
                        return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
                    case 'r': case 'R':
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
                        return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
                    case 'x': case 'X':
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
                        throw new AssertionError("user abort");
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                    default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
            } catch (IOException e) {}
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    /** Print the faulty source code line and point to the error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     *  @param pos   Buffer index of the error position, must be on current line
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    private void printErrLine(int pos, PrintWriter writer) {
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   270
        String line = (source == null ? null : source.getLine(pos));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   271
        if (line == null)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
            return;
1109
853d8c191eac 6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents: 942
diff changeset
   273
        int col = source.getColumnNumber(pos, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   275
        printLines(writer, line);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   276
        for (int i = 0; i < col - 1; i++) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   277
            writer.print((line.charAt(i) == '\t') ? "\t" : " ");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        writer.println("^");
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        writer.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    /** Print the text of a message, translating newlines appropriately
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     *  for the platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    public static void printLines(PrintWriter writer, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        int nl;
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        while ((nl = msg.indexOf('\n')) != -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            writer.println(msg.substring(0, nl));
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            msg = msg.substring(nl+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        if (msg.length() != 0) writer.println(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   295
    protected void directError(String key, Object... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   296
        printLines(errWriter, getLocalizedString(key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   297
        errWriter.flush();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    /** Report a warning that cannot be suppressed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     *  @param pos    The source position at which to report the warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     *  @param key    The key for the localized warning message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     *  @param args   Fields of the warning message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    public void strictWarning(DiagnosticPosition pos, String key, Object ... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        writeDiagnostic(diags.warning(source, pos, key, args));
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        nwarnings++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * Common diagnostic handling.
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * The diagnostic is counted, and depending on the options and how many diagnostics have been
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     * reported so far, the diagnostic may be handed off to writeDiagnostic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    public void report(JCDiagnostic diagnostic) {
1866
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   316
        if (expectDiagKeys != null)
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   317
            expectDiagKeys.remove(diagnostic.getCode());
734286a0cc38 6794959: add new switch -XDexpectKeys=key,key....
jjg
parents: 1591
diff changeset
   318
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        switch (diagnostic.getType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        case FRAGMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        case NOTE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
            // Print out notes only when we are permitted to report warnings
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            // Notes are only generated at the end of a compilation, so should be small
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
            // in number.
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
            if (emitWarnings || diagnostic.isMandatory()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                writeDiagnostic(diagnostic);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        case WARNING:
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
            if (emitWarnings || diagnostic.isMandatory()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
                if (nwarnings < MaxWarnings) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
                    writeDiagnostic(diagnostic);
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                    nwarnings++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
            break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        case ERROR:
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
            if (nerrors < MaxErrors
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
                writeDiagnostic(diagnostic);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                nerrors++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
            break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
     * Write out a diagnostic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    protected void writeDiagnostic(JCDiagnostic diag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
        if (diagListener != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                diagListener.report(diag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
            catch (Throwable t) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
                throw new ClientCodeException(t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        PrintWriter writer = getWriterForDiagnosticType(diag.getType());
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   367
        printLines(writer, diagFormatter.format(diag, messages.getCurrentLocale()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
        if (promptOnError) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
            switch (diag.getType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
            case ERROR:
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
            case WARNING:
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
                prompt();
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
        if (dumpOnError)
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
            new RuntimeException().printStackTrace(writer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
        writer.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    @Deprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    protected PrintWriter getWriterForDiagnosticType(DiagnosticType dt) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        switch (dt) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
        case FRAGMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
        case NOTE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
            return noticeWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
        case WARNING:
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
            return warnWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
        case ERROR:
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
            return errWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            throw new Error();
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    /** Find a localized string in the resource bundle.
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
     *  @param key    The key for the localized string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
     *  @param args   Fields to substitute into the string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
    public static String getLocalizedString(String key, Object ... args) {
1471
57506cdfb7b4 6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents: 1109
diff changeset
   408
        return JavacMessages.getDefaultLocalizedString("compiler.misc." + key, args);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
/***************************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
 * raw error messages without internationalization; used for experimentation
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
 * and quick prototyping
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
 ***************************************************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   416
    /** print an error or warning message:
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   417
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
    private void printRawError(int pos, String msg) {
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   419
        if (source == null || pos == Position.NOPOS) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
            printLines(errWriter, "error: " + msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
        } else {
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   422
            int line = source.getLineNumber(pos);
1591
e5a618442f5f 6768932: Add support for multiline diagnostics
mcimadamore
parents: 1472
diff changeset
   423
            JavaFileObject file = source.getFile();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
            if (file != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
                printLines(errWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
                           JavacFileManager.getJavacFileName(file) + ":" +
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
                           line + ": " + msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
            printErrLine(pos, errWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
        errWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   433
    /** report an error:
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   434
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
    public void rawError(int pos, String msg) {
1591
e5a618442f5f 6768932: Add support for multiline diagnostics
mcimadamore
parents: 1472
diff changeset
   436
        if (nerrors < MaxErrors && shouldReport(currentSourceFile(), pos)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
            printRawError(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
            prompt();
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
            nerrors++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        errWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   444
    /** report a warning:
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents: 815
diff changeset
   445
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    public void rawWarning(int pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        if (nwarnings < MaxWarnings && emitWarnings) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
            printRawError(pos, "warning: " + msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
        prompt();
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        nwarnings++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
        errWriter.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
    public static String format(String fmt, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        return String.format((java.util.Locale)null, fmt, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
}