CSR :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
The instance of the java.lang.annotation.AnnotationTypeMismatchException class could not be serialized because the AnnotationTypeMismatchException class has non-transient and non-static field 'element' of non-serializable class java.lang.reflect.Method. The minimized test to reproduce the bug: --- Test.java --- import java.lang.annotation.AnnotationTypeMismatchException; import java.lang.reflect.Method; import java.io.*; public class Test { public static void main(String argv[]) throws Exception { Method[] meths = MyClass.class.getDeclaredMethods(); System.out.println("meths[0]: " + meths[0].toString()); AnnotationTypeMismatchException obj = new AnnotationTypeMismatchException(meths[0], "foundType"); ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream("test.ser")); System.out.println("Serializing AnnotationTypeMismatchException ..."); oos.writeObject(obj); oos.close(); System.out.println("PASSED."); } } class MyClass { public MyClass() { super(); } public String dummyMethod() { return ""; } } --- end-of-Test.java --- Test output: ----------- <gyi@mars> java Test meths[0]: public java.lang.String MyClass.dummyMethod() Serializing AnnotationTypeMismatchException ... Exception in thread "main" java.io.NotSerializableException: java.lang.reflect.Method at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291) at Test.main(Test.java:16) ###@###.### 2005-2-08 16:53:49 GMT
|