src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java

Print this page




 253         private void typeMismatch(final Method method, final Attribute attr) {
 254             value = new ExceptionProxy() {
 255                 private static final long serialVersionUID = 8473323277815075163L;
 256                 public String toString() {
 257                     return "<error>";   // eg:  @Anno(value=<error>)
 258                 }
 259                 protected RuntimeException generateException() {
 260                     return new AnnotationTypeMismatchException(method,
 261                                 attr.type.toString());
 262                 }
 263             };
 264         }
 265     }
 266 
 267 
 268     /**
 269      * ExceptionProxy for MirroredTypeException.
 270      * The toString, hashCode, and equals methods foward to the underlying
 271      * type.
 272      */
 273     private static class MirroredTypeExceptionProxy extends ExceptionProxy {
 274         private static final long serialVersionUID = 6662035281599933545L;
 275 
 276         private MirroredTypeException ex;
 277 
 278         MirroredTypeExceptionProxy(TypeMirror t) {
 279             // It would be safer if we could construct the exception in
 280             // generateException(), but there would be no way to do
 281             // that properly following deserialization.
 282             ex = new MirroredTypeException(t);
 283         }
 284 
 285         public String toString() {
 286             return ex.getQualifiedName();
 287         }
 288 
 289         public int hashCode() {
 290             TypeMirror t = ex.getTypeMirror();
 291             return (t != null)
 292                     ? t.hashCode()
 293                     : ex.getQualifiedName().hashCode();


 295 
 296         public boolean equals(Object obj) {
 297             TypeMirror t = ex.getTypeMirror();
 298             return t != null &&
 299                    obj instanceof MirroredTypeExceptionProxy &&
 300                    t.equals(
 301                         ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror());
 302         }
 303 
 304         protected RuntimeException generateException() {
 305             return (RuntimeException) ex.fillInStackTrace();
 306         }
 307     }
 308 
 309 
 310     /**
 311      * ExceptionProxy for MirroredTypesException.
 312      * The toString, hashCode, and equals methods foward to the underlying
 313      * types.
 314      */
 315     private static class MirroredTypesExceptionProxy extends ExceptionProxy {
 316         private static final long serialVersionUID = -6670822532616693951L;
 317 
 318         private MirroredTypesException ex;
 319 
 320         MirroredTypesExceptionProxy(Collection<TypeMirror> ts) {
 321             // It would be safer if we could construct the exception in
 322             // generateException(), but there would be no way to do
 323             // that properly following deserialization.
 324             ex = new MirroredTypesException(ts);
 325         }
 326 
 327         public String toString() {
 328             return ex.getQualifiedNames().toString();
 329         }
 330 
 331         public int hashCode() {
 332             Collection<TypeMirror> ts = ex.getTypeMirrors();
 333             return (ts != null)
 334                     ? ts.hashCode()
 335                     : ex.getQualifiedNames().hashCode();


 253         private void typeMismatch(final Method method, final Attribute attr) {
 254             value = new ExceptionProxy() {
 255                 private static final long serialVersionUID = 8473323277815075163L;
 256                 public String toString() {
 257                     return "<error>";   // eg:  @Anno(value=<error>)
 258                 }
 259                 protected RuntimeException generateException() {
 260                     return new AnnotationTypeMismatchException(method,
 261                                 attr.type.toString());
 262                 }
 263             };
 264         }
 265     }
 266 
 267 
 268     /**
 269      * ExceptionProxy for MirroredTypeException.
 270      * The toString, hashCode, and equals methods foward to the underlying
 271      * type.
 272      */
 273     private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
 274         private static final long serialVersionUID = 6662035281599933545L;
 275 
 276         private MirroredTypeException ex;
 277 
 278         MirroredTypeExceptionProxy(TypeMirror t) {
 279             // It would be safer if we could construct the exception in
 280             // generateException(), but there would be no way to do
 281             // that properly following deserialization.
 282             ex = new MirroredTypeException(t);
 283         }
 284 
 285         public String toString() {
 286             return ex.getQualifiedName();
 287         }
 288 
 289         public int hashCode() {
 290             TypeMirror t = ex.getTypeMirror();
 291             return (t != null)
 292                     ? t.hashCode()
 293                     : ex.getQualifiedName().hashCode();


 295 
 296         public boolean equals(Object obj) {
 297             TypeMirror t = ex.getTypeMirror();
 298             return t != null &&
 299                    obj instanceof MirroredTypeExceptionProxy &&
 300                    t.equals(
 301                         ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror());
 302         }
 303 
 304         protected RuntimeException generateException() {
 305             return (RuntimeException) ex.fillInStackTrace();
 306         }
 307     }
 308 
 309 
 310     /**
 311      * ExceptionProxy for MirroredTypesException.
 312      * The toString, hashCode, and equals methods foward to the underlying
 313      * types.
 314      */
 315     private static final class MirroredTypesExceptionProxy extends ExceptionProxy {
 316         private static final long serialVersionUID = -6670822532616693951L;
 317 
 318         private MirroredTypesException ex;
 319 
 320         MirroredTypesExceptionProxy(Collection<TypeMirror> ts) {
 321             // It would be safer if we could construct the exception in
 322             // generateException(), but there would be no way to do
 323             // that properly following deserialization.
 324             ex = new MirroredTypesException(ts);
 325         }
 326 
 327         public String toString() {
 328             return ex.getQualifiedNames().toString();
 329         }
 330 
 331         public int hashCode() {
 332             Collection<TypeMirror> ts = ex.getTypeMirrors();
 333             return (ts != null)
 334                     ? ts.hashCode()
 335                     : ex.getQualifiedNames().hashCode();