langtools/src/share/classes/com/sun/tools/javac/main/Main.java
author jjg
Mon, 16 Jun 2008 13:28:00 -0700
changeset 731 1dd22bdb9ca5
parent 10 06bc494ca11e
child 735 372aa565a221
permissions -rw-r--r--
6714364: refactor javac File handling code into new javac.file package Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
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.main;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.File;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.PrintWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.MissingResourceException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.code.Source;
731
1dd22bdb9ca5 6714364: refactor javac File handling code into new javac.file package
jjg
parents: 10
diff changeset
    34
import com.sun.tools.javac.file.JavacFileManager;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import com.sun.tools.javac.jvm.Target;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.tools.javac.main.JavacOption.Option;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.processing.AnnotationProcessingError;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import javax.tools.JavaFileManager;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
import javax.tools.JavaFileObject;
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
import javax.annotation.processing.Processor;
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
/** This class provides a commandline interface to the GJC compiler.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 *  you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
public class Main {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /** The name of the compiler, for use in diagnostics.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    String ownName;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /** The writer to use for diagnostic output.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    PrintWriter out;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * If true, any command line arg errors will cause an exception.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    boolean fatalErrors;
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /** Result codes.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    static final int
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        EXIT_OK = 0,        // Compilation completed with no errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        EXIT_ERROR = 1,     // Completed but reported errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        EXIT_CMDERR = 2,    // Bad command-line arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        EXIT_SYSERR = 3,    // System error or resource exhaustion.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    private Option[] recognizedOptions = RecognizedOptions.getJavaCompilerOptions(new OptionHelper() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        public void setOut(PrintWriter out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            Main.this.out = out;
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        public void error(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            Main.this.error(key, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        public void printVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            Log.printLines(out, getLocalizedString("version", ownName,  JavaCompiler.version()));
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        public void printFullVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            Log.printLines(out, getLocalizedString("fullVersion", ownName,  JavaCompiler.fullVersion()));
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        public void printHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            help();
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        public void printXhelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            xhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        public void addFile(File f) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            if (!filenames.contains(f))
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                filenames.append(f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        public void addClassName(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            classnames.append(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    });
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * Construct a compiler instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    public Main(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        this(name, new PrintWriter(System.err, true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * Construct a compiler instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    public Main(String name, PrintWriter out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        this.ownName = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        this.out = out;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    /** A table of all options that's passed to the JavaCompiler constructor.  */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    private Options options = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    /** The list of source files to process
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public ListBuffer<File> filenames = null; // XXX sb protected
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /** List of class files names passed on the command line
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public ListBuffer<String> classnames = null; // XXX sb protected
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    /** Print a string that explains usage.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    void help() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        Log.printLines(out, getLocalizedString("msg.usage.header", ownName));
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        for (int i=0; i<recognizedOptions.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            recognizedOptions[i].help(out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        out.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    /** Print a string that explains usage for X options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    void xhelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        for (int i=0; i<recognizedOptions.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            recognizedOptions[i].xhelp(out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        out.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        Log.printLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    /** Report a usage error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    void error(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        if (fatalErrors) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            String msg = getLocalizedString(key, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            throw new PropagatedException(new IllegalStateException(msg));
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        warning(key, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        Log.printLines(out, getLocalizedString("msg.usage", ownName));
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /** Report a warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    void warning(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        Log.printLines(out, ownName + ": "
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                       + getLocalizedString(key, args));
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    public Option getOption(String flag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        for (Option option : recognizedOptions) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            if (option.matches(flag))
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                return option;
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    public void setOptions(Options options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        if (options == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
            throw new NullPointerException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        this.options = options;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    public void setFatalErrors(boolean fatalErrors) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        this.fatalErrors = fatalErrors;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    /** Process command line arguments: store all command line options
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     *  in `options' table and return all source filenames.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     *  @param flags    The array of command line arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    public List<File> processArgs(String[] flags) { // XXX sb protected
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        int ac = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        while (ac < flags.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            String flag = flags[ac];
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            ac++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
            Option option = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            if (flag.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                // quick hack to speed up file processing:
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
                // if the option does not begin with '-', there is no need to check
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
                // most of the compiler options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                int firstOptionToCheck = flag.charAt(0) == '-' ? 0 : recognizedOptions.length-1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
                for (int j=firstOptionToCheck; j<recognizedOptions.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
                    if (recognizedOptions[j].matches(flag)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
                        option = recognizedOptions[j];
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                        break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            if (option == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
                error("err.invalid.flag", flag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
                return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
            if (option.hasArg()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                if (ac == flags.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                    error("err.req.arg", flag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                    return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                String operand = flags[ac];
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                ac++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                if (option.process(options, flag, operand))
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
                    return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
                if (option.process(options, flag))
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                    return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        if (!checkDirectory("-d"))
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        if (!checkDirectory("-s"))
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        String sourceString = options.get("-source");
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        Source source = (sourceString != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            ? Source.lookup(sourceString)
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
            : Source.DEFAULT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        String targetString = options.get("-target");
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        Target target = (targetString != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
            ? Target.lookup(targetString)
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
            : Target.DEFAULT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
        // We don't check source/target consistency for CLDC, as J2ME
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
        // profiles are not aligned with J2SE targets; moreover, a
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        // single CLDC target may have many profiles.  In addition,
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        // this is needed for the continued functioning of the JSR14
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        // prototype.
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        if (Character.isDigit(target.name.charAt(0))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
            if (target.compareTo(source.requiredTarget()) < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
                if (targetString != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                    if (sourceString == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
                        warning("warn.target.default.source.conflict",
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                                targetString,
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                                source.requiredTarget().name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
                    } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
                        warning("warn.source.target.conflict",
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
                                sourceString,
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
                                source.requiredTarget().name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
                    return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                    options.put("-target", source.requiredTarget().name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
                if (targetString == null && !source.allowGenerics()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
                    options.put("-target", Target.JDK1_4.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        return filenames.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    // where
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        private boolean checkDirectory(String optName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
            String value = options.get(optName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
            if (value == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            File file = new File(value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
            if (!file.exists()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                error("err.dir.not.found", value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            if (!file.isDirectory()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
                error("err.file.not.directory", value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    /** Programmatic interface for main function.
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * @param args    The command line parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    public int compile(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        Context context = new Context();
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        JavacFileManager.preRegister(context); // can't create it until Log has been set up
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
        int result = compile(args, context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        if (fileManager instanceof JavacFileManager) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            // A fresh context was created above, so jfm must be a JavacFileManager
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
            ((JavacFileManager)fileManager).close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
    public int compile(String[] args, Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        return compile(args, context, List.<JavaFileObject>nil(), null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    /** Programmatic interface for main function.
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * @param args    The command line parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    public int compile(String[] args,
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
                       Context context,
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                       List<JavaFileObject> fileObjects,
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
                       Iterable<? extends Processor> processors)
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
    {
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        if (options == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
            options = Options.instance(context); // creates a new one
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        filenames = new ListBuffer<File>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        classnames = new ListBuffer<String>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        JavaCompiler comp = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        /*
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
         * TODO: Logic below about what is an acceptable command line
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
         * should be updated to take annotation processing semantics
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
         * into account.
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
            if (args.length == 0 && fileObjects.isEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                help();
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                return EXIT_CMDERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
            List<File> filenames;
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                filenames = processArgs(CommandLine.parse(args));
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                if (filenames == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
                    // null signals an error in options, abort
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                    return EXIT_CMDERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                } else if (filenames.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                    // it is allowed to compile nothing if just asking for help or version info
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
                    if (options.get("-help") != null
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
                        || options.get("-X") != null
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
                        || options.get("-version") != null
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
                        || options.get("-fullversion") != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
                        return EXIT_OK;
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
                    error("err.no.source.files");
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
                    return EXIT_CMDERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            } catch (java.io.FileNotFoundException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                Log.printLines(out, ownName + ": " +
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                               getLocalizedString("err.file.not.found",
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                                                  e.getMessage()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            boolean forceStdOut = options.get("stdout") != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
            if (forceStdOut) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                out.flush();
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
                out = new PrintWriter(System.out, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
            context.put(Log.outKey, out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
            fileManager = context.get(JavaFileManager.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
            comp = JavaCompiler.instance(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            if (comp == null) return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            if (!filenames.isEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
                // add filenames to fileObjects
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
                comp = JavaCompiler.instance(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
                List<JavaFileObject> otherFiles = List.nil();
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
                JavacFileManager dfm = (JavacFileManager)fileManager;
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
                for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(filenames))
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
                    otherFiles = otherFiles.prepend(fo);
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
                for (JavaFileObject fo : otherFiles)
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
                    fileObjects = fileObjects.prepend(fo);
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
            comp.compile(fileObjects,
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                         classnames.toList(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
                         processors);
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
            if (comp.errorCount() != 0 ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
                options.get("-Werror") != null && comp.warningCount() != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
                return EXIT_ERROR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
        } catch (IOException ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
            ioMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
            return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
        } catch (OutOfMemoryError ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
            resourceMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
            return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        } catch (StackOverflowError ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
            resourceMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
            return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
        } catch (FatalError ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
            feMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
            return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
        } catch(AnnotationProcessingError ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            apMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
            return EXIT_SYSERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
        } catch (ClientCodeException ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
            // as specified by javax.tools.JavaCompiler#getTask
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
            // and javax.tools.JavaCompiler.CompilationTask#call
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            throw new RuntimeException(ex.getCause());
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
        } catch (PropagatedException ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
            throw ex.getCause();
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
        } catch (Throwable ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            // Nasty.  If we've already reported an error, compensate
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
            // for buggy compiler error recovery by swallowing thrown
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            // exceptions.
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
            if (comp == null || comp.errorCount() == 0 ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
                options == null || options.get("dev") != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
                bugMessage(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
            return EXIT_ABNORMAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        } finally {
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
            if (comp != null) comp.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
            filenames = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
            options = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
        return EXIT_OK;
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
    /** Print a message reporting an internal error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
    void bugMessage(Throwable ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
        Log.printLines(out, getLocalizedString("msg.bug",
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
                                               JavaCompiler.version()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
        ex.printStackTrace(out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
    /** Print a message reporting an fatal error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    void feMessage(Throwable ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        Log.printLines(out, ex.getMessage());
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
    /** Print a message reporting an input/output error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    void ioMessage(Throwable ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        Log.printLines(out, getLocalizedString("msg.io"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
        ex.printStackTrace(out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
    /** Print a message reporting an out-of-resources error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    void resourceMessage(Throwable ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
        Log.printLines(out, getLocalizedString("msg.resource"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
//      System.out.println("(name buffer len = " + Name.names.length + " " + Name.nc);//DEBUG
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        ex.printStackTrace(out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
    /** Print a message reporting an uncaught exception from an
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
     * annotation processor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
    void apMessage(AnnotationProcessingError ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
        Log.printLines(out,
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
                       getLocalizedString("msg.proc.annotation.uncaught.exception"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        ex.getCause().printStackTrace();
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
    private JavaFileManager fileManager;
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
    /* ************************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
     * Internationalization
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
     *************************************************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
    /** Find a localized string in the resource bundle.
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
     *  @param key     The key for the localized string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
    public static String getLocalizedString(String key, Object... args) { // FIXME sb private
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
            if (messages == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
                messages = new Messages(javacBundleName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
            return messages.getLocalizedString("javac." + key, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
        catch (MissingResourceException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
            throw new Error("Fatal Error: Resource for javac is missing", e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
    public static void useRawMessages(boolean enable) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        if (enable) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
            messages = new Messages(javacBundleName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
                    public String getLocalizedString(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
                        return key;
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
                };
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
            messages = new Messages(javacBundleName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
    private static final String javacBundleName =
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        "com.sun.tools.javac.resources.javac";
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
    private static Messages messages;
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
}