/*
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8012453 8016046
* @summary workaround for legacy applications with Runtime.getRuntime().exec(String command)
*/
public class ExecCommand {
{
? 0
if (length > 1
{
}
return str;
}
{
return;
}
}
}
// Parameters for the Runtime.exec calls
"cmd /C dir > dirOut.txt",
"cmd /C dir > \".\\Program Files\\dirOut.txt\"",
".\\Program Files\\do.cmd",
"\".\\Program Files\\doNot.cmd\" arg",
"\".\\Program Files\\do.cmd\" arg",
// compatibility
"\".\\Program.cmd\" arg",
".\\Program.cmd arg",
};
".\\Program.cmd",
".\\Program Files\\doNot.cmd",
".\\Program Files\\do.cmd",
};
// Golden image for results
//Def Legacy mode, Enforced mode, Set Legacy mode, Set Legacy mode & SM
// [cmd /C dir > dirOut.txt]
new String[]{"Success",
"IOException", // [cmd /C dir ">" dirOut.txt] no redirection
"Success",
"IOException"}, //SM - no legacy mode, bad command
// [cmd /C dir > ".\Program Files\dirOut.txt"]
new String[]{"Success",
"IOException", // [cmd /C dir ">" ".\Program Files\dirOut.txt"] no redirection
"Success",
"IOException"}, //SM - no legacy mode, bad command
// [.\Program File\do.cmd]
new String[]{"Success",
"IOException", // [.\Program] not found
"Success",
"IOException"}, //SM - no legacy mode [.\Program] - OK
// [".\Program File\doNot.cmd" arg]
new String[]{"Success",
"Success",
"Success",
"AccessControlException"}, //SM - [".\Program] - OK,
// [.\\Program Files\\doNot.cmd] - Fail
// [".\Program File\do.cmd" arg]
// AccessControlException
new String[]{"Success",
"Success",
"Success",
"Success"}, //SM - [".\Program] - OK,
// [.\\Program Files\\do.cmd] - OK
// compatibility
};
try {
} catch (IOException ex) {
//that is OK
}
}
throw new FileNotFoundException(path);
}
return;
}
// tear up
try {
new FileWriter(doCmdCopy[i]))) {
}
}
} catch (IOException e) {
throw new Error(e.getMessage());
}
// action
for (int k = 0; k < 4; ++k) {
switch (k) {
case 0:
// the "jdk.lang.Process.allowAmbiguousCommands" is undefined
// "true" by default with the legacy verification procedure
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
try {
// tear up
switch (i) {
case 0:
// [cmd /C dir > dirOut.txt]
deleteOut(".\\dirOut.txt");
break;
case 1:
// [cmd /C dir > ".\Program Files\dirOut.txt"]
deleteOut(".\\Program Files\\dirOut.txt");
break;
}
//exteded check
switch (i) {
case 0:
// [cmd /C dir > dirOut.txt]
checkOut(".\\dirOut.txt");
break;
case 1:
// [cmd /C dir > ".\Program Files\dirOut.txt"]
checkOut(".\\Program Files\\dirOut.txt");
break;
}
outRes = "Success";
} catch (IOException ioe) {
} catch (IllegalArgumentException iae) {
} catch (AccessControlException se) {
}
+ "\nArgument: " + TEST_RTE_ARG[i]
+ "\nExpected: " + TEST_RTE_GI[i][k]
+ "\n Output: " + outRes);
} else {
}
}
}
}
}