This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
GCJ Optimizer troubles: testcase
- From: Thomas Aeby <aeby at graeff dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: Java GCJ Mailing List <java at gcc dot gnu dot org>
- Date: Thu, 12 Aug 2004 16:10:46 +0200
- Subject: GCJ Optimizer troubles: testcase
- References: <1092167699.3012.210.camel@susix> <41192F9B.5080405@redhat.com>
On Tue, 2004-08-10 at 22:27, Bryce McKinlay wrote:
> Could you post a full test case please? That behaviour would surprise
> me, too.
Ok, here it is:
public class testcase {
private static class encapsulatedInt {
int value;
public encapsulatedInt( int i ) {
value = i;
}
public synchronized void increment() {
value++;
}
public int intValue() {
return value;
}
}
public static void main( String args[] ) {
encapsulatedInt tester = new encapsulatedInt(0);
System.out.println( "value: " + tester.intValue() );
tester.increment();
System.out.println( "value: " + tester.intValue() );
}
}
Compiled with GCJ 3.4.0 (with <3.4 everything seems to work
as expected):
$ gcj -O -o testcase --main=testcase testcase.java
$ ./testcase
value: 0
value: 0
$ gcj -o testcase --main=testcase testcase.java
$ ./testcase
value: 0
value: 1
$ gcj --version
gcj (GCC) 3.4.0
[...]
Now, isn't that cool?
Best regards,
Tom
--------------------------------------------------------------------
Thomas Aeby, Kirchweg 52, 1735 Giffers, Switzerland, aeby@graeff.com
Voice:(+41)26 4180040 PGP public key available
--------------------------------------------------------------------