1/*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package java.lang;
27
28import java.lang.annotation.*;
29import static java.lang.annotation.ElementType.*;
30
31/**
32 * A program element annotated {@code @Deprecated} is one that programmers
33 * are discouraged from using. An element may be deprecated for any of several
34 * reasons, for example, its usage is likely to lead to errors; it may
35 * be changed incompatibly or removed in a future version; it has been
36 * superseded by a newer, usually preferable alternative; or it is obsolete.
37 *
38 * <p>Compilers issue warnings when a deprecated program element is used or
39 * overridden in non-deprecated code. Use of the {@code @Deprecated}
40 * annotation on a local variable declaration or on a parameter declaration
41 * or a package declaration has no effect on the warnings issued by a compiler.
42 *
43 * <p>When a module is deprecated, the use of that module in {@code
44 * requires}, but not in {@code exports} or {@code opens} clauses causes
45 * a warning to be issued. A module being deprecated does <em>not</em> cause
46 * warnings to be issued for uses of types within the module.
47 *
48 * <p>This annotation type has a string-valued element {@code since}. The value
49 * of this element indicates the version in which the annotated program element
50 * was first deprecated.
51 *
52 * <p>This annotation type has a boolean-valued element {@code forRemoval}.
53 * A value of {@code true} indicates intent to remove the annotated program
54 * element in a future version. A value of {@code false} indicates that use of
55 * the annotated program element is discouraged, but at the time the program
56 * element was annotated, there was no specific intent to remove it.
57 *
58 * @apiNote
59 * It is strongly recommended that the reason for deprecating a program element
60 * be explained in the documentation, using the {@code @deprecated}
61 * javadoc tag. The documentation should also suggest and link to a
62 * recommended replacement API, if applicable. A replacement API often
63 * has subtly different semantics, so such issues should be discussed as
64 * well.
65 *
66 * <p>It is recommended that a {@code since} value be provided with all newly
67 * annotated program elements. Note that {@code since} cannot be mandatory,
68 * as there are many existing annotations that lack this element value.
69 *
70 * <p>There is no defined order among annotation elements. As a matter of
71 * style, the {@code since} element should be placed first.
72 *
73 * <p>The {@code @Deprecated} annotation should always be present if
74 * the {@code @deprecated} javadoc tag is present, and vice-versa.
75 *
76 * @author  Neal Gafter
77 * @since 1.5
78 * @jls 9.6.4.6 @Deprecated
79 */
80@Documented
81@Retention(RetentionPolicy.RUNTIME)
82@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE})
83public @interface Deprecated {
84    /**
85     * Returns the version in which the annotated element became deprecated.
86     * The version string is in the same format and namespace as the value of
87     * the {@code @since} javadoc tag. The default value is the empty
88     * string.
89     *
90     * @return the version string
91     * @since 9
92     */
93    String since() default "";
94
95    /**
96     * Indicates whether the annotated element is subject to removal in a
97     * future version. The default value is {@code false}.
98     *
99     * @return whether the element is subject to removal
100     * @since 9
101     */
102    boolean forRemoval() default false;
103}
104