< prev index next > test/jdk/java/lang/ProcessBuilder/Basic.java
Print this page
* @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
* 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517
! * 8352533
* @key intermittent
* @summary Basic tests for Process and Environment Variable code
* @modules java.base/java.lang:open
* java.base/java.io:open
* @requires !vm.musl
* @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
* 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517
! * 8352533 8368192
* @key intermittent
* @summary Basic tests for Process and Environment Variable code
* @modules java.base/java.lang:open
* java.base/java.io:open
* @requires !vm.musl
private static boolean matches(String str, String regex) {
return Pattern.compile(regex).matcher(str).find();
}
! private static String matchAndExtract(String str, String regex) {
! Matcher matcher = Pattern.compile(regex).matcher(str);
! if (matcher.find()) {
! return matcher.group();
! } else {
- return "";
- }
}
/* Only used for Mac OS X --
! * Mac OS X (may) add the variable __CF_USER_TEXT_ENCODING to an empty
! * environment. The environment variable JAVA_MAIN_CLASS_<pid> may also
! * be set in Mac OS X.
- * Remove them both from the list of env variables
*/
private static String removeMacExpectedVars(String vars) {
// Check for __CF_USER_TEXT_ENCODING
! String cleanedVars = vars.replace("__CF_USER_TEXT_ENCODING="
! +cfUserTextEncoding+",","");
// Check for JAVA_MAIN_CLASS_<pid>
! String javaMainClassStr
! = matchAndExtract(cleanedVars,
! "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,");
! return cleanedVars.replace(javaMainClassStr,"");
}
/* Only used for AIX --
* AIX adds the variable AIXTHREAD_GUARDPAGES=0 to the environment.
* Remove it from the list of env variables
private static boolean matches(String str, String regex) {
return Pattern.compile(regex).matcher(str).find();
}
! // Return the string with the matching regex removed
! private static String matchAndRemove(String str, String regex) {
! return Pattern.compile(regex)
! .matcher(str)
! .replaceAll("");
}
/* Only used for Mac OS X --
! * Mac OS X (may) add the variables: __CF_USER_TEXT_ENCODING, JAVA_MAIN_CLASS_<pid>,
! * and TMPDIR.
! * Remove them from the list of env variables
*/
private static String removeMacExpectedVars(String vars) {
// Check for __CF_USER_TEXT_ENCODING
! String cleanedVars = matchAndRemove(vars,
! "__CF_USER_TEXT_ENCODING=" + cfUserTextEncoding + ",");
// Check for JAVA_MAIN_CLASS_<pid>
! cleanedVars = matchAndRemove(cleanedVars,
! "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,");
! // Check and remove TMPDIR
! cleanedVars = matchAndRemove(cleanedVars,
+ "TMPDIR=[^,]*,");
+ return cleanedVars;
}
/* Only used for AIX --
* AIX adds the variable AIXTHREAD_GUARDPAGES=0 to the environment.
* Remove it from the list of env variables
< prev index next >