problem with ObjectInputStream.java

Moses DeJong dejong at cs.umn.edu
Thu Feb 4 12:01:06 PST 1999


On Thu, 4 Feb 1999, Archie Cobbs wrote:

> In ObjectInputStream.java, note the double declaration of "Integer key":
> 
> >     case ObjectStreamConstants.TC_CLASSDESC:
> > 	    ObjectStreamClass cls = new ObjectStreamClass();
> > 	    currObject = (Object)cls;
> > 	    Integer key = new Integer(++nextKey);
> > 	    objectsDone.put(key, currObject);
> > 	    invokeObjectReader(currObject, ObjectStreamClass.class);
> > 	    cls.clazz = resolveClass(cls);
> > 	    cls.buildFieldsAndOffset();
> > 	    break;
> > 
> >     case ObjectStreamConstants.TC_STRING:
> > 	    currObject = readUTF();
> > 	    Integer key = new Integer(++nextKey);
> > 	    objectsDone.put(key, currObject);
> > 	    break;
> 
> Clearly this makes sense, once you realize that there's no way
> during execution that "key" will be declared twice.
> 
> However, jikes doesn't recognize this. Is this a Jikes bug, or
> is the above code not really valid?
> 
> -Archie



Hello all.

It looks like the problem with multiple vars with the same name
is a bug in pizza. Here is a small example and output from jikes,
javac, and pizza.


public class SwitchBug {
    public static void main(String[] argv) {
	switch (1) {
	case 1:
	    int num = 1;
	case 2:
	    int num = 2;
	}
    }
}


% jikes SwitchBug.java      
Found 1 semantic error and compiling "SwitchBug.java":
     7.             int num = 2;
                        <->
*** Error[61]: Duplicate declaration of local variable "num"



% /soft/java/JDK-1.1.6/bin/javac SwitchBug.java
SwitchBug.java:7: Variable 'num' is already defined in this method.
            int num = 2;
                ^
1 error



% /tmp/mo/install_kaffe/bin/javac SwitchBug.java
(no error)



So it seems like ObjectInputStream.java needs to be fixed.


I hope that helps
Mo DeJong
dejong at cs.umn.edu



More information about the kaffe mailing list