8296684: Improve String platform support
Reviewed-by: amenkov, michaelm, rhalade
This commit is contained in:
parent
14aad787a8
commit
b1c34c03d7
@ -136,6 +136,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
|||||||
*/
|
*/
|
||||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||||
assert args.length <= 3; // includes null
|
assert args.length <= 3; // includes null
|
||||||
|
checkNulls(args);
|
||||||
|
|
||||||
// did we detach?
|
// did we detach?
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -140,6 +140,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
|||||||
*/
|
*/
|
||||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||||
assert args.length <= 3; // includes null
|
assert args.length <= 3; // includes null
|
||||||
|
checkNulls(args);
|
||||||
|
|
||||||
// did we detach?
|
// did we detach?
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -136,6 +136,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
|||||||
*/
|
*/
|
||||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||||
assert args.length <= 3; // includes null
|
assert args.length <= 3; // includes null
|
||||||
|
checkNulls(args);
|
||||||
|
|
||||||
// did we detach?
|
// did we detach?
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -487,4 +487,14 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
|
|||||||
}
|
}
|
||||||
return attachTimeout;
|
return attachTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static void checkNulls(Object... args) {
|
||||||
|
for (Object arg : args) {
|
||||||
|
if (arg instanceof String s) {
|
||||||
|
if (s.indexOf(0) >= 0) {
|
||||||
|
throw new IllegalArgumentException("illegal null character in command");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
|||||||
throws AgentLoadException, IOException
|
throws AgentLoadException, IOException
|
||||||
{
|
{
|
||||||
assert args.length <= 3; // includes null
|
assert args.length <= 3; // includes null
|
||||||
|
checkNulls(args);
|
||||||
|
|
||||||
// create a pipe using a random name
|
// create a pipe using a random name
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user