changeset 35185:31b4d3da482f

8138677: IllegalAccessException Class sun.usagetracker.UsageTrackerClient$4 (module java.base) can not access a member of class java.lang.management.ManagementFactory (module java.management) Reviewed-by: alanb, mchung, dholmes, erikj, ihse
author jbachorik
date Tue, 24 Nov 2015 16:07:40 +0100
parents 298594487e08
children 89076d5121c0
files hotspot/make/share/makefiles/mapfile-vers hotspot/src/share/vm/prims/jvm.cpp hotspot/src/share/vm/prims/jvm.h hotspot/src/share/vm/services/jmm.h hotspot/src/share/vm/services/management.cpp
diffstat 5 files changed, 37 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/make/share/makefiles/mapfile-vers	Thu Dec 17 08:23:51 2015 +0100
+++ b/hotspot/make/share/makefiles/mapfile-vers	Tue Nov 24 16:07:40 2015 +0100
@@ -111,6 +111,7 @@
                 JVM_GetSystemPackages;
                 JVM_GetTemporaryDirectory;
                 JVM_GetVersionInfo;
+                JVM_GetVmArguments;
                 JVM_Halt;
                 JVM_HoldsLock;
                 JVM_IHashCode;
--- a/hotspot/src/share/vm/prims/jvm.cpp	Thu Dec 17 08:23:51 2015 +0100
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Tue Nov 24 16:07:40 2015 +0100
@@ -3723,6 +3723,35 @@
 }
 JVM_END
 
+// Returns an array of java.lang.String objects containing the input arguments to the VM.
+JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))
+  ResourceMark rm(THREAD);
+
+  if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) {
+    return NULL;
+  }
+
+  char** vm_flags = Arguments::jvm_flags_array();
+  char** vm_args = Arguments::jvm_args_array();
+  int num_flags = Arguments::num_jvm_flags();
+  int num_args = Arguments::num_jvm_args();
+
+  instanceKlassHandle ik (THREAD, SystemDictionary::String_klass());
+  objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL);
+  objArrayHandle result_h(THREAD, r);
+
+  int index = 0;
+  for (int j = 0; j < num_flags; j++, index++) {
+    Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL);
+    result_h->obj_at_put(index, h());
+  }
+  for (int i = 0; i < num_args; i++, index++) {
+    Handle h = java_lang_String::create_from_platform_dependent_str(vm_args[i], CHECK_NULL);
+    result_h->obj_at_put(index, h());
+  }
+  return (jobjectArray) JNIHandles::make_local(env, result_h());
+JVM_END
+
 JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
   return os::get_signal_number(name);
 JVM_END
--- a/hotspot/src/share/vm/prims/jvm.h	Thu Dec 17 08:23:51 2015 +0100
+++ b/hotspot/src/share/vm/prims/jvm.h	Tue Nov 24 16:07:40 2015 +0100
@@ -141,6 +141,10 @@
 JNIEXPORT jobject JNICALL
 JVM_InitProperties(JNIEnv *env, jobject p);
 
+/*
+ * java.lang.Runtime
+ */
+
 JNIEXPORT void JNICALL
 JVM_Halt(jint code);
 
@@ -188,6 +192,9 @@
 JNIEXPORT jboolean JNICALL
 JVM_IsSupportedJNIVersion(jint version);
 
+JNIEXPORT jobjectArray JNICALL
+JVM_GetVmArguments(JNIEnv *env);
+
 /*
  * java.lang.Throwable
  */
--- a/hotspot/src/share/vm/services/jmm.h	Thu Dec 17 08:23:51 2015 +0100
+++ b/hotspot/src/share/vm/services/jmm.h	Tue Nov 24 16:07:40 2015 +0100
@@ -227,16 +227,10 @@
   jint         (JNICALL *GetOptionalSupport)     (JNIEnv *env,
                                                   jmmOptionalSupport* support_ptr);
 
-  /* This is used by JDK 6 and earlier.
-   * For JDK 7 and after, use GetInputArgumentArray.
-   */
-  jobject      (JNICALL *GetInputArguments)      (JNIEnv *env);
-
   jint         (JNICALL *GetThreadInfo)          (JNIEnv *env,
                                                   jlongArray ids,
                                                   jint maxDepth,
                                                   jobjectArray infoArray);
