Skip to main content

TestSync failed

3 replies [Last post]
Joined: 2006-12-10

Hi all,

I have built a phoneme-advanced-mr1 package using default build options of linux-x86-generic. The environment is:
OS: ubuntu Linux 2.6.15-26-686
JDK: Blackdown-1.4.2-02
GCC: 4.0.3

Then I performed some testcases in the testclasses directory. When testing TestSync, it failed to pass and the output is:

Holds lock tests:
PASSED 1: holdsLock
PASSED 2: enter,holdsLock
PASSED 3: enter,exit,holdsLock
PASSED 4: enter,enter,holdsLock
PASSED 5: enter,enter,exit,holdsLock
PASSED 6: enter,enter,exit,exit,holdsLock
PASSED 7: sync{holdsLock}
PASSED 8: sync{},holdsLock
PASSED 9: sync{sync{holdsLock}}
PASSED 10: sync{sync{},holdsLock}
PASSED 11: sync{sync{}},holdsLock
PASSED 12: enter,sync{holdsLock}
PASSED 13: sync{enter,holdsLock,exit}
PASSED 14: inflate,holdsLock
PASSED 15: inflate,enter,holdsLock
PASSED 16: enter,inflate,holdsLock
PASSED 17: enter,inflate,exit,holdsLock
PASSED 18: enter,exit,inflate,holdsLock
PASSED 19: enter,inflate,enter,holdsLock
PASSED 20: enter,enter,inflate,holdsLock
PASSED 21: enter,inflate,enter,exit,holdsLock
PASSED 22: enter,enter,inflate,exit,holdsLock
PASSED 23: enter,enter,exit,inflate,holdsLock
PASSED 24: enter,enter,exit,exit,inflate,holdsLock
PASSED 25: inflate,sync{holdsLock}
PASSED 26: sync{inflate,holdsLock}
PASSED 27: sync{},inflate,holdsLock
PASSED 28: sync{inflate,sync{holdsLock}}
PASSED 29: sync{sync{holdsLock}}
PASSED 30: sync{sync{},inflate,holdsLock}
PASSED 31: sync{sync{}},inflate,holdsLock
PASSED 32: enter,inflate,sync{holdsLock}
PASSED 33: enter,sync{holdsLock}
PASSED 34: sync{inflate,enter,holdsLock,exit}
PASSED 35: sync{enter,inflate,holdsLock,exit}
PASSED 36: t2.enter,holdsLock
PASSED 37: t2.lock,t2.exit,holdsLock
PASSED 38: t2.enter,t2.enter,holdsLock
PASSED 39: t2.enter,t2.enter,t2.exit,holdsLock
PASSED 40: t2.enter,t2.enter,t2.exit,t2.exit,holdsLock
PASSED 41: t2.sync{holdsLock}
PASSED 42: t2.sync{},holdsLock
PASSED 43: t2.sync{t2.sync{holdsLock}}
PASSED 44: t2.sync{t2.sync{},holdsLock}
PASSED 45: t2.sync{t2.sync{}},holdsLock
PASSED 46: t2.enter,t2.sync{holdsLock}
PASSED 47: t2.sync{t2.enter,holdsLock,t2.exit}
PASSED 48: t2.inflate,holdsLock
PASSED 49: t2.inflate,t2.enter,holdsLock
PASSED 50: t2.enter,t2.inflate,holdsLock
PASSED 51: t2.enter,t2.inflate,t2.exit,holdsLock
PASSED 52: enter,exit,inflate,holdsLock
PASSED 53: t2.enter,t2.inflate,t2.enter,holdsLock
PASSED 54: t2.enter,t2.enter,t2.inflate,holdsLock
PASSED 55: t2.enter,t2.inflate,t2.enter,t2.exit,holdsLock
PASSED 56: t2.enter,t2.enter,t2.inflate,t2.exit,holdsLock
PASSED 57: t2.enter,t2.enter,t2.exit,t2.inflate,holdsLock
PASSED 58: t2.enter,t2.enter,t2.exit,t2.exit,t2.inflate,holdsLock
PASSED 59: t2.inflate,t2.sync{holdsLock}
PASSED 60: t2.sync{t2.inflate,holdsLock}
PASSED 61: t2.sync{},t2.inflate,holdsLock
PASSED 62: t2.sync{t2.inflate,t2.sync{holdsLock}}
PASSED 63: t2.sync{t2.sync{holdsLock}}
PASSED 64: t2.sync{t2.sync{},t2.inflate,holdsLock}
PASSED 65: t2.sync{t2.sync{}},t2.inflate,holdsLock
PASSED 66: t2.enter,t2.inflate,t2.sync{holdsLock}
PASSED 67: t2.enter,t2.sync{holdsLock}
PASSED 68: t2.sync{t2.inflate,t2.enter,holdsLock,t2.exit}
PASSED 69: t2.sync{t2.enter,t2.inflate,holdsLock,t2.exit}

Excess monitorexit tests:

No more output. I found the program stopped at
static void testExcessMonitorExit() {
boolean success;

System.out.println("Excess monitorexit tests:");
// Excess monitorexit on synchronized blocks:

// Case 1: sync{exit}
success = false;
level = 0;
try {
Object o = new Object();
synchronized(o) {
} catch (IllegalMonitorStateException e) {
if (level == 1) {
success = true;
passIf(success, "sync{exit}", level, 1);

So I write a simple test file,
public class TestS {
public static void main(String[] args) throws Exception {
Object o = new Object();

synchronized(o) {

When run "java TestS", I got the expected result
Exception in thread "main" java.lang.IllegalMonitorStateException
at TestSyncLocker.monitorExit(TestSyncLocker.jasm)
at TestS.main(

But when run "../bin/cvm -cp . TestS", no output and the program hangs there.

I have tried the test under linux-arm-xscale, and the result is the same.

Has someone come across this? Can someone explain it?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-12-10

Hi Mark,

Thanks for your help.

I have seen the bug report, and I will compile with 1.3's javac and try the test. I agree with you this problem will hardly occur in real world applications.

Thanks Terrence too, and you all have a nice holiday.


Joined: 2006-10-13

Hi iniesta,

This is a known issue. Basically, JDK 1.4's javac generate a catch block that catches the same IllegalMonitorStateException that it throws. See bug reports at and However, the javac team has determined this to not be a bug due to various reasons. But in CVM's case, this unfortunately results in an infinite loop.

Here is a work around: compile using JDK 1.3's javac, and rerun the test. It should run to completion without any issues. In the future, we may change CVM to enforced structured locking i.e. paired locks and unlocks (though enforcements of pairing is not strictly required by the VM spec). That will also cause this problem to go away. In most real world applications, this problem will not manifest because it requires special effort to get the locks to be unlocked in an unstructured way in order to manifest this condition.


Joined: 2004-03-04


Unfortunately, I have not run these tests on phoneME Advanced yet so I don't have an answer. Due to the holidays in the U.S. not all our phoneME Advanced experts are monitoring the forums right now. I will make sure someone gets back to you in the first week of the new year if that is ok by you.


-- Terrence

Terrence Barr
Evangelist, Java Mobile & Embedded Community
Sun Microsystems, Germany