6640188: Methods com.cun.attach.VirtualMachine.load... don't throw NullPointerxception
authorgadams
Tue, 09 Jan 2018 13:58:30 -0500
changeset 48629 a58c1924e037
parent 48628 69d65d9dcadb
child 48630 fdef4da95080
6640188: Methods com.cun.attach.VirtualMachine.load... don't throw NullPointerxception Reviewed-by: sspitsyn
src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
--- a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Wed Jan 10 18:04:56 2018 +0100
+++ b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Tue Jan 09 13:58:30 2018 -0500
@@ -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 @@
     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 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;