jdk/src/jdk.rmic/share/classes/sun/tools/javac/Main.java
author chegar
Wed, 03 Dec 2014 14:22:58 +0000
changeset 27565 729f9700483a
parent 25859 3317bb8137f4
permissions -rw-r--r--
8049367: Modular Run-Time Images Reviewed-by: chegar, dfuchs, ihse, joehw, mullan, psandoz, wetmore Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, bradford.wetmore@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, james.laskey@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.javac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.tools.java.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.tools.util.CommandLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
// JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.tools.asm.Assembler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
// end JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.text.MessageFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Main program of the Java compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * WARNING: The contents of this source file are not part of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * supported API.  Code that depends on them does so at its own risk:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * they are subject to change or removal without notice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @deprecated As of J2SE 1.3, the preferred way to compile Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * language sources is by using the new compiler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * com.sun.tools.javac.Main.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
@Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
class Main implements Constants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Name of the program.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    String program;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * The stream where error message are printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    OutputStream out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public Main(OutputStream out, String program) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        this.out = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.program = program;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Exit status.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * We introduce a separate integer status variable, and do not alter the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * convention that 'compile' returns a boolean true upon a successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * compilation with no errors.  (JavaTest relies on this.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public static final int EXIT_OK = 0;        // Compilation completed with no errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public static final int EXIT_ERROR = 1;     // Compilation completed but reported errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static final int EXIT_CMDERR = 2;    // Bad command-line arguments and/or switches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static final int EXIT_SYSERR = 3;    // System error or resource exhaustion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public static final int EXIT_ABNORMAL = 4;  // Compiler terminated abnormally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private int exitStatus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public int getExitStatus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return exitStatus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public boolean compilationPerformedSuccessfully() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return exitStatus == EXIT_OK || exitStatus == EXIT_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public boolean compilationReportedErrors () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        return exitStatus != EXIT_OK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Output a message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private void output(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        PrintStream out =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            this.out instanceof PrintStream ? (PrintStream)this.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                            : new PrintStream(this.out, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        out.println(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Top level error message.  This method is called when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * environment could not be set up yet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private void error(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        output(getText(msg));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    private void error(String msg, String arg1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        output(getText(msg, arg1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private void error(String msg, String arg1, String arg2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        output(getText(msg, arg1, arg2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Print usage message and make exit status an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Note: 'javac' invoked without any arguments is considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * be an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public void usage_error() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        error("main.usage", program);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    private static ResourceBundle messageRB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Initialize ResourceBundle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    static void initResource() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            messageRB =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                ResourceBundle.getBundle("sun.tools.javac.resources.javac");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        } catch (MissingResourceException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            throw new Error("Fatal: Resource for javac is missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * get and format message string from resource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public static String getText(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return getText(key, (String)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public static String getText(String key, int num) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return getText(key, Integer.toString(num));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public static String getText(String key, String fixed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return getText(key, fixed, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public static String getText(String key, String fixed1, String fixed2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return getText(key, fixed1, fixed2, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public static String getText(String key, String fixed1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                 String fixed2, String fixed3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (messageRB == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            initResource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            String message = messageRB.getString(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            return MessageFormat.format(message, fixed1, fixed2, fixed3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        } catch (MissingResourceException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            if (fixed1 == null)  fixed1 = "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            if (fixed2 == null)  fixed2 = "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            if (fixed3 == null)  fixed3 = "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            String message = "JAVAC MESSAGE FILE IS BROKEN: key={0}, arguments={1}, {2}, {3}";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            return MessageFormat.format(message, key, fixed1, fixed2, fixed3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    // What major and minor version numbers to use for the -target flag.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    // This should grow every time the minor version number accepted by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    // the VM is incremented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private static final String[] releases =      { "1.1", "1.2", "1.3", "1.4" };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private static final short[] majorVersions =  {    45,    46,    47,    48 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private static final short[] minorVersions =  {     3,     0,     0,     0 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Run the compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
23740
1d63a6c00b26 8039864: Fix fallthrough lint warnings in other libs
darcy
parents: 5506
diff changeset
   195
    @SuppressWarnings("fallthrough")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public synchronized boolean compile(String argv[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        String sourcePathArg = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        String classPathArg = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        String sysClassPathArg = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        boolean verbosePath = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        String targetArg = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        short majorVersion = JAVA_DEFAULT_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        File destDir = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
//JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        File covFile = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        String optJcov = "-Xjcov";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        String optJcovFile = "-Xjcov:file=";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
//end JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        int flags = F_WARNINGS | F_DEBUG_LINES | F_DEBUG_SOURCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        long tm = System.currentTimeMillis();
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   214
        Vector<String> v = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        boolean nowrite = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        String props = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        String encoding = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        // These flags are used to make sure conflicting -O and -g
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        // options aren't given.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        String prior_g = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        String prior_O = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        exitStatus = EXIT_OK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        // Pre-process command line for @file arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            argv = CommandLine.parse(argv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        } catch (FileNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            error("javac.err.cant.read", e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        // Parse arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        for (int i = 0 ; i < argv.length ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            if (argv[i].equals("-g")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                if (prior_g!=null && !(prior_g.equals("-g")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                   error("main.conflicting.options", prior_g, "-g");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                prior_g = "-g";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                flags |= F_DEBUG_LINES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                flags |= F_DEBUG_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                flags |= F_DEBUG_SOURCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            } else if (argv[i].equals("-g:none")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                if (prior_g!=null && !(prior_g.equals("-g:none")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                   error("main.conflicting.options", prior_g, "-g:none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                prior_g = "-g:none";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                flags &= ~F_DEBUG_LINES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                flags &= ~F_DEBUG_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                flags &= ~F_DEBUG_SOURCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            } else if (argv[i].startsWith("-g:")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                // We choose to have debugging options conflict even
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                // if they amount to the same thing (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                // -g:source,lines and -g:lines,source).  However, multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                // debugging options are allowed if they are textually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                // identical.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                if (prior_g!=null && !(prior_g.equals(argv[i])))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                   error("main.conflicting.options", prior_g, argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                prior_g = argv[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                String args = argv[i].substring("-g:".length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                flags &= ~F_DEBUG_LINES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                flags &= ~F_DEBUG_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                flags &= ~F_DEBUG_SOURCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    if (args.startsWith("lines")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                        flags |= F_DEBUG_LINES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                        args = args.substring("lines".length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    } else if (args.startsWith("vars")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                        flags |= F_DEBUG_VARS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                        args = args.substring("vars".length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                    } else if (args.startsWith("source")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                        flags |= F_DEBUG_SOURCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                        args = args.substring("source".length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                        error("main.bad.debug.option",argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                        usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                        return false;  // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                    if (args.length() == 0) break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    if (args.startsWith(","))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                        args = args.substring(",".length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            } else if (argv[i].equals("-O")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                // -O is accepted for backward compatibility, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                // is no longer effective.  Use the undocumented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                // -XO option to get the old behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                if (prior_O!=null && !(prior_O.equals("-O")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    error("main.conflicting.options", prior_O, "-O");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                prior_O = "-O";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            } else if (argv[i].equals("-nowarn")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                flags &= ~F_WARNINGS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            } else if (argv[i].equals("-deprecation")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                flags |= F_DEPRECATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            } else if (argv[i].equals("-verbose")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                flags |= F_VERBOSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            } else if (argv[i].equals("-nowrite")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                nowrite = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            } else if (argv[i].equals("-classpath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                    if (classPathArg!=null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                       error("main.option.already.seen","-classpath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                    classPathArg = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                    error("main.option.requires.argument","-classpath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                    return false;  // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            } else if (argv[i].equals("-sourcepath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                    if (sourcePathArg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        error("main.option.already.seen","-sourcepath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                    sourcePathArg = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                    error("main.option.requires.argument","-sourcepath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    return false;  // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            } else if (argv[i].equals("-sysclasspath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                    if (sysClassPathArg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                        error("main.option.already.seen","-sysclasspath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    sysClassPathArg = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    error("main.option.requires.argument","-sysclasspath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                    return false;  // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            } else if (argv[i].equals("-bootclasspath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                    if (sysClassPathArg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                        error("main.option.already.seen","-bootclasspath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                    sysClassPathArg = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                    error("main.option.requires.argument","-bootclasspath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                    return false;  // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            } else if (argv[i].equals("-encoding")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                    if (encoding!=null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                       error("main.option.already.seen","-encoding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                    encoding = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                    error("main.option.requires.argument","-encoding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                    return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            } else if (argv[i].equals("-target")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                    if (targetArg!=null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                       error("main.option.already.seen","-target");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    targetArg = argv[++i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                    int j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                    for (j=0; j<releases.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                        if (releases[j].equals(targetArg)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                            majorVersion = majorVersions[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                            minorVersion = minorVersions[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                    if (j==releases.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                        error("main.unknown.release",targetArg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                        usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                        return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    error("main.option.requires.argument","-target");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                    return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            } else if (argv[i].equals("-d")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                if ((i + 1) < argv.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                    if (destDir!=null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                       error("main.option.already.seen","-d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    destDir = new File(argv[++i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    if (!destDir.exists()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                        error("main.no.such.directory",destDir.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                        usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                        return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    error("main.option.requires.argument","-d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
// JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            } else if (argv[i].equals(optJcov)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    flags |= F_COVERAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                    flags &= ~F_OPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                    flags &= ~F_OPT_INTERCLASS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            } else if ((argv[i].startsWith(optJcovFile)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                       (argv[i].length() > optJcovFile.length())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    covFile = new File(argv[i].substring(optJcovFile.length()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                    flags &= ~F_OPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    flags &= ~F_OPT_INTERCLASS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    flags |= F_COVERAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                    flags |= F_COVDATA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
// end JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            } else if (argv[i].equals("-XO")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                // This is what -O used to be.  Now undocumented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                if (prior_O!=null && !(prior_O.equals("-XO")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                   error("main.conflicting.options", prior_O, "-XO");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                prior_O = "-XO";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                flags |= F_OPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            } else if (argv[i].equals("-Xinterclass")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                if (prior_O!=null && !(prior_O.equals("-Xinterclass")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                   error("main.conflicting.options", prior_O, "-Xinterclass");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                prior_O = "-Xinterclass";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                flags |= F_OPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                flags |= F_OPT_INTERCLASS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                flags |= F_DEPENDENCIES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            } else if (argv[i].equals("-Xdepend")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                flags |= F_DEPENDENCIES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            } else if (argv[i].equals("-Xdebug")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                flags |= F_DUMP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            // Unadvertised option used by JWS.  The non-X version should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            // be removed, but we'll leave it in until we find out for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            // sure that no one still depends on that option syntax.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            } else if (argv[i].equals("-xdepend") || argv[i].equals("-Xjws")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                flags |= F_PRINT_DEPENDENCIES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                // change the default output in this case:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                if (out == System.err) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    out = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            } else if (argv[i].equals("-Xstrictdefault")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                // Make strict floating point the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                flags |= F_STRICTDEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            } else if (argv[i].equals("-Xverbosepath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                verbosePath = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            } else if (argv[i].equals("-Xstdout")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                out = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            } else if (argv[i].equals("-X")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                error("main.unsupported.usage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            } else if (argv[i].equals("-Xversion1.2")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                // Inform the compiler that it need not target VMs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                // earlier than version 1.2.  This option is here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                // for testing purposes only.  It is deliberately
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                // kept orthogonal to the -target option in 1.2.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                // for the sake of stability.  These options will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                // be merged in a future release.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                flags |= F_VERSION12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            } else if (argv[i].endsWith(".java")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                v.addElement(argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                error("main.no.such.option",argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                return false; // Stop processing now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        if (v.size() == 0 || exitStatus == EXIT_CMDERR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            usage_error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        // Create our Environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        BatchEnvironment env = BatchEnvironment.create(out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                                       sourcePathArg,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                                       classPathArg,
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   466
                                                       sysClassPathArg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        if (verbosePath) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            output(getText("main.path.msg",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                           env.sourcePath.toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                           env.binaryPath.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        env.flags |= flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        env.majorVersion = majorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        env.minorVersion = minorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
// JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        env.covFile = covFile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
// end JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        env.setCharacterEncoding(encoding);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        // Preload the "out of memory" error string just in case we run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        // out of memory during the compile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        String noMemoryErrorString = getText("main.no.memory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        String stackOverflowErrorString = getText("main.stack.overflow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        env.error(0, "warn.class.is.deprecated", "sun.tools.javac.Main");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            // Parse all input files
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   490
            for (Enumeration<String> e = v.elements() ; e.hasMoreElements() ;) {
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   491
                File file = new File(e.nextElement());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                try {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   493
                    env.parseFile(ClassFile.newClassFile(file));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                } catch (FileNotFoundException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                    env.error(0, "cant.read", file.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                    exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            // Do a post-read check on all newly-parsed classes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            // after they have all been read.
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   502
            for (Enumeration<ClassDeclaration> e = env.getClasses() ; e.hasMoreElements() ; ) {
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   503
                ClassDeclaration c = e.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                if (c.getStatus() == CS_PARSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                    if (c.getClassDefinition().isLocal())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                        c.getClassDefinition(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    } catch (ClassNotFound ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            // compile all classes that need compilation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            boolean done;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                done = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                env.flushErrors();
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   521
                for (Enumeration<ClassDeclaration> e = env.getClasses() ; e.hasMoreElements() ; ) {
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 25522
diff changeset
   522
                    ClassDeclaration c = e.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                    SourceClass src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                    switch (c.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                      case CS_UNDEFINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        if (!env.dependencies()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                        // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                      case CS_SOURCE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                        if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                            env.dtEvent("Main.compile (SOURCE): loading, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                        done = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                        env.loadDefinition(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                        if (c.getStatus() != CS_PARSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                env.dtEvent("Main.compile (SOURCE): not parsed, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                        // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                      case CS_PARSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                        if (c.getClassDefinition().isInsideLocal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                            // the enclosing block will check this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                                env.dtEvent("Main.compile (PARSED): skipping local class, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                        done = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                        if (tracing) env.dtEvent("Main.compile (PARSED): checking, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                        src = (SourceClass)c.getClassDefinition(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                        src.check(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                        c.setDefinition(src, CS_CHECKED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                        // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                      case CS_CHECKED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                        src = (SourceClass)c.getClassDefinition(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                        // bail out if there were any errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                        if (src.getError()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                                env.dtEvent("Main.compile (CHECKED): bailing out on error, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                            c.setDefinition(src, CS_COMPILED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        done = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                        buf.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                        if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                            env.dtEvent("Main.compile (CHECKED): compiling, " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        src.compile(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                        c.setDefinition(src, CS_COMPILED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                        src.cleanup(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                        if (src.getNestError() || nowrite) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                        String pkgName = c.getName().getQualifier().toString().replace('.', File.separatorChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                        String className = c.getName().getFlatName().toString().replace('.', SIGC_INNERCLASS) + ".class";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                        File file;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                        if (destDir != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                            if (pkgName.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                                file = new File(destDir, pkgName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                                if (!file.exists()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                                    file.mkdirs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                                file = new File(file, className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                file = new File(destDir, className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                            ClassFile classfile = (ClassFile)src.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                            if (classfile.isZipped()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                                env.error(0, "cant.write", classfile.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                                exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                            file = new File(classfile.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                            file = new File(file.getParent(), className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                        // Create the file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                            FileOutputStream out = new FileOutputStream(file.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                            buf.writeTo(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                            out.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                            if (env.verbose()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                output(getText("main.wrote", file.getPath()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                        } catch (IOException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                            env.error(0, "cant.write", file.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                            exitStatus = EXIT_CMDERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                        // Print class dependencies if requested (-xdepend)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                        if (env.print_dependencies()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                            src.printClassDependencies(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            } while (!done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        } catch (OutOfMemoryError ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            // The compiler has run out of memory.  Use the error string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            // which we preloaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            env.output(noMemoryErrorString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            exitStatus = EXIT_SYSERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        } catch (StackOverflowError ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            env.output(stackOverflowErrorString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            exitStatus = EXIT_SYSERR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        } catch (Error ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            // We allow the compiler to take an exception silently if a program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            // error has previously been detected.  Presumably, this makes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            // compiler more robust in the face of bad error recovery.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            if (env.nerrors == 0 || env.dump()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                ee.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                env.error(0, "fatal.error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                exitStatus = EXIT_ABNORMAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        } catch (Exception ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            if (env.nerrors == 0 || env.dump()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                ee.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                env.error(0, "fatal.exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                exitStatus = EXIT_ABNORMAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        int ndepfiles = env.deprecationFiles.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        if (ndepfiles > 0 && env.warnings()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            int ndeps = env.ndeprecations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            Object file1 = env.deprecationFiles.elementAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            if (env.deprecation()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                if (ndepfiles > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                    env.error(0, "warn.note.deprecations",
25522
10d789df41bb 8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents: 23740
diff changeset
   659
                              ndepfiles, ndeps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                    env.error(0, "warn.note.1deprecation",
25522
10d789df41bb 8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents: 23740
diff changeset
   662
                              file1, ndeps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                if (ndepfiles > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                    env.error(0, "warn.note.deprecations.silent",
25522
10d789df41bb 8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents: 23740
diff changeset
   667
                              ndepfiles, ndeps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                    env.error(0, "warn.note.1deprecation.silent",
25522
10d789df41bb 8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents: 23740
diff changeset
   670
                              file1, ndeps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        env.flushErrors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        env.shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        boolean status = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        if (env.nerrors > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            String msg = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            if (env.nerrors > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                msg = getText("main.errors", env.nerrors);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                msg = getText("main.1error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            if (env.nwarnings > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                if (env.nwarnings > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                    msg += ", " + getText("main.warnings", env.nwarnings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                    msg += ", " + getText("main.1warning");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            output(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            if (exitStatus == EXIT_OK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                // Allow EXIT_CMDERR or EXIT_ABNORMAL to take precedence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                exitStatus = EXIT_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            status = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            if (env.nwarnings > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                if (env.nwarnings > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    output(getText("main.warnings", env.nwarnings));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    output(getText("main.1warning"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
//JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        if (env.covdata()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            Assembler CovAsm = new Assembler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            CovAsm.GenJCov(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
// end JCOV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        // We're done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        if (env.verbose()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            tm = System.currentTimeMillis() - tm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            output(getText("main.done_in", Long.toString(tm)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * Main program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public static void main(String argv[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        OutputStream out = System.err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        // This is superceeded by the -Xstdout option, but we leave
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        // in the old property check for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        if (Boolean.getBoolean("javac.pipe.output")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            out = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        Main compiler = new Main(out, "javac");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        System.exit(compiler.compile(argv) ? 0 : compiler.exitStatus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
}