langtools/src/share/classes/com/sun/tools/apt/main/Main.java
changeset 11053 48713f779b1d
parent 10818 e95eb04c68cc
equal deleted inserted replaced
11052:65b9fa7eaf55 11053:48713f779b1d
   203 
   203 
   204         void help() {
   204         void help() {
   205             String s = "  " + helpSynopsis();
   205             String s = "  " + helpSynopsis();
   206             out.print(s);
   206             out.print(s);
   207             for (int j = s.length(); j < 29; j++) out.print(" ");
   207             for (int j = s.length(); j < 29; j++) out.print(" ");
   208             Bark.printLines(out, getLocalizedString(descrKey));
   208             Bark.printRawLines(out, getLocalizedString(descrKey));
   209         }
   209         }
   210 
   210 
   211     }
   211     }
   212 
   212 
   213     private class AptOption extends Option {
   213     private class AptOption extends Option {
   225          */
   225          */
   226         void help() {
   226         void help() {
   227             String s = "  " + helpSynopsis();
   227             String s = "  " + helpSynopsis();
   228             out.print(s);
   228             out.print(s);
   229             for (int j = s.length(); j < 29; j++) out.print(" ");
   229             for (int j = s.length(); j < 29; j++) out.print(" ");
   230             Bark.printLines(out, getLocalizedString(descrKey));
   230             Bark.printRawLines(out, getLocalizedString(descrKey));
   231         }
   231         }
   232 
   232 
   233     }
   233     }
   234 
   234 
   235     /** A nonstandard or extended (-X) option
   235     /** A nonstandard or extended (-X) option
   257         }
   257         }
   258         void xhelp() {
   258         void xhelp() {
   259             String s = "  " + helpSynopsis();
   259             String s = "  " + helpSynopsis();
   260             out.print(s);
   260             out.print(s);
   261             for (int j = s.length(); j < 29; j++) out.print(" ");
   261             for (int j = s.length(); j < 29; j++) out.print(" ");
   262             Log.printLines(out, getLocalizedString(descrKey));
   262             Log.printRawLines(out, getLocalizedString(descrKey));
   263         }
   263         }
   264     };
   264     };
   265 
   265 
   266     /** A hidden (implementor) option
   266     /** A hidden (implementor) option
   267      */
   267      */
   419                 return super.process(option, operand);
   419                 return super.process(option, operand);
   420             }
   420             }
   421         },
   421         },
   422         new AptOption("-version",               "opt.version") {
   422         new AptOption("-version",               "opt.version") {
   423             boolean process(String option) {
   423             boolean process(String option) {
   424                 Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
   424                 Bark.printRawLines(out, ownName + " " + AptJavaCompiler.version());
   425                 return super.process(option);
   425                 return super.process(option);
   426             }
   426             }
   427         },
   427         },
   428         new HiddenOption("-fullversion"),
   428         new HiddenOption("-fullversion"),
   429         new AptOption("-help",                                  "opt.help") {
   429         new AptOption("-help",                                  "opt.help") {
   658 
   658 
   659 
   659 
   660     /** Print a string that explains usage.
   660     /** Print a string that explains usage.
   661      */
   661      */
   662     void help() {
   662     void help() {
   663         Bark.printLines(out, getLocalizedString("msg.usage.header", ownName));
   663         Bark.printRawLines(out, getLocalizedString("msg.usage.header", ownName));
   664         for (int i=0; i < recognizedOptions.length; i++) {
   664         for (int i=0; i < recognizedOptions.length; i++) {
   665             recognizedOptions[i].help();
   665             recognizedOptions[i].help();
   666         }
   666         }
   667         Bark.printLines(out, getLocalizedString("msg.usage.footer"));
   667         Bark.printRawLines(out, getLocalizedString("msg.usage.footer"));
   668         out.println();
   668         out.println();
   669     }
   669     }
   670 
   670 
   671     /** Print a string that explains usage for X options.
   671     /** Print a string that explains usage for X options.
   672      */
   672      */
   673     void xhelp() {
   673     void xhelp() {
   674         for (int i=0; i<recognizedOptions.length; i++) {
   674         for (int i=0; i<recognizedOptions.length; i++) {
   675             recognizedOptions[i].xhelp();
   675             recognizedOptions[i].xhelp();
   676         }
   676         }
   677         out.println();
   677         out.println();
   678         Bark.printLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
   678         Bark.printRawLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
   679     }
   679     }
   680 
   680 
   681     /** Report a usage error.
   681     /** Report a usage error.
   682      */
   682      */
   683     void error(String key, Object... args) {
   683     void error(String key, Object... args) {
   686     }
   686     }
   687 
   687 
   688     /** Report a warning.
   688     /** Report a warning.
   689      */
   689      */
   690     void warning(String key, Object... args) {
   690     void warning(String key, Object... args) {
   691         Bark.printLines(out, ownName + ": "
   691         Bark.printRawLines(out, ownName + ": "
   692                        + getLocalizedString(key, args));
   692                        + getLocalizedString(key, args));
   693     }
   693     }
   694 
   694 
   695     /** Process command line arguments: store all command line options
   695     /** Process command line arguments: store all command line options
   696      *  in `options' table and return all source filenames.
   696      *  in `options' table and return all source filenames.
   794             // assign args the result of parse to capture results of
   794             // assign args the result of parse to capture results of
   795             // '@file' expansion
   795             // '@file' expansion
   796             origFilenames = processArgs((args=CommandLine.parse(args)));
   796             origFilenames = processArgs((args=CommandLine.parse(args)));
   797 
   797 
   798             if (options.get("suppress-tool-api-removal-message") == null) {
   798             if (options.get("suppress-tool-api-removal-message") == null) {
   799                 Bark.printLines(out, getLocalizedString("misc.Deprecation"));
   799                 Bark.printRawLines(out, getLocalizedString("misc.Deprecation"));
   800             }
   800             }
   801 
   801 
   802             if (origFilenames == null) {
   802             if (origFilenames == null) {
   803                 return EXIT_CMDERR;
   803                 return EXIT_CMDERR;
   804             } else if (origFilenames.size() == 0) {
   804             } else if (origFilenames.size() == 0) {
   806                 if (options.get("-help") != null ||
   806                 if (options.get("-help") != null ||
   807                     options.get("-X") != null)
   807                     options.get("-X") != null)
   808                     return EXIT_OK;
   808                     return EXIT_OK;
   809             }
   809             }
   810         } catch (java.io.FileNotFoundException e) {
   810         } catch (java.io.FileNotFoundException e) {
   811             Bark.printLines(out, ownName + ": " +
   811             Bark.printRawLines(out, ownName + ": " +
   812                            getLocalizedString("err.file.not.found",
   812                            getLocalizedString("err.file.not.found",
   813                                               e.getMessage()));
   813                                               e.getMessage()));
   814             return EXIT_SYSERR;
   814             return EXIT_SYSERR;
   815         } catch (IOException ex) {
   815         } catch (IOException ex) {
   816             ioMessage(ex);
   816             ioMessage(ex);
  1181     }
  1181     }
  1182 
  1182 
  1183     /** Print a message reporting an internal error.
  1183     /** Print a message reporting an internal error.
  1184      */
  1184      */
  1185     void bugMessage(Throwable ex) {
  1185     void bugMessage(Throwable ex) {
  1186         Bark.printLines(out, getLocalizedString("msg.bug",
  1186         Bark.printRawLines(out, getLocalizedString("msg.bug",
  1187                                                AptJavaCompiler.version()));
  1187                                                AptJavaCompiler.version()));
  1188         ex.printStackTrace(out);
  1188         ex.printStackTrace(out);
  1189     }
  1189     }
  1190 
  1190 
  1191     /** Print a message reporting an fatal error.
  1191     /** Print a message reporting an fatal error.
  1192      */
  1192      */
  1193     void apMessage(AnnotationProcessingError ex) {
  1193     void apMessage(AnnotationProcessingError ex) {
  1194         Bark.printLines(out, getLocalizedString("misc.Problem"));
  1194         Bark.printRawLines(out, getLocalizedString("misc.Problem"));
  1195         ex.getCause().printStackTrace(out);
  1195         ex.getCause().printStackTrace(out);
  1196     }
  1196     }
  1197 
  1197 
  1198     /** Print a message about sun.misc.Service problem.
  1198     /** Print a message about sun.misc.Service problem.
  1199      */
  1199      */
  1200     void sceMessage(sun.misc.ServiceConfigurationError ex) {
  1200     void sceMessage(sun.misc.ServiceConfigurationError ex) {
  1201         Bark.printLines(out, getLocalizedString("misc.SunMiscService"));
  1201         Bark.printRawLines(out, getLocalizedString("misc.SunMiscService"));
  1202         ex.printStackTrace(out);
  1202         ex.printStackTrace(out);
  1203     }
  1203     }
  1204 
  1204 
  1205     /** Print a message reporting an fatal error.
  1205     /** Print a message reporting an fatal error.
  1206      */
  1206      */
  1207     void feMessage(Throwable ex) {
  1207     void feMessage(Throwable ex) {
  1208         Bark.printLines(out, ex.toString());
  1208         Bark.printRawLines(out, ex.toString());
  1209     }
  1209     }
  1210 
  1210 
  1211     /** Print a message reporting an input/output error.
  1211     /** Print a message reporting an input/output error.
  1212      */
  1212      */
  1213     void ioMessage(Throwable ex) {
  1213     void ioMessage(Throwable ex) {
  1214         Bark.printLines(out, getLocalizedString("msg.io"));
  1214         Bark.printRawLines(out, getLocalizedString("msg.io"));
  1215         ex.printStackTrace(out);
  1215         ex.printStackTrace(out);
  1216     }
  1216     }
  1217 
  1217 
  1218     /** Print a message reporting an out-of-resources error.
  1218     /** Print a message reporting an out-of-resources error.
  1219      */
  1219      */
  1220     void resourceMessage(Throwable ex) {
  1220     void resourceMessage(Throwable ex) {
  1221         Bark.printLines(out, getLocalizedString("msg.resource"));
  1221         Bark.printRawLines(out, getLocalizedString("msg.resource"));
  1222         ex.printStackTrace(out);
  1222         ex.printStackTrace(out);
  1223     }
  1223     }
  1224 
  1224 
  1225     /* ************************************************************************
  1225     /* ************************************************************************
  1226      * Internationalization
  1226      * Internationalization