-  jobjectArray (JNICALL *GetInputArgumentArray)  (JNIEnv *env);
 
   jobjectArray (JNICALL *GetMemoryPools)         (JNIEnv* env, jobject mgr);
 
--- a/hotspot/src/share/vm/services/management.cpp	Thu Dec 17 08:23:51 2015 +0100
+++ b/hotspot/src/share/vm/services/management.cpp	Tue Nov 24 16:07:40 2015 +0100
@@ -473,90 +473,6 @@
   return 0;
 JVM_END
 
-// Returns a java.lang.String object containing the input arguments to the VM.
-JVM_ENTRY(jobject, jmm_GetInputArguments(JNIEnv *env))
-  ResourceMark rm(THREAD);
-
-  if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) {
-    return NULL;
-  }
-
-  char** vm_flags = Arguments::jvm_flags_array();
-  char** vm_args  = Arguments::jvm_args_array();
-  int num_flags   = Arguments::num_jvm_flags();
-  int num_args    = Arguments::num_jvm_args();
-
-  size_t length = 1; // null terminator
-  int i;
-  for (i = 0; i < num_flags; i++) {
-    length += strlen(vm_flags[i]);
-  }
-  for (i = 0; i < num_args; i++) {
-    length += strlen(vm_args[i]);
-  }
-  // add a space between each argument
-  length += num_flags + num_args - 1;
-
-  // Return the list of input arguments passed to the VM
-  // and preserve the order that the VM processes.
-  char* args = NEW_RESOURCE_ARRAY(char, length);
-  args[0] = '\0';
-  // concatenate all jvm_flags
-  if (num_flags > 0) {
-    strcat(args, vm_flags[0]);
-    for (i = 1; i < num_flags; i++) {
-      strcat(args, " ");
-      strcat(args, vm_flags[i]);
-    }
-  }
-
-  if (num_args > 0 && num_flags > 0) {
-    // append a space if args already contains one or more jvm_flags
-    strcat(args, " ");
-  }
-
-  // concatenate all jvm_args
-  if (num_args > 0) {
-    strcat(args, vm_args[0]);
-    for (i = 1; i < num_args; i++) {
-      strcat(args, " ");
-      strcat(args, vm_args[i]);
-    }
-  }
-
-  Handle hargs = java_lang_String::create_from_platform_dependent_str(args, CHECK_NULL);
-  return JNIHandles::make_local(env, hargs());
-JVM_END
-
-// Returns an array of java.lang.String object containing the input arguments to the VM.
-JVM_ENTRY(jobjectArray, jmm_GetInputArgumentArray(JNIEnv *env))
-  ResourceMark rm(THREAD);
-
-  if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) {
-    return NULL;
-  }
-
-  char** vm_flags = Arguments::jvm_flags_array();
-  char** vm_args = Arguments::jvm_args_array();
-  int num_flags = Arguments::num_jvm_flags();
-  int num_args = Arguments::num_jvm_args();
-
-  instanceKlassHandle ik (THREAD, SystemDictionary::String_klass());
-  objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL);
-  objArrayHandle result_h(THREAD, r);
-
-  int index = 0;
-  for (int j = 0; j < num_flags; j++, index++) {
-    Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL);
-    result_h->obj_at_put(index, h());
-  }
-  for (int i = 0; i < num_args; i++, index++) {
-    Handle h = java_lang_String::create_from_platform_dependent_str(vm_args[i], CHECK_NULL);
-    result_h->obj_at_put(index, h());
-  }
-  return (jobjectArray) JNIHandles::make_local(env, result_h());
-JVM_END
-
 // Returns an array of java/lang/management/MemoryPoolMXBean object
 // one for each memory pool if obj == null; otherwise returns
 // an array of memory pools for a given memory manager if
@@ -2291,9 +2207,7 @@
   NULL,
   jmm_GetVersion,
   jmm_GetOptionalSupport,
-  jmm_GetInputArguments,
   jmm_GetThreadInfo,
-  jmm_GetInputArgumentArray,
   jmm_GetMemoryPools,
   jmm_GetMemoryManagers,
   jmm_GetMemoryPoolUsage,