[Kafffe] invocation bug found!

Moses DeJong dejong at cs.umn.edu
Thu Feb 4 14:13:43 PST 1999


Hello all.

I have run into a problem with invocation of a method that has
a boolean return value that needs to be wrapped into
a Boolean object. I looked around in the VM code but I was not
able to figure out where to go next. I am going to attach 4 test
cases that show the correct and incorrect way that Kaffe is working.
The first two test cases work because they return Boolean objects
and the second two test cases fail because they return boolean
primitive types.

Here is what I found out so far.

Java_java_lang_reflect_Method_invoke()   Method.c
CallBooleanMethodA()                     Method.c
callMethodA()                            support.c
sysdepCallMethod()                       config/sparc/common.h
!UGH!

The value returned by CallBooleanMethodA() inside
Java_java_lang_reflect_Method_invoke() is incorrect but I
was not able to find out where the code went after the call
to sysdepCallMethod(), so I had to give up at that point.

In case I was not too clear about what the bug was, a return of
true as a boolean will actually return false (jvalue.z is 0).


Mo DeJong
dejong at cs.umn.edu





// File ReflectedBooleanBug1.java (no bug found)

import java.lang.reflect.*;
import java.util.*;

public class ReflectedBooleanBug1 {
    public static void main(String[] argv) throws Exception {
	Method m1 = ReflectedBooleanBug1.class.getMethod("trueBooleanObjectMethod", null);
	System.out.println("m1 is " + m1);

	Method m2 = ReflectedBooleanBug1.class.getMethod("falseBooleanObjectMethod", null);
	System.out.println("m2 is " + m2);


	Boolean tb = (Boolean) m1.invoke(null,null);
	Boolean fb = (Boolean) m2.invoke(null,null);

	if (tb.booleanValue() != true) {
	    throw new Exception("booleanValue() != true");
	}

	if (fb.booleanValue() != false) {
	    throw new Exception("booleanValue() != false");
	}

	System.out.println("OK");
    }

    public static Boolean trueBooleanObjectMethod() {
	return new Boolean(true);
    }

    public static Boolean falseBooleanObjectMethod() {
	return new Boolean(false);
    }
}








// File ReflectedBooleanBug2.java (no bug found)

import java.lang.reflect.*;
import java.util.*;

public class ReflectedBooleanBug2 {
    public static void main(String[] argv) throws Exception {
	Method m1 = ReflectedBooleanBug2.class.getMethod("trueBooleanObjectMethod", null);
	System.out.println("m1 is " + m1);

	Method m2 = ReflectedBooleanBug2.class.getMethod("falseBooleanObjectMethod", null);
	System.out.println("m2 is " + m2);

	
	ReflectedBooleanBug2 rbb2 = new ReflectedBooleanBug2();

	Boolean tb = (Boolean) m1.invoke(rbb2,null);
	Boolean fb = (Boolean) m2.invoke(rbb2,null);

	if (tb.booleanValue() != true) {
	    throw new Exception("booleanValue() != true");
	}

	if (fb.booleanValue() != false) {
	    throw new Exception("booleanValue() != false");
	}

	System.out.println("OK");
    }

    public Boolean trueBooleanObjectMethod() {
	return new Boolean(true);
    }

    public Boolean falseBooleanObjectMethod() {
	return new Boolean(false);
    }
}







// File ReflectedBooleanBug3.java (bug found)


import java.lang.reflect.*;
import java.util.*;

public class ReflectedBooleanBug3 {
    public static void main(String[] argv) throws Exception {
	Method m1 = ReflectedBooleanBug3.class.getMethod("trueBooleanObjectMethod", null);
	System.out.println("m1 is " + m1);

	Method m2 = ReflectedBooleanBug3.class.getMethod("falseBooleanObjectMethod", null);
	System.out.println("m2 is " + m2);

	
	ReflectedBooleanBug3 rbb3 = new ReflectedBooleanBug3();

	Boolean tb = (Boolean) m1.invoke(rbb3,null);
	Boolean fb = (Boolean) m2.invoke(rbb3,null);

	if (tb.booleanValue() != true) {
	    throw new Exception("booleanValue() != true");
	}

	if (fb.booleanValue() != false) {
	    throw new Exception("booleanValue() != false");
	}

	System.out.println("OK");
    }

    public boolean trueBooleanObjectMethod() {
	return true;
    }

    public boolean falseBooleanObjectMethod() {
	return false;
    }
}





// File ReflectedBooleanBug4.java (bug found)

import java.lang.reflect.*;
import java.util.*;

public class ReflectedBooleanBug4 {
    public static void main(String[] argv) throws Exception {
	Method m1 = ReflectedBooleanBug4.class.getMethod("trueBooleanObjectMethod", null);
	System.out.println("m1 is " + m1);

	Method m2 = ReflectedBooleanBug4.class.getMethod("falseBooleanObjectMethod", null);
	System.out.println("m2 is " + m2);


	Boolean tb = (Boolean) m1.invoke(null,null);
	Boolean fb = (Boolean) m2.invoke(null,null);

	if (tb.booleanValue() != true) {
	    throw new Exception("booleanValue() != true");
	}

	if (fb.booleanValue() != false) {
	    throw new Exception("booleanValue() != false");
	}

	System.out.println("OK");
    }

    public static boolean trueBooleanObjectMethod() {
	return true;
    }

    public static boolean falseBooleanObjectMethod() {
	return false;
    }
}




More information about the kaffe mailing list