8008279: Remove InvalidContainerAnnotationError.java
authordarcy
Tue, 26 Feb 2013 17:38:29 -0800
changeset 16037 1cf21ce98a25
parent 16036 a30224365db2
child 16038 de84354579d3
child 16124 5f589ebf7cd3
8008279: Remove InvalidContainerAnnotationError.java Reviewed-by: jfranck
jdk/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java
jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java
jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java
--- a/jdk/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java	Tue Feb 26 17:01:04 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.lang.annotation;
-
-import java.util.Objects;
-
-/**
- * Thrown to indicate that an annotation type expected to act as a
- * container for another annotation type by virture of an @Repeatable
- * annotation, does not act as a container.
- *
- * @see   java.lang.reflect.AnnotatedElement
- * @since 1.8
- * @jls   9.6 Annotation Types
- * @jls   9.7 Annotations
- */
-public class InvalidContainerAnnotationError extends AnnotationFormatError {
-    private static final long serialVersionUID = 5023L;
-
-    /**
-     * The instance of the erroneous container.
-     */
-    private transient Annotation container;
-
-    /**
-     * The type of the annotation that should be contained in the
-     * container.
-     */
-    private transient Class<? extends Annotation> annotationType;
-
-    /**
-     * Constructs a new InvalidContainerAnnotationError with the
-     * specified detail message.
-     *
-     * @param  message the detail message.
-     */
-    public InvalidContainerAnnotationError(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs a new InvalidContainerAnnotationError with the specified
-     * detail message and cause.  Note that the detail message associated
-     * with {@code cause} is <i>not</i> automatically incorporated in
-     * this error's detail message.
-     *
-     * @param message the detail message
-     * @param cause the cause, may be {@code null}
-     */
-    public InvalidContainerAnnotationError(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    /**
-     * Constructs a new InvalidContainerAnnotationError with the
-     * specified cause and a detail message of {@code (cause == null ?
-     * null : cause.toString())} (which typically contains the class
-     * and detail message of {@code cause}).
-     *
-     * @param cause the cause, may be {@code null}
-     */
-    public InvalidContainerAnnotationError(Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Constructs InvalidContainerAnnotationError for the specified
-     * container instance and contained annotation type.
-     *
-     * @param  message the detail message
-     * @param  cause the cause, may be {@code null}
-     * @param container the erroneous container instance, may be
-     *        {@code null}
-     * @param annotationType the annotation type intended to be
-     *        contained, may be {@code null}
-     */
-    public InvalidContainerAnnotationError(String message,
-                                           Throwable cause,
-                                           Annotation container,
-                                           Class<? extends Annotation> annotationType) {
-        super(message, cause);
-        this.container = container;
-        this.annotationType = annotationType;
-    }
-
-    /**
-     * Returns the erroneous container.
-     *
-     * @return the erroneous container, may return {@code null}
-     */
-    public Annotation getContainer() {
-        return container;
-    }
-
-    /**
-     * Returns the annotation type intended to be contained. Returns
-     * {@code null} if the annotation type intended to be contained
-     * could not be determined.
-     *
-     * @return the annotation type intended to be contained, or {@code
-     * null} if unknown
-     */
-    public Class<? extends Annotation> getAnnotationType() {
-        return annotationType;
-    }
-}
--- a/jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java	Tue Feb 26 17:01:04 2013 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java	Tue Feb 26 17:38:29 2013 -0800
@@ -26,6 +26,7 @@
 package java.lang.reflect;
 
 import java.lang.annotation.Annotation;
+import java.lang.annotation.AnnotationFormatError;
 
 /**
  * Represents an annotated element of the program currently running in this
@@ -86,8 +87,8 @@
  *
  * <p>Attempting to read annotations of a repeatable annotation type T
  * that are contained in an annotation whose type is not, in fact, the
- * containing annotation type of T will result in an
- * InvalidContainerAnnotationError.
+ * containing annotation type of T, will result in an {@link
+ * AnnotationFormatError}.
  *
  * <p>Finally, attempting to read a member whose definition has evolved
  * incompatibly will result in a {@link
@@ -96,10 +97,9 @@
  *
  * @see java.lang.EnumConstantNotPresentException
  * @see java.lang.TypeNotPresentException
- * @see java.lang.annotation.AnnotationFormatError
+ * @see AnnotationFormatError
  * @see java.lang.annotation.AnnotationTypeMismatchException
  * @see java.lang.annotation.IncompleteAnnotationException
- * @see java.lang.annotation.InvalidContainerAnnotationError
  * @since 1.5
  * @author Josh Bloch
  */
--- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java	Tue Feb 26 17:01:04 2013 -0800
+++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java	Tue Feb 26 17:38:29 2013 -0800
@@ -86,11 +86,11 @@
             Class<? extends Annotation> containerClass = containerInstance.annotationType();
             AnnotationType annoType = AnnotationType.getInstance(containerClass);
             if (annoType == null)
-                throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations");
+                throw new AnnotationFormatError(containerInstance + " is an invalid container for repeating annotations");
 
             Method m = annoType.members().get("value");
             if (m == null)
-                throw new InvalidContainerAnnotationError(containerInstance +
+                throw new AnnotationFormatError(containerInstance +
                                                           " is an invalid container for repeating annotations");
             m.setAccessible(true);
 
@@ -103,11 +103,9 @@
                  IllegalArgumentException | // parameters doesn't match
                  InvocationTargetException | // the value method threw an exception
                  ClassCastException e) { // well, a cast failed ...
-            throw new InvalidContainerAnnotationError(
+            throw new AnnotationFormatError(
                     containerInstance + " is an invalid container for repeating annotations",
-                    e,
-                    containerInstance,
-                    null);
+                    e);
         }
     }
 
@@ -129,12 +127,10 @@
             return l;
         } catch (ClassCastException |
                  NullPointerException e) {
-            throw new InvalidContainerAnnotationError(
+            throw new AnnotationFormatError(
                     String.format("%s is an invalid container for repeating annotations of type: %s",
                         containerInstance, annotationClass),
-                    e,
-                    containerInstance,
-                    annotationClass);
+                    e);
         }
     }
 }