JDK-6306959 : doc: jps produce strange results when processes come and go
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2005-08-05
  • Updated: 2016-11-03
  • Resolved: 2016-11-03
Description
running many instances of jps concurrently produce strage output like:

8081 -- process information unavailable
8091 -- process information unavailable
8050 -- process information unavailable
8065 -- process information unavailable
8086 -- process information unavailable

This output can provoke failures in scripts that use jps output with grep and awk postprocessing. Output of jps shouldn't include any diagnostic messages, only discovered proccesses and requested information about them.
Please find the output below - with the suggested flags (-J-Djps.debug=true -J-Djps.printStackTrace=true) :
8120 -- process information unavailable
    8120 not found
sun.jvmstat.monitor.MonitorException: 8120 not found
    at sun.jvmstat.perfdata.monitor.protocol.local.PerfDataBuffer.<init>(PerfDataBuffer.java:66)
    at sun.jvmstat.perfdata.monitor.protocol.local.LocalMonitoredVm.<init>(LocalMonitoredVm.java:51)
    at sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider.getMonitoredVm(MonitoredHostProvider.java:60)
    at sun.tools.jps.Jps.main(Jps.java:65)
Caused by: java.lang.IllegalArgumentException: Process not found
    at sun.misc.Perf.attach(Native Method)
    at sun.misc.Perf.attachImpl(Perf.java:253)
    at sun.misc.Perf.attach(Perf.java:183)
    at sun.jvmstat.perfdata.monitor.protocol.local.PerfDataBuffer.<init>(PerfDataBuffer.java:46)
    ... 3 more
=============================================================
Used the below script to reproduce/ get the above exception :
#!/bin/ksh

which java
java -version

i=0
while [ i -le 10 ]
do
    jps -J-Djps.debug=true -J-Djps.printStackTrace=true > jps${i}.log 2>&1 &
    i=`expr $i + 1`
done
=================================
At least one of the log files (out of 10 above) did have this exception.

Comments
This is not on our list of current priorities, if this changes please re-open this issue.
03-11-2016

And by "fixing" you mean documenting that these things can happen as Dan suggested.
02-10-2012

Still an issue with jdk8 and something we should fix to get these issues to go away.
02-10-2012

EVALUATION The output in description note #2 is the perfect example of the difficulties in trying to monitor a system that is changing state. PID 8120 is present when jps asks for all the java processes running on the system. However, when jps tries to query more detailed information, e.g., what class is running, PID 8120 is gone. jps is very much like the UNIX ps(1) command. This paragraph from the ps(1) man page is appropriate: Things can change while ps is running. The snapshot it gives is true only for a split-second, and it may not be accurate by the time you see it. Some data printed for defunct processes is irrelevant. I took a quick look at the jps man page in JDK7-B135 and I don't see any caveats like the one from the ps(1) man page. This bug should be used to update the jps(1) man page.
28-03-2011

EVALUATION Will be addressed in an update release
20-06-2006

EVALUATION As noted in "Comments" section, it would be useful to provide more debug info. Please run jps with the jps.debug and jps.printStackTrace properties set. These will provide us with information that might help diagnose this issue. Here is the command line to use: jps -J-Djps.debug=true -J-Djps.printStackTrace=true
08-06-2006