src/share/classes/javax/lang/model/type/MirroredTypesException.java
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
@@ -23,16 +23,16 @@
* have any questions.
*/
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;
/**
* Thrown when an application attempts to access a sequence of {@link
@@ -47,20 +47,21 @@
*/
public class MirroredTypesException extends RuntimeException {
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.
*
* @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);
}
/**
* Returns the type mirrors corresponding to the types being accessed.
@@ -70,6 +71,15 @@
* @return the type mirrors in construction order, or {@code null} if unavailable
*/
public List<? extends TypeMirror> getTypeMirrors() {
return types;
}
+
+ /**
+ * Explicitly set all transient fields.
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException {
+ s.defaultReadObject();
+ types = null;
+ }
}