1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.main;
  27 
  28 import java.io.File;
  29 import java.io.IOException;
  30 import java.io.PrintWriter;
  31 import java.net.URL;
  32 import java.security.DigestInputStream;
  33 import java.security.MessageDigest;
  34 import java.util.Arrays;
  35 import java.util.Collection;
  36 import java.util.Iterator;
  37 import java.util.LinkedHashSet;
  38 import java.util.Set;
  39 
  40 import javax.annotation.processing.Processor;
  41 import javax.tools.JavaFileManager;
  42 import javax.tools.JavaFileObject;
  43 
  44 import com.sun.source.util.JavacTask;
  45 import com.sun.source.util.Plugin;
  46 import com.sun.tools.doclint.DocLint;
  47 import com.sun.tools.javac.api.BasicJavacTask;
  48 import com.sun.tools.javac.code.Source;
  49 import com.sun.tools.javac.file.CacheFSInfo;
  50 import com.sun.tools.javac.file.JavacFileManager;
  51 import com.sun.tools.javac.jvm.Profile;
  52 import com.sun.tools.javac.jvm.Target;
  53 import com.sun.tools.javac.processing.AnnotationProcessingError;
  54 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  55 import com.sun.tools.javac.util.*;
  56 import com.sun.tools.javac.util.Log.PrefixKind;
  57 import com.sun.tools.javac.util.Log.WriterKind;
  58 import com.sun.tools.javac.util.ServiceLoader;
  59 import static com.sun.tools.javac.main.Option.*;
  60 
  61 /** This class provides a command line interface to the javac compiler.
  62  *
  63  *  <p><b>This is NOT part of any supported API.
  64  *  If you write code that depends on this, you do so at your own risk.
  65  *  This code and its internal interfaces are subject to change or
  66  *  deletion without notice.</b>
  67  */
  68 public class Main {
  69 
  70     /** The name of the compiler, for use in diagnostics.
  71      */
  72     String ownName;
  73 
  74     /** The writer to use for diagnostic output.
  75      */
  76     PrintWriter out;
  77 
  78     /** The log to use for diagnostic output.
  79      */
  80     public Log log;
  81 
  82     /**
  83      * If true, certain errors will cause an exception, such as command line
  84      * arg errors, or exceptions in user provided code.
  85      */
  86     boolean apiMode;
  87 
  88 
  89     /** Result codes.
  90      */
  91     public enum Result {
  92         OK(0),        // Compilation completed with no errors.
  93         ERROR(1),     // Completed but reported errors.
  94         CMDERR(2),    // Bad command-line arguments
  95         SYSERR(3),    // System error or resource exhaustion.
  96         ABNORMAL(4);  // Compiler terminated abnormally
  97 
  98         Result(int exitCode) {
  99             this.exitCode = exitCode;
 100         }
 101 
 102         public boolean isOK() {
 103             return (exitCode == 0);
 104         }
 105 
 106         public final int exitCode;
 107     }
 108 
 109     private Option[] recognizedOptions =
 110             Option.getJavaCompilerOptions().toArray(new Option[0]);
 111 
 112     private OptionHelper optionHelper = new OptionHelper() {
 113         @Override
 114         public String get(Option option) {
 115             return options.get(option);
 116         }
 117 
 118         @Override
 119         public void put(String name, String value) {
 120             options.put(name, value);
 121         }
 122 
 123         @Override
 124         public void remove(String name) {
 125             options.remove(name);
 126         }
 127 
 128         @Override
 129         public Log getLog() {
 130             return log;
 131         }
 132 
 133         @Override
 134         public String getOwnName() {
 135             return ownName;
 136         }
 137 
 138         @Override
 139         public void error(String key, Object... args) {
 140             Main.this.error(key, args);
 141         }
 142 
 143         @Override
 144         public void addFile(File f) {
 145             filenames.add(f);
 146         }
 147 
 148         @Override
 149         public void addClassName(String s) {
 150             classnames.append(s);
 151         }
 152 
 153     };
 154 
 155     /**
 156      * Construct a compiler instance.
 157      */
 158     public Main(String name) {
 159         this(name, new PrintWriter(System.err, true));
 160     }
 161 
 162     /**
 163      * Construct a compiler instance.
 164      */
 165     public Main(String name, PrintWriter out) {
 166         this.ownName = name;
 167         this.out = out;
 168     }
 169 
 170     /** A table of all options that's passed to the JavaCompiler constructor.  */
 171     private Options options = null;
 172 
 173     /** The list of source files to process
 174      */
 175     public Set<File> filenames = null; // XXX sb protected
 176 
 177     /** List of class files names passed on the command line
 178      */
 179     public ListBuffer<String> classnames = null; // XXX sb protected
 180 
 181     /** Report a usage error.
 182      */
 183     void error(String key, Object... args) {
 184         if (apiMode) {
 185             String msg = log.localize(PrefixKind.JAVAC, key, args);
 186             throw new PropagatedException(new IllegalStateException(msg));
 187         }
 188         warning(key, args);
 189         log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
 190     }
 191 
 192     /** Report a warning.
 193      */
 194     void warning(String key, Object... args) {
 195         log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
 196     }
 197 
 198     public Option getOption(String flag) {
 199         for (Option option : recognizedOptions) {
 200             if (option.matches(flag))
 201                 return option;
 202         }
 203         return null;
 204     }
 205 
 206     public void setOptions(Options options) {
 207         if (options == null)
 208             throw new NullPointerException();
 209         this.options = options;
 210     }
 211 
 212     public void setAPIMode(boolean apiMode) {
 213         this.apiMode = apiMode;
 214     }
 215 
 216     /** Process command line arguments: store all command line options
 217      *  in `options' table and return all source filenames.
 218      *  @param flags    The array of command line arguments.
 219      */
 220     public Collection<File> processArgs(String[] flags) { // XXX sb protected
 221         return processArgs(flags, null);
 222     }
 223 
 224     public Collection<File> processArgs(String[] flags, String[] classNames) { // XXX sb protected
 225         int ac = 0;
 226         while (ac < flags.length) {
 227             String flag = flags[ac];
 228             ac++;
 229 
 230             Option option = null;
 231 
 232             if (flag.length() > 0) {
 233                 // quick hack to speed up file processing:
 234                 // if the option does not begin with '-', there is no need to check
 235                 // most of the compiler options.
 236                 int firstOptionToCheck = flag.charAt(0) == '-' ? 0 : recognizedOptions.length-1;
 237                 for (int j=firstOptionToCheck; j<recognizedOptions.length; j++) {
 238                     if (recognizedOptions[j].matches(flag)) {
 239                         option = recognizedOptions[j];
 240                         break;
 241                     }
 242                 }
 243             }
 244 
 245             if (option == null) {
 246                 error("err.invalid.flag", flag);
 247                 return null;
 248             }
 249 
 250             if (option.hasArg()) {
 251                 if (ac == flags.length) {
 252                     error("err.req.arg", flag);
 253                     return null;
 254                 }
 255                 String operand = flags[ac];
 256                 ac++;
 257                 if (option.process(optionHelper, flag, operand))
 258                     return null;
 259             } else {
 260                 if (option.process(optionHelper, flag))
 261                     return null;
 262             }
 263         }
 264 
 265         if (this.classnames != null && classNames != null) {
 266             this.classnames.addAll(Arrays.asList(classNames));
 267         }
 268 
 269         if (!checkDirectory(D))
 270             return null;
 271         if (!checkDirectory(S))
 272             return null;
 273 
 274         String sourceString = options.get(SOURCE);
 275         Source source = (sourceString != null)
 276             ? Source.lookup(sourceString)
 277             : Source.DEFAULT;
 278         String targetString = options.get(TARGET);
 279         Target target = (targetString != null)
 280             ? Target.lookup(targetString)
 281             : Target.DEFAULT;
 282         // We don't check source/target consistency for CLDC, as J2ME
 283         // profiles are not aligned with J2SE targets; moreover, a
 284         // single CLDC target may have many profiles.  In addition,
 285         // this is needed for the continued functioning of the JSR14
 286         // prototype.
 287         if (Character.isDigit(target.name.charAt(0))) {
 288             if (target.compareTo(source.requiredTarget()) < 0) {
 289                 if (targetString != null) {
 290                     if (sourceString == null) {
 291                         warning("warn.target.default.source.conflict",
 292                                 targetString,
 293                                 source.requiredTarget().name);
 294                     } else {
 295                         warning("warn.source.target.conflict",
 296                                 sourceString,
 297                                 source.requiredTarget().name);
 298                     }
 299                     return null;
 300                 } else {
 301                     target = source.requiredTarget();
 302                     options.put("-target", target.name);
 303                 }
 304             } else {
 305                 if (targetString == null && !source.allowGenerics()) {
 306                     target = Target.JDK1_4;
 307                     options.put("-target", target.name);
 308                 }
 309             }
 310         }
 311 
 312         String profileString = options.get(PROFILE);
 313         if (profileString != null) {
 314             Profile profile = Profile.lookup(profileString);
 315             if (!profile.isValid(target)) {
 316                 warning("warn.profile.target.conflict", profileString, target.name);
 317                 return null;
 318             }
 319         }
 320 
 321         // handle this here so it works even if no other options given
 322         String showClass = options.get("showClass");
 323         if (showClass != null) {
 324             if (showClass.equals("showClass")) // no value given for option
 325                 showClass = "com.sun.tools.javac.Main";
 326             showClass(showClass);
 327         }
 328 
 329         options.notifyListeners();
 330 
 331         return filenames;
 332     }
 333     // where
 334         private boolean checkDirectory(Option option) {
 335             String value = options.get(option);
 336             if (value == null)
 337                 return true;
 338             File file = new File(value);
 339             if (!file.exists()) {
 340                 error("err.dir.not.found", value);
 341                 return false;
 342             }
 343             if (!file.isDirectory()) {
 344                 error("err.file.not.directory", value);
 345                 return false;
 346             }
 347             return true;
 348         }
 349 
 350     /** Programmatic interface for main function.
 351      * @param args    The command line parameters.
 352      */
 353     public Result compile(String[] args) {
 354         Context context = new Context();
 355         JavacFileManager.preRegister(context); // can't create it until Log has been set up
 356         Result result = compile(args, context);
 357         if (fileManager instanceof JavacFileManager) {
 358             // A fresh context was created above, so jfm must be a JavacFileManager
 359             ((JavacFileManager)fileManager).close();
 360         }
 361         return result;
 362     }
 363 
 364     public Result compile(String[] args, Context context) {
 365         return compile(args, context, List.<JavaFileObject>nil(), null);
 366     }
 367 
 368     /** Programmatic interface for main function.
 369      * @param args    The command line parameters.
 370      */
 371     public Result compile(String[] args,
 372                        Context context,
 373                        List<JavaFileObject> fileObjects,
 374                        Iterable<? extends Processor> processors)
 375     {
 376         return compile(args,  null, context, fileObjects, processors);
 377     }
 378 
 379     public Result compile(String[] args,
 380                           String[] classNames,
 381                           Context context,
 382                           List<JavaFileObject> fileObjects,
 383                           Iterable<? extends Processor> processors)
 384     {
 385         context.put(Log.outKey, out);
 386         log = Log.instance(context);
 387         return compile(args,  classNames, context,
 388                        fileObjects, processors, log);
 389     }
 390 
 391     // Added to allow tests to install their own log subclasses
 392     public Result compile(String[] args,
 393                           String[] classNames,
 394                           Context context,
 395                           List<JavaFileObject> fileObjects,
 396                           Iterable<? extends Processor> processors,
 397                           Log log)
 398     {
 399         if (options == null)
 400             options = Options.instance(context); // creates a new one
 401 
 402         filenames = new LinkedHashSet<File>();
 403         classnames = new ListBuffer<String>();
 404         JavaCompiler comp = null;
 405         /*
 406          * TODO: Logic below about what is an acceptable command line
 407          * should be updated to take annotation processing semantics
 408          * into account.
 409          */
 410         try {
 411             if (args.length == 0
 412                     && (classNames == null || classNames.length == 0)
 413                     && fileObjects.isEmpty()) {
 414                 Option.HELP.process(optionHelper, "-help");
 415                 return Result.CMDERR;
 416             }
 417 
 418             Collection<File> files;
 419             try {
 420                 files = processArgs(CommandLine.parse(args), classNames);
 421                 if (files == null) {
 422                     // null signals an error in options, abort
 423                     return Result.CMDERR;
 424                 } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
 425                     // it is allowed to compile nothing if just asking for help or version info
 426                     if (options.isSet(HELP)
 427                         || options.isSet(X)
 428                         || options.isSet(VERSION)
 429                         || options.isSet(FULLVERSION))
 430                         return Result.OK;
 431                     if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
 432                         error("err.no.source.files.classes");
 433                     } else {
 434                         error("err.no.source.files");
 435                     }
 436                     return Result.CMDERR;
 437                 }
 438             } catch (java.io.FileNotFoundException e) {
 439                 warning("err.file.not.found", e.getMessage());
 440                 return Result.SYSERR;
 441             }
 442 
 443             boolean forceStdOut = options.isSet("stdout");
 444             if (forceStdOut) {
 445                 log.flush();
 446                 log.setWriters(new PrintWriter(System.out, true));
 447             }
 448 
 449             // allow System property in following line as a Mustang legacy
 450             boolean batchMode = (options.isUnset("nonBatchMode")
 451                         && System.getProperty("nonBatchMode") == null);
 452             if (batchMode)
 453                 CacheFSInfo.preRegister(context);
 454 
 455             // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate
 456             // invoke any available plugins
 457             String plugins = options.get(PLUGIN);
 458             if (plugins != null) {
 459                 JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context);
 460                 ClassLoader cl = pEnv.getProcessorClassLoader();
 461                 ServiceLoader<Plugin> sl = ServiceLoader.load(Plugin.class, cl);
 462                 Set<List<String>> pluginsToCall = new LinkedHashSet<List<String>>();
 463                 for (String plugin: plugins.split("\\x00")) {
 464                     pluginsToCall.add(List.from(plugin.split("\\s+")));
 465                 }
 466                 JavacTask task = null;
 467                 Iterator<Plugin> iter = sl.iterator();
 468                 while (iter.hasNext()) {
 469                     Plugin plugin = iter.next();
 470                     for (List<String> p: pluginsToCall) {
 471                         if (plugin.getName().equals(p.head)) {
 472                             pluginsToCall.remove(p);
 473                             try {
 474                                 if (task == null)
 475                                     task = JavacTask.instance(pEnv);
 476                                 plugin.init(task, p.tail.toArray(new String[p.tail.size()]));
 477                             } catch (Throwable ex) {
 478                                 if (apiMode)
 479                                     throw new RuntimeException(ex);
 480                                 pluginMessage(ex);
 481                                 return Result.SYSERR;
 482                             }
 483                         }
 484                     }
 485                 }
 486                 for (List<String> p: pluginsToCall) {
 487                     log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head);
 488                 }
 489             }
 490 
 491             comp = JavaCompiler.instance(context);
 492 
 493             // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate
 494             String xdoclint = options.get(XDOCLINT);
 495             String xdoclintCustom = options.get(XDOCLINT_CUSTOM);
 496             if (xdoclint != null || xdoclintCustom != null) {
 497                 Set<String> doclintOpts = new LinkedHashSet<String>();
 498                 if (xdoclint != null)
 499                     doclintOpts.add(DocLint.XMSGS_OPTION);
 500                 if (xdoclintCustom != null) {
 501                     for (String s: xdoclintCustom.split("\\s+")) {
 502                         if (s.isEmpty())
 503                             continue;
 504                         doclintOpts.add(s.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
 505                     }
 506                 }
 507                 if (!(doclintOpts.size() == 1
 508                         && doclintOpts.iterator().next().equals(DocLint.XMSGS_CUSTOM_PREFIX + "none"))) {
 509                     JavacTask t = BasicJavacTask.instance(context);
 510                     // standard doclet normally generates H1, H2
 511                     doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
 512                     new DocLint().init(t, doclintOpts.toArray(new String[doclintOpts.size()]));
 513                     comp.keepComments = true;
 514                 }
 515             }
 516 
 517             fileManager = context.get(JavaFileManager.class);
 518 
 519             if (!files.isEmpty()) {
 520                 // add filenames to fileObjects
 521                 comp = JavaCompiler.instance(context);
 522                 List<JavaFileObject> otherFiles = List.nil();
 523                 JavacFileManager dfm = (JavacFileManager)fileManager;
 524                 for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(files))
 525                     otherFiles = otherFiles.prepend(fo);
 526                 for (JavaFileObject fo : otherFiles)
 527                     fileObjects = fileObjects.prepend(fo);
 528             }
 529             comp.compile(fileObjects,
 530                          classnames.toList(),
 531                          processors);
 532 
 533             if (log.expectDiagKeys != null) {
 534                 if (log.expectDiagKeys.isEmpty()) {
 535                     log.printRawLines("all expected diagnostics found");
 536                     return Result.OK;
 537                 } else {
 538                     log.printRawLines("expected diagnostic keys not found: " + log.expectDiagKeys);
 539                     return Result.ERROR;
 540                 }
 541             }
 542 
 543             if (comp.errorCount() != 0)
 544                 return Result.ERROR;
 545         } catch (IOException ex) {
 546             ioMessage(ex);
 547             return Result.SYSERR;
 548         } catch (OutOfMemoryError ex) {
 549             resourceMessage(ex);
 550             return Result.SYSERR;
 551         } catch (StackOverflowError ex) {
 552             resourceMessage(ex);
 553             return Result.SYSERR;
 554         } catch (FatalError ex) {
 555             feMessage(ex);
 556             return Result.SYSERR;
 557         } catch (AnnotationProcessingError ex) {
 558             if (apiMode)
 559                 throw new RuntimeException(ex.getCause());
 560             apMessage(ex);
 561             return Result.SYSERR;
 562         } catch (ClientCodeException ex) {
 563             // as specified by javax.tools.JavaCompiler#getTask
 564             // and javax.tools.JavaCompiler.CompilationTask#call
 565             throw new RuntimeException(ex.getCause());
 566         } catch (PropagatedException ex) {
 567             throw ex.getCause();
 568         } catch (Throwable ex) {
 569             // Nasty.  If we've already reported an error, compensate
 570             // for buggy compiler error recovery by swallowing thrown
 571             // exceptions.
 572             if (comp == null || comp.errorCount() == 0 ||
 573                 options == null || options.isSet("dev"))
 574                 bugMessage(ex);
 575             return Result.ABNORMAL;
 576         } finally {
 577             if (comp != null) {
 578                 try {
 579                     comp.close();
 580                 } catch (ClientCodeException ex) {
 581                     throw new RuntimeException(ex.getCause());
 582                 }
 583             }
 584             filenames = null;
 585             options = null;
 586         }
 587         return Result.OK;
 588     }
 589 
 590     /** Print a message reporting an internal error.
 591      */
 592     void bugMessage(Throwable ex) {
 593         log.printLines(PrefixKind.JAVAC, "msg.bug", JavaCompiler.version());
 594         ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
 595     }
 596 
 597     /** Print a message reporting a fatal error.
 598      */
 599     void feMessage(Throwable ex) {
 600         log.printRawLines(ex.getMessage());
 601         if (ex.getCause() != null && options.isSet("dev")) {
 602             ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
 603         }
 604     }
 605 
 606     /** Print a message reporting an input/output error.
 607      */
 608     void ioMessage(Throwable ex) {
 609         log.printLines(PrefixKind.JAVAC, "msg.io");
 610         ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
 611     }
 612 
 613     /** Print a message reporting an out-of-resources error.
 614      */
 615     void resourceMessage(Throwable ex) {
 616         log.printLines(PrefixKind.JAVAC, "msg.resource");
 617         ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
 618     }
 619 
 620     /** Print a message reporting an uncaught exception from an
 621      * annotation processor.
 622      */
 623     void apMessage(AnnotationProcessingError ex) {
 624         log.printLines(PrefixKind.JAVAC, "msg.proc.annotation.uncaught.exception");
 625         ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
 626     }
 627 
 628     /** Print a message reporting an uncaught exception from an
 629      * annotation processor.
 630      */
 631     void pluginMessage(Throwable ex) {
 632         log.printLines(PrefixKind.JAVAC, "msg.plugin.uncaught.exception");
 633         ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
 634     }
 635 
 636     /** Display the location and checksum of a class. */
 637     void showClass(String className) {
 638         PrintWriter pw = log.getWriter(WriterKind.NOTICE);
 639         pw.println("javac: show class: " + className);
 640         URL url = getClass().getResource('/' + className.replace('.', '/') + ".class");
 641         if (url == null)
 642             pw.println("  class not found");
 643         else {
 644             pw.println("  " + url);
 645             try {
 646                 final String algorithm = "MD5";
 647                 byte[] digest;
 648                 MessageDigest md = MessageDigest.getInstance(algorithm);
 649                 DigestInputStream in = new DigestInputStream(url.openStream(), md);
 650                 try {
 651                     byte[] buf = new byte[8192];
 652                     int n;
 653                     do { n = in.read(buf); } while (n > 0);
 654                     digest = md.digest();
 655                 } finally {
 656                     in.close();
 657                 }
 658                 StringBuilder sb = new StringBuilder();
 659                 for (byte b: digest)
 660                     sb.append(String.format("%02x", b));
 661                 pw.println("  " + algorithm + " checksum: " + sb);
 662             } catch (Exception e) {
 663                 pw.println("  cannot compute digest: " + e);
 664             }
 665         }
 666     }
 667 
 668     private JavaFileManager fileManager;
 669 
 670     /* ************************************************************************
 671      * Internationalization
 672      *************************************************************************/
 673 
 674 //    /** Find a localized string in the resource bundle.
 675 //     *  @param key     The key for the localized string.
 676 //     */
 677 //    public static String getLocalizedString(String key, Object... args) { // FIXME sb private
 678 //        try {
 679 //            if (messages == null)
 680 //                messages = new JavacMessages(javacBundleName);
 681 //            return messages.getLocalizedString("javac." + key, args);
 682 //        }
 683 //        catch (MissingResourceException e) {
 684 //            throw new Error("Fatal Error: Resource for javac is missing", e);
 685 //        }
 686 //    }
 687 //
 688 //    public static void useRawMessages(boolean enable) {
 689 //        if (enable) {
 690 //            messages = new JavacMessages(javacBundleName) {
 691 //                    @Override
 692 //                    public String getLocalizedString(String key, Object... args) {
 693 //                        return key;
 694 //                    }
 695 //                };
 696 //        } else {
 697 //            messages = new JavacMessages(javacBundleName);
 698 //        }
 699 //    }
 700 
 701     public static final String javacBundleName =
 702         "com.sun.tools.javac.resources.javac";
 703 //
 704 //    private static JavacMessages messages;
 705 }