JDK-6300884 : Thread dumps should show actual class locks
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-22
  • Updated: 2014-06-27
  • Resolved: 2005-09-28
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 6
6 b54Fixed
Related Reports
Relates :  
Description
>>The new thread dump output looks great but I wonder if one little 
>>improvement is possible. When it puts out something like this:
>>
>>	- locked <0xf495fbb8> (a java.lang.Class)
>>
>>is there no way to list the actual class?(e.g. in my case today it is 
>>mostly java.util.logging.Logger) If the program is doing a lot of static 
>>synchronization I'm left staring at and matching up hex numbers, a more 
>>tiresome exercise.
>>
public class Foo extends Thread {
  static Object o = new Foo();
  public static void main(String[] args) {
	try {
	    synchronized(Foo.class) {
	        Foo.class.wait();
	    }
	} catch (InterruptedException e){
	    System.exit(0);
	}
  }
}

Just run this, then kill -3 (On Solaris it's control-\) and you'll see
something like:

- waiting on <0xd0c042f8> (a java.lang.Class)

And the RFE is asking to see "a Foo" instead of "a java.lang.Class".

Comments
EVALUATION Added the code in vframe.cpp. Now the output looks like: Full thread dump Java HotSpot(TM) Server VM (ws-jdk.ksrini.0914 mixed mode): "Thread-2" prio=10 tid=0x000e7f00 nid=0xd waiting on condition [0xd6d7f000..0xd6d7fae8] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0xf14212f0> (a Foo) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:145) at Foo$ParkThread.run(Foo.java:19) "Thread-1" prio=10 tid=0x000e7000 nid=0xc in Object.wait() [0xd6e7f000..0xd6e7fa68] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0xd7d820c0> (a java.lang.Class for Foo) at java.lang.Object.wait(Object.java:484) at Foo$FooThread.run(Foo.java:27) - locked <0xd7d820c0> (a java.lang.Class for Foo)
15-09-2005

SUGGESTED FIX Kenneth Russell wrote: > Sure, just modify javaVFrame::print_lock_info_on. e.g. > > if (obj->klass() == SystemDictionary::class_klass()) { > klassOop target_klass = java_lang_Class::as_klassOop(); > st->print_cr("a java.lang.Class for %s", > instanceKlass::cast(target_klass)->external_name()); > } else { > ... > } >
22-07-2005