src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java

Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: otaviojava@java.net


 214     /**
 215      * Getter for the "JvmThreadInstCpuTimeNs" variable.
 216      */
 217     public Long getJvmThreadInstCpuTimeNs() throws SnmpStatusException {
 218         long l = 0;
 219         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 220 
 221         try {
 222             if (tmb.isThreadCpuTimeSupported()) {
 223                 l = tmb.getThreadCpuTime(info.getThreadId());
 224                 log.debug("getJvmThreadInstCpuTimeNs", "Cpu time ns : " + l);
 225 
 226                 //Cpu time measurement is disabled or the id is not valid.
 227                 if(l == -1) l = 0;
 228             }
 229         } catch (UnsatisfiedLinkError e) {
 230             // XXX Revisit: catch TO BE EVENTUALLY REMOVED
 231             log.debug("getJvmThreadInstCpuTimeNs",
 232                       "Operation not supported: " + e);
 233         }
 234         return new Long(l);
 235     }
 236 
 237     /**
 238      * Getter for the "JvmThreadInstBlockTimeMs" variable.
 239      */
 240     public Long getJvmThreadInstBlockTimeMs() throws SnmpStatusException {
 241         long l = 0;
 242 
 243         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 244 
 245         if (tmb.isThreadContentionMonitoringSupported()) {
 246             l = info.getBlockedTime();
 247 
 248             //Monitoring is disabled
 249             if(l == -1) l = 0;
 250         }
 251         return new Long(l);
 252     }
 253 
 254     /**
 255      * Getter for the "JvmThreadInstBlockCount" variable.
 256      */
 257     public Long getJvmThreadInstBlockCount() throws SnmpStatusException {
 258         return new Long(info.getBlockedCount());
 259     }
 260 
 261     /**
 262      * Getter for the "JvmThreadInstWaitTimeMs" variable.
 263      */
 264     public Long getJvmThreadInstWaitTimeMs() throws SnmpStatusException {
 265         long l = 0;
 266 
 267         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 268 
 269         if (tmb.isThreadContentionMonitoringSupported()) {
 270             l = info.getWaitedTime();
 271 
 272             //Monitoring is disabled
 273             if(l == -1) l = 0;
 274         }
 275         return new Long(l);
 276     }
 277 
 278     /**
 279      * Getter for the "JvmThreadInstWaitCount" variable.
 280      */
 281     public Long getJvmThreadInstWaitCount() throws SnmpStatusException {
 282         return new Long(info.getWaitedCount());
 283     }
 284 
 285     /**
 286      * Getter for the "JvmThreadInstState" variable.
 287      */
 288     public Byte[] getJvmThreadInstState()
 289         throws SnmpStatusException {
 290         return ThreadStateMap.getState(info);
 291     }
 292 
 293     /**
 294      * Getter for the "JvmThreadInstId" variable.
 295      */
 296     public Long getJvmThreadInstId() throws SnmpStatusException {
 297         return new Long(info.getThreadId());
 298     }
 299 
 300     /**
 301      * Getter for the "JvmThreadInstIndex" variable.
 302      */
 303     public Byte[] getJvmThreadInstIndex() throws SnmpStatusException {
 304         return index;
 305     }
 306 
 307     /**
 308      * Getter for the "JvmThreadInstStackTrace" variable.
 309      */
 310     private String getJvmThreadInstStackTrace() throws SnmpStatusException {
 311         StackTraceElement[] stackTrace = info.getStackTrace();
 312         //We append the stack trace in a buffer
 313         // XXX Revisit: should check isDebugOn()
 314         StringBuilder sb = new StringBuilder();
 315         final int stackSize = stackTrace.length;
 316         log.debug("getJvmThreadInstStackTrace", "Stack size : " + stackSize);
 317         for(int i = 0; i < stackSize; i++) {


 214     /**
 215      * Getter for the "JvmThreadInstCpuTimeNs" variable.
 216      */
 217     public Long getJvmThreadInstCpuTimeNs() throws SnmpStatusException {
 218         long l = 0;
 219         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 220 
 221         try {
 222             if (tmb.isThreadCpuTimeSupported()) {
 223                 l = tmb.getThreadCpuTime(info.getThreadId());
 224                 log.debug("getJvmThreadInstCpuTimeNs", "Cpu time ns : " + l);
 225 
 226                 //Cpu time measurement is disabled or the id is not valid.
 227                 if(l == -1) l = 0;
 228             }
 229         } catch (UnsatisfiedLinkError e) {
 230             // XXX Revisit: catch TO BE EVENTUALLY REMOVED
 231             log.debug("getJvmThreadInstCpuTimeNs",
 232                       "Operation not supported: " + e);
 233         }
 234         return l;
 235     }
 236 
 237     /**
 238      * Getter for the "JvmThreadInstBlockTimeMs" variable.
 239      */
 240     public Long getJvmThreadInstBlockTimeMs() throws SnmpStatusException {
 241         long l = 0;
 242 
 243         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 244 
 245         if (tmb.isThreadContentionMonitoringSupported()) {
 246             l = info.getBlockedTime();
 247 
 248             //Monitoring is disabled
 249             if(l == -1) l = 0;
 250         }
 251         return l;
 252     }
 253 
 254     /**
 255      * Getter for the "JvmThreadInstBlockCount" variable.
 256      */
 257     public Long getJvmThreadInstBlockCount() throws SnmpStatusException {
 258         return info.getBlockedCount();
 259     }
 260 
 261     /**
 262      * Getter for the "JvmThreadInstWaitTimeMs" variable.
 263      */
 264     public Long getJvmThreadInstWaitTimeMs() throws SnmpStatusException {
 265         long l = 0;
 266 
 267         final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
 268 
 269         if (tmb.isThreadContentionMonitoringSupported()) {
 270             l = info.getWaitedTime();
 271 
 272             //Monitoring is disabled
 273             if(l == -1) l = 0;
 274         }
 275         return l;
 276     }
 277 
 278     /**
 279      * Getter for the "JvmThreadInstWaitCount" variable.
 280      */
 281     public Long getJvmThreadInstWaitCount() throws SnmpStatusException {
 282         return info.getWaitedCount();
 283     }
 284 
 285     /**
 286      * Getter for the "JvmThreadInstState" variable.
 287      */
 288     public Byte[] getJvmThreadInstState()
 289         throws SnmpStatusException {
 290         return ThreadStateMap.getState(info);
 291     }
 292 
 293     /**
 294      * Getter for the "JvmThreadInstId" variable.
 295      */
 296     public Long getJvmThreadInstId() throws SnmpStatusException {
 297         return info.getThreadId();
 298     }
 299 
 300     /**
 301      * Getter for the "JvmThreadInstIndex" variable.
 302      */
 303     public Byte[] getJvmThreadInstIndex() throws SnmpStatusException {
 304         return index;
 305     }
 306 
 307     /**
 308      * Getter for the "JvmThreadInstStackTrace" variable.
 309      */
 310     private String getJvmThreadInstStackTrace() throws SnmpStatusException {
 311         StackTraceElement[] stackTrace = info.getStackTrace();
 312         //We append the stack trace in a buffer
 313         // XXX Revisit: should check isDebugOn()
 314         StringBuilder sb = new StringBuilder();
 315         final int stackSize = stackTrace.length;
 316         log.debug("getJvmThreadInstStackTrace", "Stack size : " + stackSize);
 317         for(int i = 0; i < stackSize; i++) {