Debian Codegraph @

org.eclipse.jdt.annotation/src/org/eclipse/jdt/annotation/NonNull.java

raw symbols SCIP
1 /*******************************************************************************
2 * Copyright (c) 2011, 2013 Stephan Herrmann and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * Stephan Herrmann - initial API and implementation
13 * IBM Corporation - bug fixes
14 *******************************************************************************/
15 package org.eclipse.jdt.annotation;
16
17 import static java.lang.annotation.ElementType.TYPE_USE;
18
19 import java.lang.annotation.Documented;
20 import java.lang.annotation.ElementType;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 import java.lang.annotation.Target;
24
25 /**
26 * Qualifier for a reference type in a {@link ElementType#TYPE_USE TYPE_USE} position:
27 * The type that has this annotation is intended to not include the value <code>null</code>.
28 * <p>
29 * If annotation based null analysis is enabled using this annotation has two consequences:
30 * </p>
31 * <ol>
32 * <li>Dereferencing an expression of this type is safe, i.e., no <code>NullPointerException</code> can occur at runtime.</li>
33 * <li>An attempt to bind a <code>null</code> value to an entity (field, local variable, method parameter or method return value)
34 * of this type is a compile time error.</li>
35 * </ol>
36 * For the second case, diagnostics issued by the compiler should distinguish three situations:
37 * <ol>
38 * <li>Nullness of the value can be statically determined, the entity is definitely bound from either of:
39 * <ul><li>the value <code>null</code>, or</li>
40 * <li>an entity with a {@link Nullable @Nullable} type.</li></ul></li>
41 * <li>Nullness cannot definitely be determined, because different code branches yield different results.</li>
42 * <li>Nullness cannot be determined, because other program elements are involved for which
43 * null annotations are lacking.</li>
44 * </ol>
45 * <p>
46 * <b>Note:</b> Since org.eclipse.jdt.annotation 2.0.0, the
47 * <code>@Target</code> is <code>{TYPE_USE}</code>. For the old API, see
48 * <a href="http://help.eclipse.org/kepler/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/NonNull.html">
49 * <code>@NonNull</code> in 1.1.0</a>.
50 * </p>
51 * @since 1.0
52 */
53 @Documented
54 @Retention(RetentionPolicy.CLASS)
55 @Target({ TYPE_USE })
56 public @interface NonNull {
57 // marker annotation with no members
58 }