0N/A/*
2362N/A * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.tools.javac;
0N/A
0N/Aimport sun.tools.java.*;
0N/Aimport sun.tools.util.CommandLine;
0N/A// JCOV
0N/Aimport sun.tools.asm.Assembler;
0N/A// end JCOV
0N/A
0N/Aimport java.util.*;
0N/Aimport java.io.*;
0N/Aimport java.text.MessageFormat;
0N/A
0N/A/**
0N/A * Main program of the Java compiler
0N/A *
0N/A * WARNING: The contents of this source file are not part of any
0N/A * supported API. Code that depends on them does so at its own risk:
0N/A * they are subject to change or removal without notice.
0N/A *
0N/A * @deprecated As of J2SE 1.3, the preferred way to compile Java
0N/A * language sources is by using the new compiler,
0N/A * com.sun.tools.javac.Main.
0N/A */
0N/A@Deprecated
0N/Apublic
0N/Aclass Main implements Constants {
0N/A /**
0N/A * Name of the program.
0N/A */
0N/A String program;
0N/A
0N/A /**
0N/A * The stream where error message are printed.
0N/A */
0N/A OutputStream out;
0N/A
0N/A /**
0N/A * Constructor.
0N/A */
0N/A public Main(OutputStream out, String program) {
0N/A this.out = out;
0N/A this.program = program;
0N/A }
0N/A
0N/A /**
0N/A * Exit status.
0N/A * We introduce a separate integer status variable, and do not alter the
0N/A * convention that 'compile' returns a boolean true upon a successful
0N/A * compilation with no errors. (JavaTest relies on this.)
0N/A */
0N/A
0N/A public static final int EXIT_OK = 0; // Compilation completed with no errors.
0N/A public static final int EXIT_ERROR = 1; // Compilation completed but reported errors.
0N/A public static final int EXIT_CMDERR = 2; // Bad command-line arguments and/or switches.
0N/A public static final int EXIT_SYSERR = 3; // System error or resource exhaustion.
0N/A public static final int EXIT_ABNORMAL = 4; // Compiler terminated abnormally.
0N/A
0N/A private int exitStatus;
0N/A
0N/A public int getExitStatus() {
0N/A return exitStatus;
0N/A }
0N/A
0N/A public boolean compilationPerformedSuccessfully() {
0N/A return exitStatus == EXIT_OK || exitStatus == EXIT_ERROR;
0N/A }
0N/A
0N/A public boolean compilationReportedErrors () {
0N/A return exitStatus != EXIT_OK;
0N/A }
0N/A
0N/A /**
0N/A * Output a message.
0N/A */
0N/A private void output(String msg) {
0N/A PrintStream out =
0N/A this.out instanceof PrintStream ? (PrintStream)this.out
0N/A : new PrintStream(this.out, true);
0N/A out.println(msg);
0N/A }
0N/A
0N/A /**
0N/A * Top level error message. This method is called when the
0N/A * environment could not be set up yet.
0N/A */
0N/A private void error(String msg) {
0N/A exitStatus = EXIT_CMDERR;
0N/A output(getText(msg));
0N/A }
0N/A
0N/A private void error(String msg, String arg1) {
0N/A exitStatus = EXIT_CMDERR;
0N/A output(getText(msg, arg1));
0N/A }
0N/A
0N/A private void error(String msg, String arg1, String arg2) {
0N/A exitStatus = EXIT_CMDERR;
0N/A output(getText(msg, arg1, arg2));
0N/A }
0N/A
0N/A /**
0N/A * Print usage message and make exit status an error.
0N/A * Note: 'javac' invoked without any arguments is considered
0N/A * be an error.
0N/A */
0N/A public void usage_error() {
0N/A error("main.usage", program);
0N/A }
0N/A
0N/A private static ResourceBundle messageRB;
0N/A
0N/A /**
0N/A * Initialize ResourceBundle
0N/A */
0N/A static void initResource() {
0N/A try {
0N/A messageRB =
0N/A ResourceBundle.getBundle("sun.tools.javac.resources.javac");
0N/A } catch (MissingResourceException e) {
0N/A throw new Error("Fatal: Resource for javac is missing");
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * get and format message string from resource
0N/A */
0N/A public static String getText(String key) {
0N/A return getText(key, (String)null);
0N/A }
0N/A
0N/A public static String getText(String key, int num) {
0N/A return getText(key, Integer.toString(num));
0N/A }
0N/A
0N/A public static String getText(String key, String fixed) {
0N/A return getText(key, fixed, null);
0N/A }
0N/A
0N/A public static String getText(String key, String fixed1, String fixed2) {
0N/A return getText(key, fixed1, fixed2, null);
0N/A }
0N/A
0N/A public static String getText(String key, String fixed1,
0N/A String fixed2, String fixed3) {
0N/A if (messageRB == null) {
0N/A initResource();
0N/A }
0N/A try {
0N/A String message = messageRB.getString(key);
0N/A return MessageFormat.format(message, fixed1, fixed2, fixed3);
0N/A } catch (MissingResourceException e) {
0N/A if (fixed1 == null) fixed1 = "null";
0N/A if (fixed2 == null) fixed2 = "null";
0N/A if (fixed3 == null) fixed3 = "null";
0N/A String message = "JAVAC MESSAGE FILE IS BROKEN: key={0}, arguments={1}, {2}, {3}";
0N/A return MessageFormat.format(message, key, fixed1, fixed2, fixed3);
0N/A }
0N/A }
0N/A
0N/A // What major and minor version numbers to use for the -target flag.
0N/A // This should grow every time the minor version number accepted by
0N/A // the VM is incremented.
0N/A private static final String[] releases = { "1.1", "1.2", "1.3", "1.4" };
0N/A private static final short[] majorVersions = { 45, 46, 47, 48 };
0N/A private static final short[] minorVersions = { 3, 0, 0, 0 };
0N/A
0N/A /**
0N/A * Run the compiler
0N/A */
0N/A public synchronized boolean compile(String argv[]) {
0N/A String sourcePathArg = null;
0N/A String classPathArg = null;
0N/A String sysClassPathArg = null;
0N/A String extDirsArg = null;
0N/A boolean verbosePath = false;
0N/A
0N/A String targetArg = null;
0N/A short majorVersion = JAVA_DEFAULT_VERSION;
0N/A short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
0N/A
0N/A File destDir = null;
0N/A//JCOV
0N/A File covFile = null;
0N/A String optJcov = "-Xjcov";
0N/A String optJcovFile = "-Xjcov:file=";
0N/A//end JCOV
0N/A int flags = F_WARNINGS | F_DEBUG_LINES | F_DEBUG_SOURCE;
0N/A long tm = System.currentTimeMillis();
0N/A Vector v = new Vector();
0N/A boolean nowrite = false;
0N/A String props = null;
0N/A String encoding = null;
0N/A
0N/A // These flags are used to make sure conflicting -O and -g
0N/A // options aren't given.
0N/A String prior_g = null;
0N/A String prior_O = null;
0N/A
0N/A exitStatus = EXIT_OK;
0N/A
0N/A // Pre-process command line for @file arguments
0N/A try {
0N/A argv = CommandLine.parse(argv);
0N/A } catch (FileNotFoundException e) {
0N/A error("javac.err.cant.read", e.getMessage());
0N/A System.exit(1);
0N/A } catch (IOException e) {
0N/A e.printStackTrace();
0N/A System.exit(1);
0N/A }
0N/A
0N/A // Parse arguments
0N/A for (int i = 0 ; i < argv.length ; i++) {
0N/A if (argv[i].equals("-g")) {
0N/A if (prior_g!=null && !(prior_g.equals("-g")))
0N/A error("main.conflicting.options", prior_g, "-g");
0N/A prior_g = "-g";
0N/A flags |= F_DEBUG_LINES;
0N/A flags |= F_DEBUG_VARS;
0N/A flags |= F_DEBUG_SOURCE;
0N/A } else if (argv[i].equals("-g:none")) {
0N/A if (prior_g!=null && !(prior_g.equals("-g:none")))
0N/A error("main.conflicting.options", prior_g, "-g:none");
0N/A prior_g = "-g:none";
0N/A flags &= ~F_DEBUG_LINES;
0N/A flags &= ~F_DEBUG_VARS;
0N/A flags &= ~F_DEBUG_SOURCE;
0N/A } else if (argv[i].startsWith("-g:")) {
0N/A // We choose to have debugging options conflict even
0N/A // if they amount to the same thing (for example,
0N/A // -g:source,lines and -g:lines,source). However, multiple
0N/A // debugging options are allowed if they are textually
0N/A // identical.
0N/A if (prior_g!=null && !(prior_g.equals(argv[i])))
0N/A error("main.conflicting.options", prior_g, argv[i]);
0N/A prior_g = argv[i];
0N/A String args = argv[i].substring("-g:".length());
0N/A flags &= ~F_DEBUG_LINES;
0N/A flags &= ~F_DEBUG_VARS;
0N/A flags &= ~F_DEBUG_SOURCE;
0N/A while (true) {
0N/A if (args.startsWith("lines")) {
0N/A flags |= F_DEBUG_LINES;
0N/A args = args.substring("lines".length());
0N/A } else if (args.startsWith("vars")) {
0N/A flags |= F_DEBUG_VARS;
0N/A args = args.substring("vars".length());
0N/A } else if (args.startsWith("source")) {
0N/A flags |= F_DEBUG_SOURCE;
0N/A args = args.substring("source".length());
0N/A } else {
0N/A error("main.bad.debug.option",argv[i]);
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A if (args.length() == 0) break;
0N/A if (args.startsWith(","))
0N/A args = args.substring(",".length());
0N/A }
0N/A } else if (argv[i].equals("-O")) {
0N/A // -O is accepted for backward compatibility, but
0N/A // is no longer effective. Use the undocumented
0N/A // -XO option to get the old behavior.
0N/A if (prior_O!=null && !(prior_O.equals("-O")))
0N/A error("main.conflicting.options", prior_O, "-O");
0N/A prior_O = "-O";
0N/A } else if (argv[i].equals("-nowarn")) {
0N/A flags &= ~F_WARNINGS;
0N/A } else if (argv[i].equals("-deprecation")) {
0N/A flags |= F_DEPRECATION;
0N/A } else if (argv[i].equals("-verbose")) {
0N/A flags |= F_VERBOSE;
0N/A } else if (argv[i].equals("-nowrite")) {
0N/A nowrite = true;
0N/A } else if (argv[i].equals("-classpath")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (classPathArg!=null) {
0N/A error("main.option.already.seen","-classpath");
0N/A }
0N/A classPathArg = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-classpath");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-sourcepath")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (sourcePathArg != null) {
0N/A error("main.option.already.seen","-sourcepath");
0N/A }
0N/A sourcePathArg = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-sourcepath");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-sysclasspath")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (sysClassPathArg != null) {
0N/A error("main.option.already.seen","-sysclasspath");
0N/A }
0N/A sysClassPathArg = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-sysclasspath");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-bootclasspath")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (sysClassPathArg != null) {
0N/A error("main.option.already.seen","-bootclasspath");
0N/A }
0N/A sysClassPathArg = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-bootclasspath");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-extdirs")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (extDirsArg != null) {
0N/A error("main.option.already.seen","-extdirs");
0N/A }
0N/A extDirsArg = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-extdirs");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-encoding")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (encoding!=null)
0N/A error("main.option.already.seen","-encoding");
0N/A encoding = argv[++i];
0N/A } else {
0N/A error("main.option.requires.argument","-encoding");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-target")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (targetArg!=null)
0N/A error("main.option.already.seen","-target");
0N/A targetArg = argv[++i];
0N/A int j;
0N/A for (j=0; j<releases.length; j++) {
0N/A if (releases[j].equals(targetArg)) {
0N/A majorVersion = majorVersions[j];
0N/A minorVersion = minorVersions[j];
0N/A break;
0N/A }
0N/A }
0N/A if (j==releases.length) {
0N/A error("main.unknown.release",targetArg);
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else {
0N/A error("main.option.requires.argument","-target");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else if (argv[i].equals("-d")) {
0N/A if ((i + 1) < argv.length) {
0N/A if (destDir!=null)
0N/A error("main.option.already.seen","-d");
0N/A destDir = new File(argv[++i]);
0N/A if (!destDir.exists()) {
0N/A error("main.no.such.directory",destDir.getPath());
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A } else {
0N/A error("main.option.requires.argument","-d");
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A// JCOV
0N/A } else if (argv[i].equals(optJcov)) {
0N/A flags |= F_COVERAGE;
0N/A flags &= ~F_OPT;
0N/A flags &= ~F_OPT_INTERCLASS;
0N/A } else if ((argv[i].startsWith(optJcovFile)) &&
0N/A (argv[i].length() > optJcovFile.length())) {
0N/A covFile = new File(argv[i].substring(optJcovFile.length()));
0N/A flags &= ~F_OPT;
0N/A flags &= ~F_OPT_INTERCLASS;
0N/A flags |= F_COVERAGE;
0N/A flags |= F_COVDATA;
0N/A// end JCOV
0N/A } else if (argv[i].equals("-XO")) {
0N/A // This is what -O used to be. Now undocumented.
0N/A if (prior_O!=null && !(prior_O.equals("-XO")))
0N/A error("main.conflicting.options", prior_O, "-XO");
0N/A prior_O = "-XO";
0N/A flags |= F_OPT;
0N/A } else if (argv[i].equals("-Xinterclass")) {
0N/A if (prior_O!=null && !(prior_O.equals("-Xinterclass")))
0N/A error("main.conflicting.options", prior_O, "-Xinterclass");
0N/A prior_O = "-Xinterclass";
0N/A flags |= F_OPT;
0N/A flags |= F_OPT_INTERCLASS;
0N/A flags |= F_DEPENDENCIES;
0N/A } else if (argv[i].equals("-Xdepend")) {
0N/A flags |= F_DEPENDENCIES;
0N/A } else if (argv[i].equals("-Xdebug")) {
0N/A flags |= F_DUMP;
0N/A // Unadvertised option used by JWS. The non-X version should
0N/A // be removed, but we'll leave it in until we find out for
0N/A // sure that no one still depends on that option syntax.
0N/A } else if (argv[i].equals("-xdepend") || argv[i].equals("-Xjws")) {
0N/A flags |= F_PRINT_DEPENDENCIES;
0N/A // change the default output in this case:
0N/A if (out == System.err) {
0N/A out = System.out;
0N/A }
0N/A } else if (argv[i].equals("-Xstrictdefault")) {
0N/A // Make strict floating point the default
0N/A flags |= F_STRICTDEFAULT;
0N/A } else if (argv[i].equals("-Xverbosepath")) {
0N/A verbosePath = true;
0N/A } else if (argv[i].equals("-Xstdout")) {
0N/A out = System.out;
0N/A } else if (argv[i].equals("-X")) {
0N/A error("main.unsupported.usage");
0N/A return false; // Stop processing now
0N/A } else if (argv[i].equals("-Xversion1.2")) {
0N/A // Inform the compiler that it need not target VMs
0N/A // earlier than version 1.2. This option is here
0N/A // for testing purposes only. It is deliberately
0N/A // kept orthogonal to the -target option in 1.2.0
0N/A // for the sake of stability. These options will
0N/A // be merged in a future release.
0N/A flags |= F_VERSION12;
0N/A } else if (argv[i].endsWith(".java")) {
0N/A v.addElement(argv[i]);
0N/A } else {
0N/A error("main.no.such.option",argv[i]);
0N/A usage_error();
0N/A return false; // Stop processing now
0N/A }
0N/A }
0N/A if (v.size() == 0 || exitStatus == EXIT_CMDERR) {
0N/A usage_error();
0N/A return false;
0N/A }
0N/A
0N/A // Create our Environment.
0N/A BatchEnvironment env = BatchEnvironment.create(out,
0N/A sourcePathArg,
0N/A classPathArg,
0N/A sysClassPathArg,
0N/A extDirsArg);
0N/A if (verbosePath) {
0N/A output(getText("main.path.msg",
0N/A env.sourcePath.toString(),
0N/A env.binaryPath.toString()));
0N/A }
0N/A
0N/A env.flags |= flags;
0N/A env.majorVersion = majorVersion;
0N/A env.minorVersion = minorVersion;
0N/A// JCOV
0N/A env.covFile = covFile;
0N/A// end JCOV
0N/A env.setCharacterEncoding(encoding);
0N/A
0N/A // Preload the "out of memory" error string just in case we run
0N/A // out of memory during the compile.
0N/A String noMemoryErrorString = getText("main.no.memory");
0N/A String stackOverflowErrorString = getText("main.stack.overflow");
0N/A
0N/A env.error(0, "warn.class.is.deprecated", "sun.tools.javac.Main");
0N/A
0N/A try {
0N/A // Parse all input files
0N/A for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
0N/A File file = new File((String)e.nextElement());
0N/A try {
0N/A env.parseFile(new ClassFile(file));
0N/A } catch (FileNotFoundException ee) {
0N/A env.error(0, "cant.read", file.getPath());
0N/A exitStatus = EXIT_CMDERR;
0N/A }
0N/A }
0N/A
0N/A // Do a post-read check on all newly-parsed classes,
0N/A // after they have all been read.
0N/A for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
0N/A ClassDeclaration c = (ClassDeclaration)e.nextElement();
0N/A if (c.getStatus() == CS_PARSED) {
0N/A if (c.getClassDefinition().isLocal())
0N/A continue;
0N/A try {
0N/A c.getClassDefinition(env);
0N/A } catch (ClassNotFound ee) {
0N/A }
0N/A }
0N/A }
0N/A
0N/A // compile all classes that need compilation
0N/A ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
0N/A boolean done;
0N/A
0N/A do {
0N/A done = true;
0N/A env.flushErrors();
0N/A for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
0N/A ClassDeclaration c = (ClassDeclaration)e.nextElement();
0N/A SourceClass src;
0N/A
0N/A switch (c.getStatus()) {
0N/A case CS_UNDEFINED:
0N/A if (!env.dependencies()) {
0N/A break;
0N/A }
0N/A // fall through
0N/A
0N/A case CS_SOURCE:
0N/A if (tracing)
0N/A env.dtEvent("Main.compile (SOURCE): loading, " + c);
0N/A done = false;
0N/A env.loadDefinition(c);
0N/A if (c.getStatus() != CS_PARSED) {
0N/A if (tracing)
0N/A env.dtEvent("Main.compile (SOURCE): not parsed, " + c);
0N/A break;
0N/A }
0N/A // fall through
0N/A
0N/A case CS_PARSED:
0N/A if (c.getClassDefinition().isInsideLocal()) {
0N/A // the enclosing block will check this one
0N/A if (tracing)
0N/A env.dtEvent("Main.compile (PARSED): skipping local class, " + c);
0N/A continue;
0N/A }
0N/A done = false;
0N/A if (tracing) env.dtEvent("Main.compile (PARSED): checking, " + c);
0N/A src = (SourceClass)c.getClassDefinition(env);
0N/A src.check(env);
0N/A c.setDefinition(src, CS_CHECKED);
0N/A // fall through
0N/A
0N/A case CS_CHECKED:
0N/A src = (SourceClass)c.getClassDefinition(env);
0N/A // bail out if there were any errors
0N/A if (src.getError()) {
0N/A if (tracing)
0N/A env.dtEvent("Main.compile (CHECKED): bailing out on error, " + c);
0N/A c.setDefinition(src, CS_COMPILED);
0N/A break;
0N/A }
0N/A done = false;
0N/A buf.reset();
0N/A if (tracing)
0N/A env.dtEvent("Main.compile (CHECKED): compiling, " + c);
0N/A src.compile(buf);
0N/A c.setDefinition(src, CS_COMPILED);
0N/A src.cleanup(env);
0N/A
0N/A if (src.getNestError() || nowrite) {
0N/A continue;
0N/A }
0N/A
0N/A String pkgName = c.getName().getQualifier().toString().replace('.', File.separatorChar);
0N/A String className = c.getName().getFlatName().toString().replace('.', SIGC_INNERCLASS) + ".class";
0N/A
0N/A File file;
0N/A if (destDir != null) {
0N/A if (pkgName.length() > 0) {
0N/A file = new File(destDir, pkgName);
0N/A if (!file.exists()) {
0N/A file.mkdirs();
0N/A }
0N/A file = new File(file, className);
0N/A } else {
0N/A file = new File(destDir, className);
0N/A }
0N/A } else {
0N/A ClassFile classfile = (ClassFile)src.getSource();
0N/A if (classfile.isZipped()) {
0N/A env.error(0, "cant.write", classfile.getPath());
0N/A exitStatus = EXIT_CMDERR;
0N/A continue;
0N/A }
0N/A file = new File(classfile.getPath());
0N/A file = new File(file.getParent(), className);
0N/A }
0N/A
0N/A // Create the file
0N/A try {
0N/A FileOutputStream out = new FileOutputStream(file.getPath());
0N/A buf.writeTo(out);
0N/A out.close();
0N/A
0N/A if (env.verbose()) {
0N/A output(getText("main.wrote", file.getPath()));
0N/A }
0N/A } catch (IOException ee) {
0N/A env.error(0, "cant.write", file.getPath());
0N/A exitStatus = EXIT_CMDERR;
0N/A }
0N/A
0N/A // Print class dependencies if requested (-xdepend)
0N/A if (env.print_dependencies()) {
0N/A src.printClassDependencies(env);
0N/A }
0N/A }
0N/A }
0N/A } while (!done);
0N/A } catch (OutOfMemoryError ee) {
0N/A // The compiler has run out of memory. Use the error string
0N/A // which we preloaded.
0N/A env.output(noMemoryErrorString);
0N/A exitStatus = EXIT_SYSERR;
0N/A return false;
0N/A } catch (StackOverflowError ee) {
0N/A env.output(stackOverflowErrorString);
0N/A exitStatus = EXIT_SYSERR;
0N/A return false;
0N/A } catch (Error ee) {
0N/A // We allow the compiler to take an exception silently if a program
0N/A // error has previously been detected. Presumably, this makes the
0N/A // compiler more robust in the face of bad error recovery.
0N/A if (env.nerrors == 0 || env.dump()) {
0N/A ee.printStackTrace();
0N/A env.error(0, "fatal.error");
0N/A exitStatus = EXIT_ABNORMAL;
0N/A }
0N/A } catch (Exception ee) {
0N/A if (env.nerrors == 0 || env.dump()) {
0N/A ee.printStackTrace();
0N/A env.error(0, "fatal.exception");
0N/A exitStatus = EXIT_ABNORMAL;
0N/A }
0N/A }
0N/A
0N/A int ndepfiles = env.deprecationFiles.size();
0N/A if (ndepfiles > 0 && env.warnings()) {
0N/A int ndeps = env.ndeprecations;
0N/A Object file1 = env.deprecationFiles.elementAt(0);
0N/A if (env.deprecation()) {
0N/A if (ndepfiles > 1) {
0N/A env.error(0, "warn.note.deprecations",
0N/A new Integer(ndepfiles), new Integer(ndeps));
0N/A } else {
0N/A env.error(0, "warn.note.1deprecation",
0N/A file1, new Integer(ndeps));
0N/A }
0N/A } else {
0N/A if (ndepfiles > 1) {
0N/A env.error(0, "warn.note.deprecations.silent",
0N/A new Integer(ndepfiles), new Integer(ndeps));
0N/A } else {
0N/A env.error(0, "warn.note.1deprecation.silent",
0N/A file1, new Integer(ndeps));
0N/A }
0N/A }
0N/A }
0N/A
0N/A env.flushErrors();
0N/A env.shutdown();
0N/A
0N/A boolean status = true;
0N/A if (env.nerrors > 0) {
0N/A String msg = "";
0N/A if (env.nerrors > 1) {
0N/A msg = getText("main.errors", env.nerrors);
0N/A } else {
0N/A msg = getText("main.1error");
0N/A }
0N/A if (env.nwarnings > 0) {
0N/A if (env.nwarnings > 1) {
0N/A msg += ", " + getText("main.warnings", env.nwarnings);
0N/A } else {
0N/A msg += ", " + getText("main.1warning");
0N/A }
0N/A }
0N/A output(msg);
0N/A if (exitStatus == EXIT_OK) {
0N/A // Allow EXIT_CMDERR or EXIT_ABNORMAL to take precedence.
0N/A exitStatus = EXIT_ERROR;
0N/A }
0N/A status = false;
0N/A } else {
0N/A if (env.nwarnings > 0) {
0N/A if (env.nwarnings > 1) {
0N/A output(getText("main.warnings", env.nwarnings));
0N/A } else {
0N/A output(getText("main.1warning"));
0N/A }
0N/A }
0N/A }
0N/A//JCOV
0N/A if (env.covdata()) {
0N/A Assembler CovAsm = new Assembler();
0N/A CovAsm.GenJCov(env);
0N/A }
0N/A// end JCOV
0N/A
0N/A // We're done
0N/A if (env.verbose()) {
0N/A tm = System.currentTimeMillis() - tm;
0N/A output(getText("main.done_in", Long.toString(tm)));
0N/A }
0N/A
0N/A return status;
0N/A }
0N/A
0N/A /**
0N/A * Main program
0N/A */
0N/A public static void main(String argv[]) {
0N/A OutputStream out = System.err;
0N/A
0N/A // This is superceeded by the -Xstdout option, but we leave
0N/A // in the old property check for compatibility.
0N/A if (Boolean.getBoolean("javac.pipe.output")) {
0N/A out = System.out;
0N/A }
0N/A
0N/A Main compiler = new Main(out, "javac");
0N/A System.exit(compiler.compile(argv) ? 0 : compiler.exitStatus);
0N/A }
0N/A}