src/hotspot/share/prims/jvm.cpp
changeset 52724 0bdbf854472f
parent 52478 b915bd68d907
child 52877 9e041366c764
equal deleted inserted replaced
52723:f24ae8376e71 52724:0bdbf854472f
   352 }
   352 }
   353 
   353 
   354 
   354 
   355 #define PUTPROP(props, name, value) set_property((props), (name), (value), CHECK_(properties));
   355 #define PUTPROP(props, name, value) set_property((props), (name), (value), CHECK_(properties));
   356 
   356 
   357 
   357 /*
   358 JVM_ENTRY(jobject, JVM_InitProperties(JNIEnv *env, jobject properties))
   358  * Return all of the system properties in a Java String array with alternating
   359   JVMWrapper("JVM_InitProperties");
   359  * names and values from the jvm SystemProperty.
   360   ResourceMark rm;
   360  * Which includes some internal and all commandline -D defined properties.
   361 
   361  */
   362   Handle props(THREAD, JNIHandles::resolve_non_null(properties));
   362 JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))
   363 
   363   JVMWrapper("JVM_GetProperties");
   364   // System property list includes both user set via -D option and
   364   ResourceMark rm(THREAD);
   365   // jvm system specific properties.
   365   HandleMark hm(THREAD);
   366   for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
   366   int ndx = 0;
   367     if (strcmp(p->key(), "sun.nio.MaxDirectMemorySize") == 0)  // Can not be defined with -D
   367   int fixedCount = 2;
   368       continue;
   368 
   369     PUTPROP(props, p->key(), p->value());
   369   SystemProperty* p = Arguments::system_properties();
       
   370   int count = Arguments::PropertyList_count(p);
       
   371 
       
   372   // Allocate result String array
       
   373   InstanceKlass* ik = SystemDictionary::String_klass();
       
   374   objArrayOop r = oopFactory::new_objArray(ik, (count + fixedCount) * 2, CHECK_NULL);
       
   375   objArrayHandle result_h(THREAD, r);
       
   376 
       
   377   while (p != NULL) {
       
   378     const char * key = p->key();
       
   379     if (strcmp(key, "sun.nio.MaxDirectMemorySize") != 0) {
       
   380         const char * value = p->value();
       
   381         Handle key_str    = java_lang_String::create_from_platform_dependent_str(key, CHECK_NULL);
       
   382         Handle value_str  = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK_NULL);
       
   383         result_h->obj_at_put(ndx * 2,  key_str());
       
   384         result_h->obj_at_put(ndx * 2 + 1, value_str());
       
   385         ndx++;
       
   386     }
       
   387     p = p->next();
   370   }
   388   }
   371 
   389 
   372   // Convert the -XX:MaxDirectMemorySize= command line flag
   390   // Convert the -XX:MaxDirectMemorySize= command line flag
   373   // to the sun.nio.MaxDirectMemorySize property.
   391   // to the sun.nio.MaxDirectMemorySize property.
   374   // Do this after setting user properties to prevent people
   392   // Do this after setting user properties to prevent people
   375   // from setting the value with a -D option, as requested.
   393   // from setting the value with a -D option, as requested.
   376   // Leave empty if not supplied
   394   // Leave empty if not supplied
   377   if (!FLAG_IS_DEFAULT(MaxDirectMemorySize)) {
   395   if (!FLAG_IS_DEFAULT(MaxDirectMemorySize)) {
   378     char as_chars[256];
   396     char as_chars[256];
   379     jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
   397     jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
   380     PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars);
   398     Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.nio.MaxDirectMemorySize", CHECK_NULL);
       
   399     Handle value_str  = java_lang_String::create_from_platform_dependent_str(as_chars, CHECK_NULL);
       
   400     result_h->obj_at_put(ndx * 2,  key_str());
       
   401     result_h->obj_at_put(ndx * 2 + 1, value_str());
       
   402     ndx++;
   381   }
   403   }
   382 
   404 
   383   // JVM monitoring and management support
   405   // JVM monitoring and management support
   384   // Add the sun.management.compiler property for the compiler's name
   406   // Add the sun.management.compiler property for the compiler's name
   385   {
   407   {
   404 #endif // compilers
   426 #endif // compilers
   405 #endif // TIERED
   427 #endif // TIERED
   406 
   428 
   407     if (*compiler_name != '\0' &&
   429     if (*compiler_name != '\0' &&
   408         (Arguments::mode() != Arguments::_int)) {
   430         (Arguments::mode() != Arguments::_int)) {
   409       PUTPROP(props, "sun.management.compiler", compiler_name);
   431       Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.management.compiler", CHECK_NULL);
   410     }
   432       Handle value_str  = java_lang_String::create_from_platform_dependent_str(compiler_name, CHECK_NULL);
   411   }
   433       result_h->obj_at_put(ndx * 2,  key_str());
   412 
   434       result_h->obj_at_put(ndx * 2 + 1, value_str());
   413   return properties;
   435       ndx++;
       
   436     }
       
   437   }
       
   438 
       
   439   return (jobjectArray) JNIHandles::make_local(env, result_h());
   414 JVM_END
   440 JVM_END
   415 
   441 
   416 
   442 
   417 /*
   443 /*
   418  * Return the temporary directory that the VM uses for the attach
   444  * Return the temporary directory that the VM uses for the attach