[Kaffe] bug found in Class.c, possible patch included

Moses DeJong dejong at cs.umn.edu
Thu Jan 14 04:28:27 PST 1999


There is a bug in the java.lang.Class.getMethod() method. It should
return a Method with no arguments if null is passed as the second
argument. Here is an example file.


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


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

    public void m() {}
}


JDK output

% java MethodBug
m is public void MethodBug.m()



Kaffe output

% java MethodBug
java.lang.NullPointerException
        at java/lang/Class.getMethod(149)
        at MethodBug.main(7)



Kaffe output with patch

% java MethodBug
m is public void MethodBug.m()



Patch file

*** copy_Class.c        Thu Jan 14 04:34:04 1999
--- Class.c     Thu Jan 14 06:17:06 1999
***************
*** 701,706 ****
--- 701,711 ----
        int   i;
        errorInfo info;
  
+       /* check null object and void method case */
+       if ((argtypes == NULL) && !strcmp(sig,"()V")) {
+           return 1;
+       }
+ 
        sig++;  /* skip leading '(' */
        for (i = 0; i < ARRAY_SIZE(argtypes); i++) {




This patch fixes the problem I was having but I am not 100%
sure that it is "the right thing to do". Please take a look
at it and see if it is good enough to go into the CVS tree.


thanks
mo dejong
dejong at cs.umn.edu



More information about the kaffe mailing list