-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b127
-
generic
-
generic
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
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
- csr of
-
CCC-6226715 (ann) java.lang.annotation.AnnotationTypeMismatchException could not be serialized
-
- Closed
-
- relates to
-
JDK-8160675 Issue lint warning for non-serializable non-transient instance fields in serializable type
-
- Resolved
-
-
JDK-6583626 Improve serialization support in javax.lang.model.type exception classes
-
- Closed
-
-
JDK-6749308 java.io, java.lang, java.util exception classes don't specify serialVersionUID
-
- Closed
-