[ 
https://issues.apache.org/jira/browse/GEODE-9476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17512603#comment-17512603
 ] 

Darrel Schneider edited comment on GEODE-9476 at 3/25/22, 10:08 PM:
--------------------------------------------------------------------

I think the issue with having com.sun.management.OperatingSystemMXBean in our 
code is that it does not exist on Windows. I think we support building on 
Windows not just running on it. Code with a reference to this class will fail 
to compile on Windows. If it was just a Windows runtime issue we catch 
ClassNotFoundException and be okay.
But I might be wrong about this. It just be an issue with the fd limits. It is 
worth doing some builds on windows to see what will work.


was (Author: dschneider):
I think the issue with having com.sun.management.OperatingSystemMXBean in our 
code is that it does not exist on Windows. I think we support building on 
Windows not just running on it. Code with a reference to this class will fail 
to compile on Windows. If it was just a Windows runtime issue we catch 
ClassNotFoundException and be okay.

> VMStats processCpuTime, fdLimit, and fdsOpen will always be zero on java 16 
> and later
> -------------------------------------------------------------------------------------
>
>                 Key: GEODE-9476
>                 URL: https://issues.apache.org/jira/browse/GEODE-9476
>             Project: Geode
>          Issue Type: Bug
>          Components: statistics
>            Reporter: Darrel Schneider
>            Priority: Major
>              Labels: Java16
>
> VMStats processCpuTime, fdLimit, and fdsOpen will always be zero on java 16 
> and later. 
> This is because it calls Method.setAccessible which is not allowed under 
> normal conditions starting with java 16 (see: 
> https://softwaregarden.dev/en/posts/new-java/illegal-access-in-java-16).
> A workaround for this bug is to start the jvm with  --illegal-access=permit
> The setAccessible call is in the static initializer for: 
> org.apache.geode.internal.stats50.VMStats50
> It turns out the following works for calling processCpuTime:
> {code:java}
>         OperatingSystemMXBean osBean = 
> ManagementFactory.getOperatingSystemMXBean();
>         com.sun.management.OperatingSystemMXBean sunBean = 
> (com.sun.management.OperatingSystemMXBean) osBean;
>         System.out.println("getProcessCpuTime=" + 
> sunBean.getProcessCpuTime());
> {code}
> so we can get rid of the setAccessible call



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to