jdk/src/java.base/share/classes/java/lang/Deprecated.java
author vinnie
Thu, 13 Oct 2016 15:27:33 +0100
changeset 41585 8da39dd19c93
parent 41553 eb5002231dfa
child 42338 a60f280f803c
permissions -rw-r--r--
8165064: Enhance thread contexts in JNDI Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
28305
b29f40cdd33a 6481080: (ann) @Deprecated annotation has no effect on packages
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4672
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4672
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4672
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4672
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4672
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.annotation.*;
4672
ca386fa28a62 6908218: java.lang.Deprecated should have explicit @Target meta-annotation.
darcy
parents: 2
diff changeset
    29
import static java.lang.annotation.ElementType.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
37304
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    32
 * A program element annotated {@code @Deprecated} is one that programmers
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    33
 * are discouraged from using. An element may be deprecated for any of several
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    34
 * reasons, for example, its usage is likely to lead to errors; it may
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    35
 * be changed incompatibly or removed in a future version; it has been
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    36
 * superseded by a newer, usually preferable alternative; or it is obsolete.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    37
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    38
 * <p>Compilers issue warnings when a deprecated program element is used or
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    39
 * overridden in non-deprecated code. Use of the {@code @Deprecated}
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    40
 * annotation on a local variable declaration or on a parameter declaration
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    41
 * or a package declaration has no effect on the warnings issued by a compiler.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    42
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    43
 * <p>This annotation type has a string-valued element {@code since}. The value
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    44
 * of this element indicates the version in which the annotated program element
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    45
 * was first deprecated.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
37304
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    47
 * <p>This annotation type has a boolean-valued element {@code forRemoval}.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    48
 * A value of {@code true} indicates intent to remove the annotated program
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    49
 * element in a future version. A value of {@code false} indicates that use of
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    50
 * the annotated program element is discouraged, but at the time the program
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    51
 * element was annotated, there was no specific intent to remove it.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    52
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    53
 * @apiNote
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    54
 * It is strongly recommended that the reason for deprecating a program element
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    55
 * be explained in the documentation, using the {@code @deprecated}
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    56
 * javadoc tag. The documentation should also suggest and link to a
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    57
 * recommended replacement API, if applicable. A replacement API often
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    58
 * has subtly different semantics, so such issues should be discussed as
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    59
 * well.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    60
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    61
 * <p>It is recommended that a {@code since} value be provided with all newly
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    62
 * annotated program elements. Note that {@code since} cannot be mandatory,
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    63
 * as there are many existing annotations that lack this element value.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    64
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    65
 * <p>There is no defined order among annotation elements. As a matter of
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    66
 * style, the {@code since} element should be placed first.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    67
 *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    68
 * <p>The {@code @Deprecated} annotation should always be present if
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    69
 * the {@code @deprecated} javadoc tag is present, and vice-versa.
28305
b29f40cdd33a 6481080: (ann) @Deprecated annotation has no effect on packages
darcy
parents: 25859
diff changeset
    70
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @author  Neal Gafter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @since 1.5
28305
b29f40cdd33a 6481080: (ann) @Deprecated annotation has no effect on packages
darcy
parents: 25859
diff changeset
    73
 * @jls 9.6.4.6 @Deprecated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
@Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
@Retention(RetentionPolicy.RUNTIME)
4672
ca386fa28a62 6908218: java.lang.Deprecated should have explicit @Target meta-annotation.
darcy
parents: 2
diff changeset
    77
@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
public @interface Deprecated {
37304
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    79
    /**
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    80
     * Returns the version in which the annotated element became deprecated.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    81
     * The version string is in the same format and namespace as the value of
41553
eb5002231dfa 8168096: markup error in "since" element spec of @Deprecated
smarks
parents: 37304
diff changeset
    82
     * the {@code @since} javadoc tag. The default value is the empty
37304
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    83
     * string.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    84
     *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    85
     * @return the version string
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    86
     * @since 9
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    87
     */
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    88
    String since() default "";
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    89
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    90
    /**
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    91
     * Indicates whether the annotated element is subject to removal in a
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    92
     * future version. The default value is {@code false}.
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    93
     *
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    94
     * @return whether the element is subject to removal
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    95
     * @since 9
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    96
     */
c155b23ea178 8145461: finalize and integrate @Deprecated annotation specification change
smarks
parents: 33520
diff changeset
    97
    boolean forRemoval() default false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
}