src/jdk.jpackage/share/classes/jdk/jpackage/main/CommandLine.java
author herrick
Mon, 01 Jul 2019 18:43:02 -0400
branchJDK-8200758-branch
changeset 57447 3fbe47a62ed0
parent 57438 4a31db8d42bd
child 57909 c7de06ed4b54
permissions -rw-r--r--
8226751: "Exception: ..." for missing file Reviewed-by: almatvee, kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     1
/*
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     2
 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     4
 *
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    10
 *
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    15
 * accompanied this code).
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    16
 *
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    20
 *
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    23
 * questions.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    24
 */
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    25
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    26
package jdk.jpackage.main;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    27
57447
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    28
import java.io.FileNotFoundException;
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    29
import java.io.IOException;
57447
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    30
import java.io.File;
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    31
import java.io.Reader;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    32
import java.nio.charset.Charset;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    33
import java.nio.file.Files;
57447
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    34
import java.nio.file.Path;
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    35
import java.nio.file.Paths;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    36
import java.util.ArrayList;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    37
import java.util.Arrays;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    38
import java.util.List;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    39
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    40
/**
57447
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    41
 * This file was originally a copy of CommandLine.java in
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    42
 * com.sun.tools.javac.main.
57391
970f28090a06 8223334: Additional cleanup in jpackage tool
herrick
parents: 57214
diff changeset
    43
 * It should track changes made to that file.
970f28090a06 8223334: Additional cleanup in jpackage tool
herrick
parents: 57214
diff changeset
    44
 */
970f28090a06 8223334: Additional cleanup in jpackage tool
herrick
parents: 57214
diff changeset
    45
970f28090a06 8223334: Additional cleanup in jpackage tool
herrick
parents: 57214
diff changeset
    46
/**
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    47
 * Various utility methods for processing Java tool command line arguments.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    48
 *
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    49
 *  <p><b>This is NOT part of any supported API.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    50
 *  If you write code that depends on this, you do so at your own risk.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    51
 *  This code and its internal interfaces are subject to change or
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    52
 *  deletion without notice.</b>
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    53
 */
57404
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents: 57391
diff changeset
    54
class CommandLine {
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    55
    /**
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    56
     * Process Win32-style command files for the specified command line
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    57
     * arguments and return the resulting arguments. A command file argument
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    58
     * is of the form '@file' where 'file' is the name of the file whose
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    59
     * contents are to be parsed for additional arguments. The contents of
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    60
     * the command file are parsed using StreamTokenizer and the original
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    61
     * '@file' argument replaced with the resulting tokens. Recursive command
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    62
     * files are not supported. The '@' character itself can be quoted with
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    63
     * the sequence '@@'.
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    64
     * @param args the arguments that may contain @files
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    65
     * @return the arguments, with @files expanded
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    66
     * @throws IOException if there is a problem reading any of the @files
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    67
     */
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    68
    public static String[] parse(String[] args) throws IOException {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    69
        List<String> newArgs = new ArrayList<>();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    70
        appendParsedCommandArgs(newArgs, Arrays.asList(args));
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    71
        return newArgs.toArray(new String[newArgs.size()]);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    72
    }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    73
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    74
    private static void appendParsedCommandArgs(List<String> newArgs, List<String> args) throws IOException {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    75
        for (String arg : args) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    76
            if (arg.length() > 1 && arg.charAt(0) == '@') {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    77
                arg = arg.substring(1);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    78
                if (arg.charAt(0) == '@') {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    79
                    newArgs.add(arg);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    80
                } else {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    81
                    loadCmdFile(arg, newArgs);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    82
                }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    83
            } else {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    84
                newArgs.add(arg);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    85
            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    86
        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    87
    }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    88
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    89
    private static void loadCmdFile(String name, List<String> args) throws IOException {
57447
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    90
        if (!Files.isReadable(Path.of(name))) {
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    91
            throw new FileNotFoundException(name);
3fbe47a62ed0 8226751: "Exception: ..." for missing file
herrick
parents: 57438
diff changeset
    92
        }
57214
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    93
        try (Reader r = Files.newBufferedReader(Paths.get(name), Charset.defaultCharset())) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    94
            Tokenizer t = new Tokenizer(r);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    95
            String s;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    96
            while ((s = t.nextToken()) != null) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    97
                args.add(s);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    98
            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
    99
        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   100
    }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   101
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   102
    public static class Tokenizer {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   103
        private final Reader in;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   104
        private int ch;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   105
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   106
        public Tokenizer(Reader in) throws IOException {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   107
            this.in = in;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   108
            ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   109
        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   110
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   111
        public String nextToken() throws IOException {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   112
            skipWhite();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   113
            if (ch == -1) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   114
                return null;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   115
            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   116
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   117
            StringBuilder sb = new StringBuilder();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   118
            char quoteChar = 0;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   119
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   120
            while (ch != -1) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   121
                switch (ch) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   122
                    case ' ':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   123
                    case '\t':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   124
                    case '\f':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   125
                        if (quoteChar == 0) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   126
                            return sb.toString();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   127
                        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   128
                        sb.append((char) ch);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   129
                        break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   130
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   131
                    case '\n':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   132
                    case '\r':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   133
                        return sb.toString();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   134
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   135
                    case '\'':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   136
                    case '"':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   137
                        if (quoteChar == 0) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   138
                            quoteChar = (char) ch;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   139
                        } else if (quoteChar == ch) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   140
                            quoteChar = 0;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   141
                        } else {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   142
                            sb.append((char) ch);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   143
                        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   144
                        break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   145
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   146
                    case '\\':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   147
                        if (quoteChar != 0) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   148
                            ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   149
                            switch (ch) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   150
                                case '\n':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   151
                                case '\r':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   152
                                    while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f') {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   153
                                        ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   154
                                    }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   155
                                    continue;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   156
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   157
                                case 'n':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   158
                                    ch = '\n';
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   159
                                    break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   160
                                case 'r':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   161
                                    ch = '\r';
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   162
                                    break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   163
                                case 't':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   164
                                    ch = '\t';
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   165
                                    break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   166
                                case 'f':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   167
                                    ch = '\f';
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   168
                                    break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   169
                            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   170
                        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   171
                        sb.append((char) ch);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   172
                        break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   173
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   174
                    default:
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   175
                        sb.append((char) ch);
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   176
                }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   177
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   178
                ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   179
            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   180
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   181
            return sb.toString();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   182
        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   183
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   184
        void skipWhite() throws IOException {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   185
            while (ch != -1) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   186
                switch (ch) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   187
                    case ' ':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   188
                    case '\t':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   189
                    case '\n':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   190
                    case '\r':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   191
                    case '\f':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   192
                        break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   193
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   194
                    case '#':
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   195
                        ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   196
                        while (ch != '\n' && ch != '\r' && ch != -1) {
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   197
                            ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   198
                        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   199
                        break;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   200
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   201
                    default:
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   202
                        return;
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   203
                }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   204
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   205
                ch = in.read();
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   206
            }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   207
        }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   208
    }
cb63761b7079 8219695: Use a copy of javac's implementation of @argfile in jpackager
herrick
parents:
diff changeset
   209
}