Arrrghs.java revision 0
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
public class Arrrghs{
/**
* A group of tests to ensure that arguments are passed correctly to
* a child java process upon a re-exec, this typically happens when
* a version other than the one being executed is requested by the user.
*
* History: these set of tests were part of Arrrghs.sh. The MKS shell
* implementations are notoriously buggy. Implementing these tests purely
* in Java is not only portable but also robust.
*
*/
/* Do not instantiate */
private Arrrghs() {}
// The version string to force a re-exec
// The Cookie or the pattern we match in the debug output.
private static int exitValue = 0;
}
/*
* SIGH, On Windows all strings are quoted, we need to unwrap it
*/
if (isWindows) {
// Trim the string and remove the enclosed quotes if any.
}
}
return in;
}
/*
* This method detects the cookie in the output stream of the process.
*/
private static boolean detectCookie(InputStream istream, String expectedArguments) throws IOException {
boolean retval = false;
retval = true;
} else {
}
// Return the value asap if not in debug mode.
if (!_debug) {
return retval;
}
}
}
return retval;
}
boolean retval = false;
try {
p.waitFor();
p.destroy();
}
return retval;
}
/**
* This method return true if the expected and detected arguments are the same.
* Quoting could cause dissimilar testArguments and expected arguments.
*/
}
/**
* A convenience method for identical test pattern and expected arguments
*/
}
/**
* @param args the command line arguments
*/
doUsage("Invalid number of arguments");
}
} else {
doUsage("The java executable must exist");
}
}
// Basic test
// Basic test with many spaces
// Quoted whitespace does matter ?
// Escaped quotes outside of quotes as literals
// Check for escaped quotes inside of quotes as literal
// A quote preceeded by an odd number of slashes is a literal quote
// A quote preceeded by an even number of slashes is a literal quote
// see 6214916.
// Make sure that whitespace doesn't interfere with the removal of the
// appropriate tokens. (space-tab-space preceeds -jre-restict-search).
// Make sure that the mJRE tokens being stripped, aren't stripped if
// they happen to appear as arguments to the main class.
System.out.println("Completed Arrrghs arguments quoting/matching tests with " + exitValue + " errors");
}
}