test/tools/launcher/Arrrghs.java

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
  27  *      6894719 6968053 7151434 7146424
  28  * @summary Argument parsing validation.
  29  * @compile -XDignore.symbol.file Arrrghs.java
  30  * @run main/othervm Arrrghs
  31  */
  32 
  33 import java.io.BufferedReader;
  34 import java.io.File;
  35 import java.io.FileNotFoundException;
  36 import java.io.IOException;
  37 import java.io.InputStream;
  38 import java.io.InputStreamReader;
  39 import java.util.ArrayList;
  40 import java.util.Arrays;
  41 import java.util.HashMap;
  42 import java.util.List;
  43 import java.util.Map;
  44 import java.util.regex.Matcher;
  45 import java.util.regex.Pattern;
  46 
  47 public class Arrrghs extends TestHelper {


 293         checkArgumentParsing("X\\Y\\Z", "X\\Y\\Z");
 294         checkArgumentParsing("\\X\\Y\\Z", "\\X\\Y\\Z");
 295 
 296         // literals within dangling quotes, etc.
 297         checkArgumentParsing("\"a b c\" d e", "a b c", "d", "e");
 298         checkArgumentParsing("\"ab\\\"c\"  \"\\\\\"  d", "ab\"c", "\\", "d");
 299         checkArgumentParsing("a\\\\\\c d\"e f\"g h", "a\\\\\\c", "de fg", "h");
 300         checkArgumentParsing("a\\\\\\\"b c d", "a\\\"b", "c", "d");
 301         checkArgumentParsing("a\\\\\\\\\"g c\" d e", "a\\\\g c", "d", "e");
 302 
 303         // treatment of back-slashes
 304         checkArgumentParsing("*\\", "*\\");
 305         checkArgumentParsing("*/", "*/");
 306         checkArgumentParsing(".\\*", ".\\*");
 307         checkArgumentParsing("./*", "./*");
 308         checkArgumentParsing("..\\..\\*", "..\\..\\*");
 309         checkArgumentParsing("../../*", "../../*");
 310         checkArgumentParsing("..\\..\\", "..\\..\\");
 311         checkArgumentParsing("../../", "../../");
 312         checkArgumentParsing("a b\\ c", "a", "b\\", "c");





 313     }
 314 
 315     private void initEmptyDir(File emptyDir) throws IOException {
 316         if (emptyDir.exists()) {
 317             recursiveDelete(emptyDir);
 318         }
 319         emptyDir.mkdir();
 320     }
 321 
 322     private void initDirWithJavaFiles(File libDir) throws IOException {
 323 
 324         if (libDir.exists()) {
 325             recursiveDelete(libDir);
 326         }
 327         libDir.mkdirs();
 328         ArrayList<String> scratchpad = new ArrayList<>();
 329         scratchpad.add("package lib;");
 330         scratchpad.add("public class Fbo {");
 331         scratchpad.add("public static void main(String... args){Foo.f();}");
 332         scratchpad.add("public static void f(){}");




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
  27  *      6894719 6968053 7151434 7146424 8007333
  28  * @summary Argument parsing validation.
  29  * @compile -XDignore.symbol.file Arrrghs.java
  30  * @run main/othervm Arrrghs
  31  */
  32 
  33 import java.io.BufferedReader;
  34 import java.io.File;
  35 import java.io.FileNotFoundException;
  36 import java.io.IOException;
  37 import java.io.InputStream;
  38 import java.io.InputStreamReader;
  39 import java.util.ArrayList;
  40 import java.util.Arrays;
  41 import java.util.HashMap;
  42 import java.util.List;
  43 import java.util.Map;
  44 import java.util.regex.Matcher;
  45 import java.util.regex.Pattern;
  46 
  47 public class Arrrghs extends TestHelper {


 293         checkArgumentParsing("X\\Y\\Z", "X\\Y\\Z");
 294         checkArgumentParsing("\\X\\Y\\Z", "\\X\\Y\\Z");
 295 
 296         // literals within dangling quotes, etc.
 297         checkArgumentParsing("\"a b c\" d e", "a b c", "d", "e");
 298         checkArgumentParsing("\"ab\\\"c\"  \"\\\\\"  d", "ab\"c", "\\", "d");
 299         checkArgumentParsing("a\\\\\\c d\"e f\"g h", "a\\\\\\c", "de fg", "h");
 300         checkArgumentParsing("a\\\\\\\"b c d", "a\\\"b", "c", "d");
 301         checkArgumentParsing("a\\\\\\\\\"g c\" d e", "a\\\\g c", "d", "e");
 302 
 303         // treatment of back-slashes
 304         checkArgumentParsing("*\\", "*\\");
 305         checkArgumentParsing("*/", "*/");
 306         checkArgumentParsing(".\\*", ".\\*");
 307         checkArgumentParsing("./*", "./*");
 308         checkArgumentParsing("..\\..\\*", "..\\..\\*");
 309         checkArgumentParsing("../../*", "../../*");
 310         checkArgumentParsing("..\\..\\", "..\\..\\");
 311         checkArgumentParsing("../../", "../../");
 312         checkArgumentParsing("a b\\ c", "a", "b\\", "c");
 313         checkArgumentParsing("\\\\?", "\\\\?");
 314         
 315         // more treatment of  mixed slashes
 316         checkArgumentParsing("f1/ f3\\ f4/", "f1/", "f3\\", "f4/");
 317         checkArgumentParsing("f1/ f2\' ' f3/ f4/", "f1/", "f2\'", "'", "f3/", "f4/");
 318     }
 319 
 320     private void initEmptyDir(File emptyDir) throws IOException {
 321         if (emptyDir.exists()) {
 322             recursiveDelete(emptyDir);
 323         }
 324         emptyDir.mkdir();
 325     }
 326 
 327     private void initDirWithJavaFiles(File libDir) throws IOException {
 328 
 329         if (libDir.exists()) {
 330             recursiveDelete(libDir);
 331         }
 332         libDir.mkdirs();
 333         ArrayList<String> scratchpad = new ArrayList<>();
 334         scratchpad.add("package lib;");
 335         scratchpad.add("public class Fbo {");
 336         scratchpad.add("public static void main(String... args){Foo.f();}");
 337         scratchpad.add("public static void f(){}");