[kaffe] kaffe/kaffevm/readClass.c: Should class version 1.5 be supported?

Ito Kazumitsu kaz at maczuka.gcd.org
Mon Apr 2 07:21:07 PDT 2007


Hi,

I happened to find that, luckily, a class file of version 1.5
compiled by Sun's javac from source like this:

import java.util.ArrayList;
public class Test1 {
    @Deprecated
    public static void main(String[] args) {
        ArrayList<String> a = new ArrayList<String>();
        a.add("aaa");
        for (String s : a) System.out.println(s);
    }
}

can be run with Kaffe normally.

On the other hand, kaffe/kaffevm/readClass.c seems to be trying
to prevent class file version 1.5 from running.

But UnsupportedClassVersionError does not occur because of the
bug in kaffe/kaffevm/readClass.c of not returning NULL.

The question is whether UnsupportedClassVersionError should be
thrown in this case or the class file should be run normally.

I prefer the latter, and this is my proposed patch.

Index: kaffe/kaffe/kaffevm/readClass.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/readClass.c,v
retrieving revision 1.28
diff -u -r1.28 readClass.c
--- kaffe/kaffe/kaffevm/readClass.c	17 Apr 2006 17:57:07 -0000	1.28
+++ kaffe/kaffe/kaffevm/readClass.c	2 Apr 2007 13:44:23 -0000
@@ -62,12 +62,14 @@
 	if (! ((major_version == MAJOR_VERSION_V1_1 && minor_version == MINOR_VERSION_V1_1) ||
 	       (major_version == MAJOR_VERSION_V1_2 && minor_version == MINOR_VERSION_V1_2) ||
 	       (major_version == MAJOR_VERSION_V1_3 && minor_version == MINOR_VERSION_V1_3) ||
-	       (major_version == MAJOR_VERSION_V1_4 && minor_version == MINOR_VERSION_V1_4))) {
+	       (major_version == MAJOR_VERSION_V1_4 && minor_version == MINOR_VERSION_V1_4) ||
+	       (major_version == MAJOR_VERSION_V1_5 && minor_version == MINOR_VERSION_V1_5))) {
 		postExceptionMessage(einfo,
 				     JAVA_LANG(UnsupportedClassVersionError),
 				     "%d.%d",
 				     major_version,
 				     minor_version);
+		return NULL;
 	}
 
 	if (readConstantPool(classThis, fp, einfo) == false) {



More information about the kaffe mailing list