changeset 13390:842097f877f2

Add EnableDynamicAgentLoading option Contributed-by: serguei.spitsyn@oracle.com
author alanb
date Tue, 11 Apr 2017 12:31:53 +0100
parents 4129a3cc9339
children af8942b1e722
files src/share/vm/runtime/globals.hpp src/share/vm/services/attachListener.cpp
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/globals.hpp	Sun Apr 09 13:57:28 2017 -0700
+++ b/src/share/vm/runtime/globals.hpp	Tue Apr 11 12:31:53 2017 +0100
@@ -3874,6 +3874,9 @@
   product(bool, StartAttachListener, false,                                 \
           "Always start Attach Listener at VM startup")                     \
                                                                             \
+  product(bool, EnableDynamicAgentLoading, true,                            \
+          "Allow tools to load agents with the attach mechanism")           \
+                                                                            \
   manageable(bool, PrintConcurrentLocks, false,                             \
           "Print java.util.concurrent locks in thread dump")                \
                                                                             \
--- a/src/share/vm/services/attachListener.cpp	Sun Apr 09 13:57:28 2017 -0700
+++ b/src/share/vm/services/attachListener.cpp	Tue Apr 11 12:31:53 2017 +0100
@@ -321,6 +321,11 @@
     // handle special detachall operation
     if (strcmp(op->name(), AttachOperation::detachall_operation_name()) == 0) {
       AttachListener::detachall();
+    } else if (!EnableDynamicAgentLoading && strcmp(op->name(), "load") == 0) {
+      // Dynamic loading agents is not default by default
+      st.print("Dynamic agent loading is not enabled. "
+               "Use -XX:+EnableDynamicAgentLoading to launch target VM.");
+      res = JNI_ERR;
     } else {
       // find the function to dispatch too
       AttachOperationFunctionInfo* info = NULL;