< prev index next >

src/jdk/nashorn/internal/runtime/options/Options.java

Print this page
rev 1367 : 8081156: jjs "nashorn.args" system property is not effective when script arguments are passed
Reviewed-by: hannesw, lagergren


 407      */
 408     public void displayHelp(final boolean extended) {
 409         for (final OptionTemplate t : Options.validOptions) {
 410             if ((extended || !t.isUndocumented()) && t.getResource().equals(resource)) {
 411                 err.println(t);
 412                 err.println();
 413             }
 414         }
 415     }
 416 
 417     /**
 418      * Processes the arguments and stores their information. Throws
 419      * IllegalArgumentException on error. The message can be analyzed by the
 420      * displayHelp function to become more context sensitive
 421      *
 422      * @param args arguments from command line
 423      */
 424     public void process(final String[] args) {
 425         final LinkedList<String> argList = new LinkedList<>();
 426         addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList);


 427         Collections.addAll(argList, args);


 428         addSystemProperties(NASHORN_ARGS_PROPERTY, argList);



 429 

 430         while (!argList.isEmpty()) {
 431             final String arg = argList.remove(0);
 432 
 433             // skip empty args
 434             if (arg.isEmpty()) {
 435                 continue;
 436             }
 437 
 438             // user arguments to the script
 439             if ("--".equals(arg)) {
 440                 arguments.addAll(argList);
 441                 argList.clear();
 442                 continue;
 443             }
 444 
 445             // If it doesn't start with -, it's a file. But, if it is just "-",
 446             // then it is a file representing standard input.
 447             if (!arg.startsWith("-") || arg.length() == 1) {
 448                 files.add(arg);
 449                 continue;




 407      */
 408     public void displayHelp(final boolean extended) {
 409         for (final OptionTemplate t : Options.validOptions) {
 410             if ((extended || !t.isUndocumented()) && t.getResource().equals(resource)) {
 411                 err.println(t);
 412                 err.println();
 413             }
 414         }
 415     }
 416 
 417     /**
 418      * Processes the arguments and stores their information. Throws
 419      * IllegalArgumentException on error. The message can be analyzed by the
 420      * displayHelp function to become more context sensitive
 421      *
 422      * @param args arguments from command line
 423      */
 424     public void process(final String[] args) {
 425         final LinkedList<String> argList = new LinkedList<>();
 426         addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList);
 427         processArgList(argList);
 428         assert argList.isEmpty();
 429         Collections.addAll(argList, args);
 430         processArgList(argList);
 431         assert argList.isEmpty();
 432         addSystemProperties(NASHORN_ARGS_PROPERTY, argList);
 433         processArgList(argList);
 434         assert argList.isEmpty();
 435     }
 436 
 437     private void processArgList(final LinkedList<String> argList) {
 438         while (!argList.isEmpty()) {
 439             final String arg = argList.remove(0);
 440 
 441             // skip empty args
 442             if (arg.isEmpty()) {
 443                 continue;
 444             }
 445 
 446             // user arguments to the script
 447             if ("--".equals(arg)) {
 448                 arguments.addAll(argList);
 449                 argList.clear();
 450                 continue;
 451             }
 452 
 453             // If it doesn't start with -, it's a file. But, if it is just "-",
 454             // then it is a file representing standard input.
 455             if (!arg.startsWith("-") || arg.length() == 1) {
 456                 files.add(arg);
 457                 continue;


< prev index next >