24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javah; |
26 package com.sun.tools.javah; |
27 |
27 |
28 import java.io.File; |
28 import java.io.File; |
|
29 import java.io.FileNotFoundException; |
29 import java.io.IOException; |
30 import java.io.IOException; |
30 import java.io.OutputStream; |
31 import java.io.OutputStream; |
31 import java.io.PrintWriter; |
32 import java.io.PrintWriter; |
32 import java.io.Writer; |
33 import java.io.Writer; |
33 import java.text.MessageFormat; |
34 import java.text.MessageFormat; |
72 import javax.tools.StandardLocation; |
73 import javax.tools.StandardLocation; |
73 import javax.tools.ToolProvider; |
74 import javax.tools.ToolProvider; |
74 import static javax.tools.Diagnostic.Kind.*; |
75 import static javax.tools.Diagnostic.Kind.*; |
75 |
76 |
76 import com.sun.tools.javac.code.Symbol.CompletionFailure; |
77 import com.sun.tools.javac.code.Symbol.CompletionFailure; |
|
78 import com.sun.tools.javac.main.CommandLine; |
77 |
79 |
78 /** |
80 /** |
79 * Javah generates support files for native methods. |
81 * Javah generates support files for native methods. |
80 * Parse commandline options & Invokes javadoc to execute those commands. |
82 * Parse commandline options & Invokes javadoc to execute those commands. |
81 * |
83 * |
360 } |
362 } |
361 |
363 |
362 if (fileManager == null) |
364 if (fileManager == null) |
363 fileManager = getDefaultFileManager(diagnosticListener, log); |
365 fileManager = getDefaultFileManager(diagnosticListener, log); |
364 |
366 |
365 Iterator<String> iter = args.iterator(); |
367 Iterator<String> iter = expandAtArgs(args).iterator(); |
366 noArgs = !iter.hasNext(); |
368 noArgs = !iter.hasNext(); |
367 |
369 |
368 while (iter.hasNext()) { |
370 while (iter.hasNext()) { |
369 String arg = iter.next(); |
371 String arg = iter.next(); |
370 if (arg.startsWith("-")) |
372 if (arg.startsWith("-")) |
412 |
414 |
413 if (fileManager.handleOption(name, rest)) |
415 if (fileManager.handleOption(name, rest)) |
414 return; |
416 return; |
415 |
417 |
416 throw new BadArgs("err.unknown.option", name).showUsage(true); |
418 throw new BadArgs("err.unknown.option", name).showUsage(true); |
|
419 } |
|
420 |
|
421 private Iterable<String> expandAtArgs(Iterable<String> args) throws BadArgs { |
|
422 try { |
|
423 List<String> l = new ArrayList<String>(); |
|
424 for (String arg: args) l.add(arg); |
|
425 return Arrays.asList(CommandLine.parse(l.toArray(new String[l.size()]))); |
|
426 } catch (FileNotFoundException e) { |
|
427 throw new BadArgs("at.args.file.not.found", e.getLocalizedMessage()); |
|
428 } catch (IOException e) { |
|
429 throw new BadArgs("at.args.io.exception", e.getLocalizedMessage()); |
|
430 } |
417 } |
431 } |
418 |
432 |
419 public Boolean call() { |
433 public Boolean call() { |
420 return run(); |
434 return run(); |
421 } |
435 } |
605 public String getMessage(Locale locale) { |
619 public String getMessage(Locale locale) { |
606 return JavahTask.this.getMessage(locale, key, args); |
620 return JavahTask.this.getMessage(locale, key, args); |
607 } |
621 } |
608 |
622 |
609 }; |
623 }; |
610 |
624 } |
611 } |
625 |
612 private String getMessage(String key, Object... args) { |
626 private String getMessage(String key, Object... args) { |
613 return getMessage(task_locale, key, args); |
627 return getMessage(task_locale, key, args); |
614 } |
628 } |
615 |
629 |
616 private String getMessage(Locale locale, String key, Object... args) { |
630 private String getMessage(Locale locale, String key, Object... args) { |