[ nice-Bugs-1090881 ] IllegalMonitorStateException
"SourceForge.net" <[email protected]> Mon, 07 Feb 2005 07:02:40 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1090881, was opened at 2004-12-24 19:11
Message generated for change (Comment added) made by artemgr
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090881&group_id=12788
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Artem Gr Kozarezov (artemgr)
Assigned to: Nobody/Anonymous (nobody)
Summary: IllegalMonitorStateException
Initial Comment:
The following program:
void main( String[] ){
List<Integer> list = new LinkedList();
int n = 9;
while( 0 != --n ) list.add( new Integer( n ) );
while( true ){
synchronized( list ){
if( list.isEmpty() ) break;
list.removeAt( 0 );
}
}
println( "OK" );
}
prints
OK
Exception in thread "main"
java.lang.IllegalMonitorStateException
at sync.fun.main(sync.nice:9)
at sync.dispatch.main(dispatch.nice)
It's strange also to see "OK". In real application the
thread of control was interrupted (jumped to the
appropriate catch block).
It is possible to workaround this bug, by moving
"break" outside of the "synchronized" block.
nicec --version
Nice compiler version 0.9.10 prerelease (build
2004.12.07, 13:42:26 UTC)
Compiled using JDK 1.4.2-01
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
The similar Java program (see below) works without
exceptions:
import java.util.*;
public class test {
public static void main( String[] argv ){
List list = new LinkedList();
int n = 9;
while( 0 != --n ) list.add( new Integer( n ) );
while( true ){
synchronized( list ){
if( list.isEmpty() ) break;
list.remove( 0 );
}
}
System.out.println( "OK" );
}
}
----------------------------------------------------------------------
>Comment By: Artem Gr Kozarezov (artemgr)
Date: 2005-02-07 18:02
Message:
Logged In: YES
user_id=289741
The last followup is for another bug, sorry.
----------------------------------------------------------------------
Comment By: Artem Gr Kozarezov (artemgr)
Date: 2005-02-07 17:53
Message:
Logged In: YES
user_id=289741
A smaller test case:
<pre>
class AssertCaseFail {
void?->void _aFirstPointer = null;
void?->void _aSecondPointer = null;
void aMethod(){
let void->void fun;
let first = _aFirstPointer; let second = _aSecondPointer;
if( null != first ) fun = first;
else if( null != second ) fun = second;
else assert false;
fun();
}
}
void main( String[] ) = ( new AssertCaseFail() ).aMethod();
</pre>
It seems the current CVS have already some patch against it.
Stable Nice version says (when executing the code under
1.4.2_06):
Exception in thread "main" java.lang.VerifyError: (class:
letfun/c/fun, method: aMethod signature:
(Lletfun/c/AssertCaseFail;
)V) Register 1 contains wrong type
at letfun.c.dispatch.main(dispatch.nice)
But current CVS snapshot (build 2005.02.07) says:
Exception in thread "main" nice.lang.AssertionFailed
at letfun.c.fun.aMethod(c.nice:11)
at letfun.c.AssertCaseFail.aMethod(c.nice)
at letfun.c.fun.main(c.nice:16)
at letfun.c.dispatch.main(dispatch.nice)
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-12-28 18:41
Message:
Logged In: YES
user_id=688815
'continue' has the same problem.
----------------------------------------------------------------------
Comment By: Artem Gr Kozarezov (artemgr)
Date: 2004-12-24 20:23
Message:
Logged In: YES
user_id=289741
What about "continue"? Is it safe to use?
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-12-24 19:21
Message:
Logged In: YES
user_id=688815
This is a known bug in the codegenerator.
It doesn't handle breaking out a try-finally or synchronized
block correctly.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090881&group_id=12788
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl