src/share/classes/javax/lang/model/type/MirroredTypesException.java

changeset 193
18c433be7aa7
parent 1
9a66ca7c79fa
child 554
9d9f26857129
equal deleted inserted replaced
192:42f9d392159d 193:18c433be7aa7
1 /* 1 /*
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this 7 * published by the Free Software Foundation. Sun designates this
23 * have any questions. 23 * have any questions.
24 */ 24 */
25 25
26 package javax.lang.model.type; 26 package javax.lang.model.type;
27 27
28
29 import java.lang.annotation.Annotation; 28 import java.lang.annotation.Annotation;
30 import java.util.ArrayList; 29 import java.util.ArrayList;
31 import java.util.List; 30 import java.util.List;
32 import java.util.Collections; 31 import java.util.Collections;
33 32 import java.io.ObjectInputStream;
33 import java.io.IOException;
34 import javax.lang.model.element.Element; 34 import javax.lang.model.element.Element;
35 35
36 36
37 /** 37 /**
38 * Thrown when an application attempts to access a sequence of {@link 38 * Thrown when an application attempts to access a sequence of {@link
47 */ 47 */
48 public class MirroredTypesException extends RuntimeException { 48 public class MirroredTypesException extends RuntimeException {
49 49
50 private static final long serialVersionUID = 269; 50 private static final long serialVersionUID = 269;
51 51
52 // Should this be non-final for a custum readObject method? 52 private transient List<? extends TypeMirror> types; // cannot be serialized
53 private final transient List<? extends TypeMirror> types; // cannot be serialized
54 53
55 /** 54 /**
56 * Constructs a new MirroredTypesException for the specified types. 55 * Constructs a new MirroredTypesException for the specified types.
57 * 56 *
58 * @param types the types being accessed 57 * @param types the types being accessed
59 */ 58 */
60 public MirroredTypesException(List<? extends TypeMirror> types) { 59 public MirroredTypesException(List<? extends TypeMirror> types) {
61 super("Attempt to access Class objects for TypeMirrors " + types); 60 super("Attempt to access Class objects for TypeMirrors " +
61 (types = // defensive copy
62 new ArrayList<TypeMirror>(types)).toString() );
62 this.types = Collections.unmodifiableList(types); 63 this.types = Collections.unmodifiableList(types);
63 } 64 }
64 65
65 /** 66 /**
66 * Returns the type mirrors corresponding to the types being accessed. 67 * Returns the type mirrors corresponding to the types being accessed.
70 * @return the type mirrors in construction order, or {@code null} if unavailable 71 * @return the type mirrors in construction order, or {@code null} if unavailable
71 */ 72 */
72 public List<? extends TypeMirror> getTypeMirrors() { 73 public List<? extends TypeMirror> getTypeMirrors() {
73 return types; 74 return types;
74 } 75 }
76
77 /**
78 * Explicitly set all transient fields.
79 */
80 private void readObject(ObjectInputStream s)
81 throws IOException, ClassNotFoundException {
82 s.defaultReadObject();
83 types = null;
84 }
75 } 85 }

mercurial