This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCJ Optimizer troubles: testcase


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
--------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]