JDK-7176856 : add the JRE name to the error log
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs23
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-06-14
  • Updated: 2014-02-04
  • Resolved: 2012-07-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
Description
http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2012-May/003703.html

Kirs Mok wrote:

Hi all,

Could I get some review for this change, please?
https://gist.github.com/2709918#file_jre_name.patch
I'm considering this as an initial draft version, and will improve it later
on
based on comments received.

Background:

An earlier case on hotspot-dev [1][2] seemed to have hit a bug caused by
mix-
matching an Oracle JRE with a OpenJDK-based HotSpot VM.

Chris suggested [3] that, to better aid future analysis of similar problems,
it's useful to print the JRE name in the error log, in addition to the JRE
version as printed currently. This patch implements Chris' suggestion.

An example of the effect of this patch is avaiable [4].

There are a few details that I'm not too sure about yet, and I'm looking for
comments on them:

1. How and when should I get the JRE name?

The JRE name is only exposed as a field of a Java-level class, namely the
"java_runtime_name" constant field in sun.misc.Version. I couldn't find it
exposed anywhere else. It is set into the Java-level system properties, by
the
key "java.runtime.name", but that's not immediately available to the VM
side.

In my patch, I'm fetching the JRE name from
sun.misc.Version.java_runtime_name
immediately after java.lang.System.initializeSystemClass() is invoked, and
then
storing it in a static field in JDK_Version. This is safer to do then
fetching
the name during error reporting, because it may be unreliable to access Java
heap contents when the VM is crashing.

There are other alternatives that I've thought about. One is adding a new
private interface between JDK/JVM that would allow the JDK to expose its
name
to the VM directly, perhaps with a new function JDK_GetName0(). But this is
more involved then the proposed change.

2. Where should I store the JRE name?

As mentioned, I'm storing it in a newly added static field in JDK_Version
right
now. But I'm not sure if this is the place it belongs. Universe doesn't seem
like the right place, neither.

Any suggestions or comments are welcomed.

Should I cc serviceability-dev as well?

Regards,
Kris

Comments
EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/f8de958e5b2c
29-06-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/f8de958e5b2c
18-06-2012

EVALUATION Yes
14-06-2012