6640188: Methods com.cun.attach.VirtualMachine.load... don't throw NullPointerxception

Reviewed-by: sspitsyn
This commit is contained in:
Gary Adams 2018-01-09 13:58:30 -05:00
parent c5f5601b1c
commit 00993afe1a

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -86,6 +86,10 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
private void loadAgentLibrary(String agentLibrary, boolean isAbsolute, String options)
throws AgentLoadException, AgentInitializationException, IOException
{
if (agentLibrary == null) {
throw new NullPointerException("agentLibrary cannot be null");
}
String msgPrefix = "return code: ";
InputStream in = execute("load",
agentLibrary,
@ -131,6 +135,10 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
public void loadAgent(String agent, String options)
throws AgentLoadException, AgentInitializationException, IOException
{
if (agent == null) {
throw new NullPointerException("agent cannot be null");
}
String args = agent;
if (options != null) {
args = args + "=" + options;