Mercurial > hg > release > icedtea7-forest-2.2 > langtools
changeset 192:18c433be7aa7
6583626: Improve serialization support in javax.lang.model.type exception classes
Reviewed-by: jjg
author | darcy |
---|---|
date | Fri, 16 Jan 2009 14:05:55 -0800 |
parents | 42f9d392159d |
children | d0b33fe8e710 |
files | src/share/classes/javax/lang/model/type/MirroredTypeException.java src/share/classes/javax/lang/model/type/MirroredTypesException.java |
diffstat | 2 files changed, 28 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/javax/lang/model/type/MirroredTypeException.java Thu Jan 15 18:06:36 2009 -0800 +++ b/src/share/classes/javax/lang/model/type/MirroredTypeException.java Fri Jan 16 14:05:55 2009 -0800 @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package javax.lang.model.type; - +import java.io.ObjectInputStream; +import java.io.IOException; import java.lang.annotation.Annotation; import javax.lang.model.element.Element; @@ -67,4 +68,13 @@ public TypeMirror getTypeMirror() { return type; } + + /** + * Explicitly set all transient fields. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + type = null; + } }
--- a/src/share/classes/javax/lang/model/type/MirroredTypesException.java Thu Jan 15 18:06:36 2009 -0800 +++ b/src/share/classes/javax/lang/model/type/MirroredTypesException.java Fri Jan 16 14:05:55 2009 -0800 @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,12 +25,12 @@ package javax.lang.model.type; - import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; import java.util.Collections; - +import java.io.ObjectInputStream; +import java.io.IOException; import javax.lang.model.element.Element; @@ -49,8 +49,7 @@ private static final long serialVersionUID = 269; - // Should this be non-final for a custum readObject method? - private final transient List<? extends TypeMirror> types; // cannot be serialized + private transient List<? extends TypeMirror> types; // cannot be serialized /** * Constructs a new MirroredTypesException for the specified types. @@ -58,7 +57,9 @@ * @param types the types being accessed */ public MirroredTypesException(List<? extends TypeMirror> types) { - super("Attempt to access Class objects for TypeMirrors " + types); + super("Attempt to access Class objects for TypeMirrors " + + (types = // defensive copy + new ArrayList<TypeMirror>(types)).toString() ); this.types = Collections.unmodifiableList(types); } @@ -72,4 +73,13 @@ public List<? extends TypeMirror> getTypeMirrors() { return types; } + + /** + * Explicitly set all transient fields. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + types = null; + } }