[kaffe] KJC's problem

Guilhem Lavaux guilhem.lavaux at free.fr
Fri Jul 11 13:08:01 PDT 2003


Hi all,

I am trying to fix the problem with KJC. For the moment, I am learning how it 
works (and it is much work for me as I am not really aware with the problems 
of compilation) but I already understand one thing. If you try to put a 
synchronized clause after a try {} catch you will always face the problem 
which arise in ShutdownHookTest. To test it I wrote a really gory program:

import java.lang.*;


public class Test {
        static public void main(String args[]) {
                Object a = new Object();
                Object b = null;

                try {
                        b.wait(10);
                } catch (Exception e) {
                }

                synchronized (a) {
                        System.out.println("b="+b);
                        try {
                                a.wait(20);
                        } catch (Exception e2) {
                        }
                }
        }
}

If you try to compile it with KJC and run it, you will get:
b=java.lang.NullPointerException
Obviously this is not what b is. If you try this other program:

import java.lang.*;


public class Test {
        static void testSync(Object a, Object b) {
                synchronized (a) {
                        System.out.println("b="+b);
                        try {
                                a.wait(20);
                        } catch (Exception e2) {
                        }
                }
        }
        static public void main(String args[]) {
                Object a = new Object();
                Object b = null;

                try {
                        b.wait(10);
                } catch (Exception e) {
                }

                testSync(a, b);
        }
}

You will get:
b=null

This is obviously a problem with the variable allocator... I will try to 
produce a fix as soon as I can.


Regards,

Guilhem.




More information about the kaffe mailing list