Arrrghs.java revision 2362
196N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 304N/A * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 0N/A * @summary Argument parsing validation. 0N/A * This class provides various tests for arguments processing. 0N/A * A group of tests to ensure that arguments are passed correctly to 0N/A * a child java process upon a re-exec, this typically happens when 0N/A * a version other than the one being executed is requested by the user. 0N/A * History: these set of tests were part of Arrrghs.sh. The MKS shell 0N/A * implementations were notoriously buggy. Implementing these tests purely 0N/A * in Java is not only portable but also robust. 0N/A // The version string to force a re-exec 0N/A // The Cookie or the pattern we match in the debug output. 0N/A * SIGH, On Windows all strings are quoted, we need to unwrap it 0N/A // Trim the string and remove the enclosed quotes if any. 304N/A * This method detects the cookie in the output stream of the process. 304N/A // Return the value asap if not in debug mode. 0N/A * This method return true if the expected and detected arguments are the same. 304N/A * Quoting could cause dissimilar testArguments and expected arguments. 0N/A * A convenience method for identical test pattern and expected arguments 0N/A * These tests require that a JVM (any JVM) be installed in the system registry. 0N/A * If none is installed, skip this test. 0N/A "no java found in system registry.");
0N/A // Basic test with many spaces 0N/A // Quoted whitespace does matter ? 0N/A // Escaped quotes outside of quotes as literals 0N/A // Check for escaped quotes inside of quotes as literal 0N/A // A quote preceeded by an odd number of slashes is a literal quote 304N/A // A quote preceeded by an even number of slashes is a literal quote 304N/A // Make sure that whitespace doesn't interfere with the removal of the 304N/A // appropriate tokens. (space-tab-space preceeds -jre-restict-search). 304N/A // Make sure that the mJRE tokens being stripped, aren't stripped if 304N/A // they happen to appear as arguments to the main class. 0N/A * These tests are usually run on non-existent targets to check error results 0N/A // Tests for 5030233 0N/A // Test for 6356475 "REGRESSION:"java -X" from cmdline fails" 0N/A * A set of tests which tests various dispositions of the main method. 0N/A // use classpath to check 304N/A // incorrect method access 304N/A "private static void main(String[] args){}");
304N/A // use classpath to check 304N/A // incorrect return type 304N/A "public static int main(String[] args){return 1;}");
304N/A tr.
contains(
"Error: Main method must return a value of type void in class Foo");
0N/A // use classpath to check 0N/A tr.
contains(
"Error: Main method must return a value of type void in class Foo");
0N/A // incorrect parameter type 0N/A "public static void main(Object[] args){}");
0N/A // use classpath to check 0N/A // incorrect method type - non-static 304N/A "public void main(String[] args){}");
304N/A // use classpath to check 0N/A // amongst a potpourri of kindred main methods, is the right one chosen ? 0N/A "void main(Object[] args){}",
304N/A "int main(Float[] args){return 1;}",
0N/A "private void main() {}",
0N/A "private static void main(int x) {}",
304N/A "public int main(int argc, String[] argv) {return 1;}",
304N/A "public static void main(String[] args) {System.out.println(\"THE_CHOSEN_ONE\");}");
0N/A // use classpath to check 0N/A // test for extraneous whitespace in the Main-Class attribute 0N/A "public static void main(String... args){}");
304N/A * @param args the command line arguments 0N/A * @throws java.io.FileNotFoundException