All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jdt.annotation.NonNull Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2011, 2013 Stephan Herrmann and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Stephan Herrmann - initial API and implementation
 *     IBM Corporation - bug fixes
 *******************************************************************************/
package org.eclipse.jdt.annotation;

import static java.lang.annotation.ElementType.TYPE_USE;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Qualifier for a reference type in a {@link ElementType#TYPE_USE TYPE_USE} position:
 * The type that has this annotation is intended to not include the value null.
 * 

* If annotation based null analysis is enabled using this annotation has two consequences: *

*
    *
  1. Dereferencing an expression of this type is safe, i.e., no NullPointerException can occur at runtime.
  2. *
  3. An attempt to bind a null value to an entity (field, local variable, method parameter or method return value) * of this type is a compile time error.
  4. *
* For the second case, diagnostics issued by the compiler should distinguish three situations: *
    *
  1. Nullness of the value can be statically determined, the entity is definitely bound from either of: *
    • the value null, or
    • *
    • an entity with a {@link Nullable @Nullable} type.
  2. *
  3. Nullness cannot definitely be determined, because different code branches yield different results.
  4. *
  5. Nullness cannot be determined, because other program elements are involved for which * null annotations are lacking.
  6. *
*

* Note: Since org.eclipse.jdt.annotation 2.0.0, the * @Target is {TYPE_USE}. For the old API, see * * @NonNull in 1.1.0. *

* @since 1.0 */ @Documented @Retention(RetentionPolicy.CLASS) @Target({ TYPE_USE }) public @interface NonNull { // marker annotation with no members }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy