Source for java.lang.annotation.AnnotationTypeMismatchException

   1: /* AnnotationTypeMismatchException.java - Thrown when annotation has changed
   2:    Copyright (C) 2004, 2005 Free Software Foundation
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: package java.lang.annotation;
  39: 
  40: import java.lang.reflect.Method;
  41: 
  42: /**
  43:  * Thrown when accessing an element within an annotation for
  44:  * which the type has changed, since compilation or serialization
  45:  * took place.  The mismatch between the compiled or serialized
  46:  * type and the current type causes this exception to be thrown.
  47:  * 
  48:  * @author Tom Tromey (tromey@redhat.com)
  49:  * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  50:  * @since 1.5
  51:  */
  52: public class AnnotationTypeMismatchException extends RuntimeException
  53: {
  54: 
  55:   /**
  56:    * For compatability with Sun's JDK
  57:    */
  58:   private static final long serialVersionUID = 8125925355765570191L;
  59: 
  60:   /**
  61:    * Constructs an <code>AnnotationTypeMismatchException</code>
  62:    * which is due to a mismatched type in the annotation
  63:    * element, <code>m</code>. The erroneous type used for the
  64:    * data in <code>m</code> is represented by the string,
  65:    * <code>type</code>.  This string is of an undefined format,
  66:    * and may contain the value as well as the type.
  67:    *
  68:    * @param m the element from the annotation.
  69:    * @param type the name of the erroneous type found in <code>m</code>.
  70:    */
  71:   public AnnotationTypeMismatchException(Method m, String type)
  72:   {
  73:     this.element = m;
  74:     this.foundType = type;
  75:   }
  76: 
  77:   /**
  78:    * Returns the element from the annotation, for which a
  79:    * mismatch occurred.
  80:    *
  81:    * @return the element with the mismatched type.
  82:    */
  83:   public Method element()
  84:   {
  85:     return element;
  86:   }
  87: 
  88:   /**
  89:    * Returns the erroneous type used by the element,
  90:    * represented as a <code>String</code>.  The format
  91:    * of this <code>String</code> is not explicitly specified,
  92:    * and may contain the value as well as the type.
  93:    *
  94:    * @return the type found in the element.
  95:    */
  96:   public String foundType()
  97:   {
  98:     return foundType;
  99:   }
 100: 
 101:   // Names are chosen from serialization spec.
 102:   /**
 103:    * The element from the annotation.
 104:    *
 105:    * @serial the element with the mismatched type.
 106:    */
 107:   private Method element;
 108: 
 109:   /**
 110:    * The erroneous type used by the element.
 111:    *
 112:    * @serial the type found in the element.
 113:    */
 114:   private String foundType;
 115: 
 116: }