471 } |
471 } |
472 Management::get_optional_support(support); |
472 Management::get_optional_support(support); |
473 return 0; |
473 return 0; |
474 JVM_END |
474 JVM_END |
475 |
475 |
476 // Returns a java.lang.String object containing the input arguments to the VM. |
|
477 JVM_ENTRY(jobject, jmm_GetInputArguments(JNIEnv *env)) |
|
478 ResourceMark rm(THREAD); |
|
479 |
|
480 if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) { |
|
481 return NULL; |
|
482 } |
|
483 |
|
484 char** vm_flags = Arguments::jvm_flags_array(); |
|
485 char** vm_args = Arguments::jvm_args_array(); |
|
486 int num_flags = Arguments::num_jvm_flags(); |
|
487 int num_args = Arguments::num_jvm_args(); |
|
488 |
|
489 size_t length = 1; // null terminator |
|
490 int i; |
|
491 for (i = 0; i < num_flags; i++) { |
|
492 length += strlen(vm_flags[i]); |
|
493 } |
|
494 for (i = 0; i < num_args; i++) { |
|
495 length += strlen(vm_args[i]); |
|
496 } |
|
497 // add a space between each argument |
|
498 length += num_flags + num_args - 1; |
|
499 |
|
500 // Return the list of input arguments passed to the VM |
|
501 // and preserve the order that the VM processes. |
|
502 char* args = NEW_RESOURCE_ARRAY(char, length); |
|
503 args[0] = '\0'; |
|
504 // concatenate all jvm_flags |
|
505 if (num_flags > 0) { |
|
506 strcat(args, vm_flags[0]); |
|
507 for (i = 1; i < num_flags; i++) { |
|
508 strcat(args, " "); |
|
509 strcat(args, vm_flags[i]); |
|
510 } |
|
511 } |
|
512 |
|
513 if (num_args > 0 && num_flags > 0) { |
|
514 // append a space if args already contains one or more jvm_flags |
|
515 strcat(args, " "); |
|
516 } |
|
517 |
|
518 // concatenate all jvm_args |
|
519 if (num_args > 0) { |
|
520 strcat(args, vm_args[0]); |
|
521 for (i = 1; i < num_args; i++) { |
|
522 strcat(args, " "); |
|
523 strcat(args, vm_args[i]); |
|
524 } |
|
525 } |
|
526 |
|
527 Handle hargs = java_lang_String::create_from_platform_dependent_str(args, CHECK_NULL); |
|
528 return JNIHandles::make_local(env, hargs()); |
|
529 JVM_END |
|
530 |
|
531 // Returns an array of java.lang.String object containing the input arguments to the VM. |
|
532 JVM_ENTRY(jobjectArray, jmm_GetInputArgumentArray(JNIEnv *env)) |
|
533 ResourceMark rm(THREAD); |
|
534 |
|
535 if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) { |
|
536 return NULL; |
|
537 } |
|
538 |
|
539 char** vm_flags = Arguments::jvm_flags_array(); |
|
540 char** vm_args = Arguments::jvm_args_array(); |
|
541 int num_flags = Arguments::num_jvm_flags(); |
|
542 int num_args = Arguments::num_jvm_args(); |
|
543 |
|
544 instanceKlassHandle ik (THREAD, SystemDictionary::String_klass()); |
|
545 objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL); |
|
546 objArrayHandle result_h(THREAD, r); |
|
547 |
|
548 int index = 0; |
|
549 for (int j = 0; j < num_flags; j++, index++) { |
|
550 Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL); |
|
551 result_h->obj_at_put(index, h()); |
|
552 } |
|
553 for (int i = 0; i < num_args; i++, index++) { |
|
554 Handle h = java_lang_String::create_from_platform_dependent_str(vm_args[i], CHECK_NULL); |
|
555 result_h->obj_at_put(index, h()); |
|
556 } |
|
557 return (jobjectArray) JNIHandles::make_local(env, result_h()); |
|
558 JVM_END |
|
559 |
|
560 // Returns an array of java/lang/management/MemoryPoolMXBean object |
476 // Returns an array of java/lang/management/MemoryPoolMXBean object |
561 // one for each memory pool if obj == null; otherwise returns |
477 // one for each memory pool if obj == null; otherwise returns |
562 // an array of memory pools for a given memory manager if |
478 // an array of memory pools for a given memory manager if |
563 // it is a valid memory manager. |
479 // it is a valid memory manager. |
564 JVM_ENTRY(jobjectArray, jmm_GetMemoryPools(JNIEnv* env, jobject obj)) |
480 JVM_ENTRY(jobjectArray, jmm_GetMemoryPools(JNIEnv* env, jobject obj)) |
2289 const struct jmmInterface_1_ jmm_interface = { |
2205 const struct jmmInterface_1_ jmm_interface = { |
2290 NULL, |
2206 NULL, |
2291 NULL, |
2207 NULL, |
2292 jmm_GetVersion, |
2208 jmm_GetVersion, |
2293 jmm_GetOptionalSupport, |
2209 jmm_GetOptionalSupport, |
2294 jmm_GetInputArguments, |
|
2295 jmm_GetThreadInfo, |
2210 jmm_GetThreadInfo, |
2296 jmm_GetInputArgumentArray, |
|
2297 jmm_GetMemoryPools, |
2211 jmm_GetMemoryPools, |
2298 jmm_GetMemoryManagers, |
2212 jmm_GetMemoryManagers, |
2299 jmm_GetMemoryPoolUsage, |
2213 jmm_GetMemoryPoolUsage, |
2300 jmm_GetPeakMemoryPoolUsage, |
2214 jmm_GetPeakMemoryPoolUsage, |
2301 jmm_GetThreadAllocatedMemory, |
2215 jmm_GetThreadAllocatedMemory, |