[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    RE: Proposal:JdpController.getProcessId() VM compatibility improvement
From:       "Langer, Christoph" <christoph.langer () sap ! com>
Date:       2017-06-27 18:41:40
Message-ID: a5c8cddda4e64ddb9a9a003a7edd81f9 () sap ! com
[Download RAW message or body]

Hi Andrew,

I can help you with this contribution.

First question: Do you want to create a fix completely resolving Roger's bug 8074569 \
[1] or shall I create a new bug for you? In the latter case, please send me a title \
and a long text (you can send this in a private Email).

Then, when we have the bug, you'll need to create a WebRev and post it for review. \
Are you familiar with that process? Do you have some close colleague who can assist \
you with that and upload a WebRev to cr.openjdk.java.net? If not I can do that for \
you when you send me the data. We can discuss that in a private mail thread as well.

Best regards
Christoph

[1] https://bugs.openjdk.java.net/browse/JDK-8074569

From: serviceability-dev [mailto:serviceability-dev-bounces@openjdk.java.net] On \
                Behalf Of Andrew Leonard
Sent: Donnerstag, 22. Juni 2017 18:31
To: serviceability-dev@openjdk.java.net
Subject: Fw: Proposal:JdpController.getProcessId() VM compatibility improvement

Hello,
I would like to propose the change below to the JdpController.getProcessId() method \
which currently uses a reflection hack and the VMManagement interface. Instead for \
JDK9+ we can use the ProcessHandle.current().getPid() method, which will also allow \
better compatibility with other pluggable VMs.

jdk/src/jdk.management.agent/share/classes/sun/management/jdp/JdpController.java
36d35
< import sun.management.VMManagement;
136,149c135,136
<         try {
<             // Get the current process id using a reflection hack
<             RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
<             Field jvm = runtime.getClass().getDeclaredField("jvm");
<             jvm.setAccessible(true);
<
<             VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
<             Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
<             pid_method.setAccessible(true);
<             Integer pid = (Integer) pid_method.invoke(mgmt);
<             return pid;
<         } catch(Exception ex) {
<             return null;
<         }
---
> // Get the current process id
> return (int)ProcessHandle.current().getPid();

I'd appreciate any feedback please, and help obtaining a suitable sponsor and \
contributor?

Thanks
Andrew

Andrew Leonard
Java Runtimes Development
IBM Hursley
IBM United Kingdom Ltd
Phone internal: 245913, external: 01962 815913
internet email: andrew_m_leonard@uk.ibm.com<mailto:andrew_m_leonard@uk.ibm.com>

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
	{mso-style-name:msonormal;
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">Hi \
Andrew,<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">I \
can help you with this contribution.<o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">First \
question: Do you want to create a fix completely resolving Roger&#8217;s bug 8074569 \
[1] or shall I create a new bug for you? In the  latter case, please send me a title \
and a long text (you can send this in a private Email).<o:p></o:p></span></p> <p \
class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">Then, \
when we have the bug, you&#8217;ll need to create a WebRev and post it for review. \
Are you familiar with that process? Do you have some  close colleague who can assist \
you with that and upload a WebRev to cr.openjdk.java.net? If not I can do that for \
you when you send me the data. We can discuss that in a private mail thread as \
well.<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">Best \
regards<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">Christoph<o:p></o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;mso-fareast-language:EN-US">[1] \
https://bugs.openjdk.java.net/browse/JDK-8074569<o:p></o:p></span></p> <p \
class="MsoNormal"><a name="_MailEndCompose"><span lang="EN-US" \
style="mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></a></p> <span \
style="mso-bookmark:_MailEndCompose"></span> <div \
style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"> <div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span \
lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> \
serviceability-dev [mailto:serviceability-dev-bounces@openjdk.java.net] <b>On Behalf \
Of </b>Andrew Leonard<br> <b>Sent:</b> Donnerstag, 22. Juni 2017 18:31<br>
<b>To:</b> serviceability-dev@openjdk.java.net<br>
<b>Subject:</b> Fw: Proposal:JdpController.getProcessId() VM compatibility \
improvement<o:p></o:p></span></p> </div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Hello,</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">I would like \
to propose the change below to the JdpController.getProcessId() method which \
currently uses a reflection hack and the VMManagement interface. Instead for \
JDK9&#43; we can use the ProcessHandle.current().getPid()  method, which will also \
allow better compatibility with other pluggable VMs.</span> <br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">jdk/src/jdk.management.agent/share/classes/sun/management/jdp/JdpController.java</span>
 <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">36d35</span> \
<br> <span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; \
import sun.management.VMManagement;</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">136,149c135,136</span>
 <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; try {</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Get the current process id using a reflection \
hack</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RuntimeMXBean runtime = \
ManagementFactory.getRuntimeMXBean();</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Field jvm = \
runtime.getClass().getDeclaredField(&quot;jvm&quot;);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jvm.setAccessible(true);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; \
</span><br> <span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VMManagement mgmt = \
(sun.management.VMManagement) jvm.get(runtime);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Method pid_method = \
mgmt.getClass().getDeclaredMethod(&quot;getProcessId&quot;);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pid_method.setAccessible(true);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Integer pid = (Integer) \
pid_method.invoke(mgmt);</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return pid;</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; } catch(Exception ex) {</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return null;</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&lt; &nbsp; \
&nbsp; &nbsp; &nbsp; }</span> <br> <span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">---</span> <br> \
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&gt; &nbsp; \
&nbsp; &nbsp; &nbsp; // Get the current process id</span> <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">&gt; &nbsp; \
&nbsp; &nbsp; &nbsp; return (int)ProcessHandle.current().getPid();</span> <br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">I'd \
appreciate any feedback please, and help obtaining a suitable sponsor and \
contributor?</span> <br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Thanks</span> \
<br> <span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Andrew</span> \
<br> <br>
Andrew Leonard<br>
Java Runtimes Development<br>
IBM Hursley<br>
IBM United Kingdom Ltd<br>
Phone internal: 245913, external: 01962 815913<br>
internet email: <a href="mailto:andrew_m_leonard@uk.ibm.com">andrew_m_leonard@uk.ibm.com</a>
 <br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number 741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU<br>
</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number 741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 \
3AU</span><o:p></o:p></p> </div>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic