74 JavaThread* THREAD = JavaThread::current();
75 ThreadInVMfromNative invm(THREAD);
76 ResourceMark rm(THREAD);
77
78 oop obj = vmClasses::Byte_klass()->allocate_instance(THREAD);
79
80 FlagSetting fs(WizardMode, true);
81
82 HandleMark hm(THREAD);
83 Handle h_obj(THREAD, obj);
84
85 // Thread tries to lock it.
86 {
87 ObjectLocker ol(h_obj, THREAD);
88 assert_test_pattern(h_obj, "locked");
89 }
90 assert_test_pattern(h_obj, "is_unlocked no_hash");
91
92 // Hash the object then print it.
93 intx hash = h_obj->identity_hash();
94 assert_test_pattern(h_obj, "is_unlocked hash=0x");
95
96 // Wait gets the lock inflated.
97 {
98 ObjectLocker ol(h_obj, THREAD);
99
100 Semaphore done(0);
101 LockerThread* st;
102 st = new LockerThread(&done, h_obj());
103 st->doit();
104
105 ol.wait(THREAD);
106 assert_test_pattern(h_obj, "monitor");
107 done.wait_with_safepoint_check(THREAD); // wait till the thread is done.
108 }
109 }
110 #endif // PRODUCT
|
74 JavaThread* THREAD = JavaThread::current();
75 ThreadInVMfromNative invm(THREAD);
76 ResourceMark rm(THREAD);
77
78 oop obj = vmClasses::Byte_klass()->allocate_instance(THREAD);
79
80 FlagSetting fs(WizardMode, true);
81
82 HandleMark hm(THREAD);
83 Handle h_obj(THREAD, obj);
84
85 // Thread tries to lock it.
86 {
87 ObjectLocker ol(h_obj, THREAD);
88 assert_test_pattern(h_obj, "locked");
89 }
90 assert_test_pattern(h_obj, "is_unlocked no_hash");
91
92 // Hash the object then print it.
93 intx hash = h_obj->identity_hash();
94 if (UseCompactObjectHeaders) {
95 assert_test_pattern(h_obj, "is_unlocked hash is-hashed=true is-copied=false");
96 } else {
97 assert_test_pattern(h_obj, "is_unlocked hash=0x");
98 }
99
100 // Wait gets the lock inflated.
101 {
102 ObjectLocker ol(h_obj, THREAD);
103
104 Semaphore done(0);
105 LockerThread* st;
106 st = new LockerThread(&done, h_obj());
107 st->doit();
108
109 ol.wait(THREAD);
110 assert_test_pattern(h_obj, "monitor");
111 done.wait_with_safepoint_check(THREAD); // wait till the thread is done.
112 }
113 }
114 #endif // PRODUCT
|