8203329: JDWP/JDI VM information string is incorrect
Make sure the native java.vm.info property also gets updated when the java version is. Reviewed-by: sspitsyn, dholmes
This commit is contained in:
parent
42e75b8c79
commit
660dbcc16f
@ -4447,6 +4447,18 @@ void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, c
|
|||||||
PropertyList_add(plist, k, v, writeable == WriteableProperty, internal == InternalProperty);
|
PropertyList_add(plist, k, v, writeable == WriteableProperty, internal == InternalProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update existing property with new value.
|
||||||
|
void Arguments::PropertyList_update_value(SystemProperty* plist, const char* k, const char* v) {
|
||||||
|
SystemProperty* prop;
|
||||||
|
for (prop = plist; prop != NULL; prop = prop->next()) {
|
||||||
|
if (strcmp(k, prop->key()) == 0) {
|
||||||
|
prop->set_value(v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(false, "invalid property");
|
||||||
|
}
|
||||||
|
|
||||||
// Copies src into buf, replacing "%%" with "%" and "%p" with pid
|
// Copies src into buf, replacing "%%" with "%" and "%p" with pid
|
||||||
// Returns true if all of the source pointed by src has been copied over to
|
// Returns true if all of the source pointed by src has been copied over to
|
||||||
// the destination buffer pointed by buf. Otherwise, returns false.
|
// the destination buffer pointed by buf. Otherwise, returns false.
|
||||||
|
@ -651,6 +651,7 @@ class Arguments : AllStatic {
|
|||||||
static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
|
static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
|
||||||
PropertyAppendable append, PropertyWriteable writeable,
|
PropertyAppendable append, PropertyWriteable writeable,
|
||||||
PropertyInternal internal);
|
PropertyInternal internal);
|
||||||
|
static void PropertyList_update_value(SystemProperty* plist, const char* k, const char* v);
|
||||||
static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
|
static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
|
||||||
static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
|
static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
|
||||||
static int PropertyList_count(SystemProperty* pl);
|
static int PropertyList_count(SystemProperty* pl);
|
||||||
|
@ -1132,6 +1132,9 @@ static void reset_vm_info_property(TRAPS) {
|
|||||||
ResourceMark rm(THREAD);
|
ResourceMark rm(THREAD);
|
||||||
const char *vm_info = VM_Version::vm_info_string();
|
const char *vm_info = VM_Version::vm_info_string();
|
||||||
|
|
||||||
|
// update the native system property first
|
||||||
|
Arguments::PropertyList_update_value(Arguments::system_properties(), "java.vm.info", vm_info);
|
||||||
|
|
||||||
// java.lang.System class
|
// java.lang.System class
|
||||||
Klass* klass = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
|
Klass* klass = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
|
||||||
|
|
||||||
@ -3779,9 +3782,10 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
|
|||||||
|
|
||||||
initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
|
initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
|
||||||
|
|
||||||
// We need this for ClassDataSharing - the initial vm.info property is set
|
// We need this to update the java.vm.info property in case any flags used
|
||||||
// with the default value of CDS "sharing" which may be reset through
|
// to initially define it have been changed. This is needed for both CDS and
|
||||||
// command line options.
|
// AOT, since UseSharedSpaces and UseAOT may be changed after java.vm.info
|
||||||
|
// is initially computed. See Abstract_VM_Version::vm_info_string().
|
||||||
reset_vm_info_property(CHECK_JNI_ERR);
|
reset_vm_info_property(CHECK_JNI_ERR);
|
||||||
|
|
||||||
quicken_jni_functions();
|
quicken_jni_functions();
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8203329
|
||||||
|
* @summary Verifies the JVMTI GetSystemProperty API returns the updated java.vm.info value
|
||||||
|
* @library /test/lib
|
||||||
|
* @run main/othervm/native -agentlib:JvmtiGetSystemPropertyTest JvmtiGetSystemPropertyTest
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class JvmtiGetSystemPropertyTest {
|
||||||
|
private static native String getSystemProperty();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
String vm_info = System.getProperty("java.vm.info");
|
||||||
|
String vm_info_jvmti = getSystemProperty();
|
||||||
|
System.out.println("java.vm.info from java: " + vm_info);
|
||||||
|
System.out.println("java.vm.info from jvmti: " + vm_info_jvmti);
|
||||||
|
if (!vm_info.equals(vm_info_jvmti)) {
|
||||||
|
throw new RuntimeException("java.vm.info poperties not equal: \"" +
|
||||||
|
vm_info + "\" != \"" + vm_info_jvmti + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <jvmti.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static jvmtiEnv *jvmti = NULL;
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
|
||||||
|
int err = (*jvm)->GetEnv(jvm, (void**) &jvmti, JVMTI_VERSION_9);
|
||||||
|
if (err != JNI_OK) {
|
||||||
|
return JNI_ERR;
|
||||||
|
}
|
||||||
|
return JNI_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_JvmtiGetSystemPropertyTest_getSystemProperty(JNIEnv *env, jclass cls) {
|
||||||
|
jvmtiError err;
|
||||||
|
char* prop_value;
|
||||||
|
|
||||||
|
err = (*jvmti)->GetSystemProperty(jvmti, "java.vm.info", &prop_value);
|
||||||
|
if (err != JVMTI_ERROR_NONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (*env)->NewStringUTF(env, prop_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user