BUG: ObjectStreamClass.getSerialVersionUID() Is Not JDK 1.1.4 Compatible (285218)



The information in this article applies to:

  • Microsoft virtual machine

This article was previously published under Q285218

SYMPTOMS

When the ObjectStreamClass.getSerialVersionUID class is called for an Object array of private classes, the value that is returned differs between the Microsoft virtual machine (Microsoft VM) and Sun Microsystems' JDK 1.1.4 virtual machine. However, when the Object classes are declared public, the same value is returned.

CAUSE

This problem occurs because Class.getModifiers on the Microsoft VM always indicates that the class is public for array classes; however, on the virtual machine that shipped with Sun's JDK 1.1.4, the flags for array types only include the public bit if the underlying base type is public.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

The following code reproduces the problem:
// TestCaseMain.java
import java.io.*;

public class TestCaseMain { 
  public static void main(String[] args) { 
    new TestCaseMain().go();
  }
  
  void go() { 
    TestA1[] a1 = new TestA1[0];
    TestA2[] a2 = new TestA2[0];
    ObjectStreamClass osc = ObjectStreamClass.lookup(a1.getClass());
    long id = osc.getSerialVersionUID();
    System.out.println("Non-public class array ID = " + id);
    osc = ObjectStreamClass.lookup(a2.getClass());
    id = osc.getSerialVersionUID();
    System.out.println("Public class array ID = " + id);    
  }
}

class TestA1 { 
}

// TestA2.java
public class TestA2{
}
				

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbnofix KB285218