001    /*
002     * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
003     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004     *
005     * This code is free software; you can redistribute it and/or modify it
006     * under the terms of the GNU General Public License version 2 only, as
007     * published by the Free Software Foundation.  Sun designates this
008     * particular file as subject to the "Classpath" exception as provided
009     * by Sun in the LICENSE file that accompanied this code.
010     *
011     * This code is distributed in the hope that it will be useful, but WITHOUT
012     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014     * version 2 for more details (a copy is included in the LICENSE file that
015     * accompanied this code).
016     *
017     * You should have received a copy of the GNU General Public License version
018     * 2 along with this work; if not, write to the Free Software Foundation,
019     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020     *
021     * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022     * CA 95054 USA or visit www.sun.com if you need additional information or
023     * have any questions.
024     */
025    
026    package javax.lang.model.element;
027    
028    /**
029     * Indicates that an unknown kind of annotation value was encountered.
030     * This can occur if the language evolves and new kinds of annotation
031     * values can be stored in an annotation.  May be thrown by an
032     * {@linkplain AnnotationValueVisitor annotation value visitor} to
033     * indicate that the visitor was created for a prior version of the
034     * language.
035     *
036     * @author Joseph D. Darcy
037     * @author Scott Seligman
038     * @author Peter von der Ahé
039     * @see AnnotationValueVisitor#visitUnknown
040     * @since 1.6
041     */
042    public class UnknownAnnotationValueException extends RuntimeException {
043    
044        private static final long serialVersionUID = 269L;
045    
046        private transient AnnotationValue av;
047        private transient Object parameter;
048    
049        /**
050         * Creates a new {@code UnknownAnnotationValueException}.  The
051         * {@code p} parameter may be used to pass in an additional
052         * argument with information about the context in which the
053         * unknown annotation value was encountered; for example, the
054         * visit methods of {@link AnnotationValueVisitor} may pass in
055         * their additional parameter.
056         *
057         * @param av the unknown annotation value, may be {@code null}
058         * @param p an additional parameter, may be {@code null}
059         */
060        public UnknownAnnotationValueException(AnnotationValue av, Object p) {
061            super("Unknown annotation value: " + av);
062            this.av = av;
063            this.parameter = p;
064        }
065    
066        /**
067         * Returns the unknown annotation value.
068         * The value may be unavailable if this exception has been
069         * serialized and then read back in.
070         *
071         * @return the unknown element, or {@code null} if unavailable
072         */
073        public AnnotationValue getUnknownAnnotationValue() {
074            return av;
075        }
076    
077        /**
078         * Returns the additional argument.
079         *
080         * @return the additional argument
081         */
082        public Object getArgument() {
083            return parameter;
084        }
085    }