提交 861ebacd 编写于 作者: T twisti

7176856: add the JRE name to the error log

Reviewed-by: coleenp, jrose, kvn, twisti
Contributed-by: NKrystal Mok <sajia@taobao.com>
上级 3d3d4641
...@@ -111,6 +111,10 @@ ...@@ -111,6 +111,10 @@
template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \
template(sun_misc_PostVMInitHook, "sun/misc/PostVMInitHook") \ template(sun_misc_PostVMInitHook, "sun/misc/PostVMInitHook") \
\ \
/* Java runtime version access */ \
template(sun_misc_Version, "sun/misc/Version") \
template(java_runtime_name_name, "java_runtime_name") \
\
/* class file format tags */ \ /* class file format tags */ \
template(tag_source_file, "SourceFile") \ template(tag_source_file, "SourceFile") \
template(tag_inner_classes, "InnerClasses") \ template(tag_inner_classes, "InnerClasses") \
......
...@@ -660,6 +660,7 @@ void vm_shutdown_during_initialization(const char* error, const char* message) { ...@@ -660,6 +660,7 @@ void vm_shutdown_during_initialization(const char* error, const char* message) {
} }
JDK_Version JDK_Version::_current; JDK_Version JDK_Version::_current;
const char* JDK_Version::_runtime_name;
void JDK_Version::initialize() { void JDK_Version::initialize() {
jdk_version_info info; jdk_version_info info;
......
...@@ -74,6 +74,7 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC { ...@@ -74,6 +74,7 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
private: private:
static JDK_Version _current; static JDK_Version _current;
static const char* _runtime_name;
// In this class, we promote the minor version of release to be the // In this class, we promote the minor version of release to be the
// major version for releases >= 5 in anticipation of the JDK doing the // major version for releases >= 5 in anticipation of the JDK doing the
...@@ -181,6 +182,13 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC { ...@@ -181,6 +182,13 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
void to_string(char* buffer, size_t buflen) const; void to_string(char* buffer, size_t buflen) const;
static const char* runtime_name() {
return _runtime_name;
}
static void set_runtime_name(const char* name) {
_runtime_name = name;
}
// Convenience methods for queries on the current major/minor version // Convenience methods for queries on the current major/minor version
static bool is_jdk12x_version() { static bool is_jdk12x_version() {
return current().compare_major(2) == 0; return current().compare_major(2) == 0;
......
...@@ -996,6 +996,29 @@ static void call_initializeSystemClass(TRAPS) { ...@@ -996,6 +996,29 @@ static void call_initializeSystemClass(TRAPS) {
vmSymbols::void_method_signature(), CHECK); vmSymbols::void_method_signature(), CHECK);
} }
char java_runtime_name[128] = "";
// extract the JRE name from sun.misc.Version.java_runtime_name
static const char* get_java_runtime_name(TRAPS) {
klassOop k = SystemDictionary::find(vmSymbols::sun_misc_Version(),
Handle(), Handle(), CHECK_AND_CLEAR_NULL);
fieldDescriptor fd;
bool found = k != NULL &&
instanceKlass::cast(k)->find_local_field(vmSymbols::java_runtime_name_name(),
vmSymbols::string_signature(), &fd);
if (found) {
oop name_oop = k->java_mirror()->obj_field(fd.offset());
if (name_oop == NULL)
return NULL;
const char* name = java_lang_String::as_utf8_string(name_oop,
java_runtime_name,
sizeof(java_runtime_name));
return name;
} else {
return NULL;
}
}
// General purpose hook into Java code, run once when the VM is initialized. // General purpose hook into Java code, run once when the VM is initialized.
// The Java library method itself may be changed independently from the VM. // The Java library method itself may be changed independently from the VM.
static void call_postVMInitHook(TRAPS) { static void call_postVMInitHook(TRAPS) {
...@@ -3352,6 +3375,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { ...@@ -3352,6 +3375,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// The VM creates & returns objects of this class. Make sure it's initialized. // The VM creates & returns objects of this class. Make sure it's initialized.
initialize_class(vmSymbols::java_lang_Class(), CHECK_0); initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
call_initializeSystemClass(CHECK_0); call_initializeSystemClass(CHECK_0);
// get the Java runtime name after java.lang.System is initialized
JDK_Version::set_runtime_name(get_java_runtime_name(THREAD));
} else { } else {
warning("java.lang.System not initialized"); warning("java.lang.System not initialized");
} }
......
...@@ -450,7 +450,9 @@ void VMError::report(outputStream* st) { ...@@ -450,7 +450,9 @@ void VMError::report(outputStream* st) {
// VM version // VM version
st->print_cr("#"); st->print_cr("#");
JDK_Version::current().to_string(buf, sizeof(buf)); JDK_Version::current().to_string(buf, sizeof(buf));
st->print_cr("# JRE version: %s", buf); const char* runtime_name = JDK_Version::runtime_name() != NULL ?
JDK_Version::runtime_name() : "";
st->print_cr("# JRE version: %s (%s)", runtime_name, buf);
st->print_cr("# Java VM: %s (%s %s %s %s)", st->print_cr("# Java VM: %s (%s %s %s %s)",
Abstract_VM_Version::vm_name(), Abstract_VM_Version::vm_name(),
Abstract_VM_Version::vm_release(), Abstract_VM_Version::vm_release(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册