Create tests for TYPE_USE nullability annotations
- tests and declarations for checkerframework has been moved, because they only Java 8 targeted - tests for eclipse annotations has been just copied, because there are two jars: one for Java 8 and other for earlier versions
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
package org.checkerframework.checker.nullness.qual;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* {@link NonNull} is a type annotation that indicates that an expression is
|
||||
* never {@code null}.
|
||||
*
|
||||
* <p>
|
||||
* For fields of a class, the {@link NonNull} annotation indicates that this
|
||||
* field is never {@code null}
|
||||
* <em>after the class has been fully initialized</em>. Class initialization is
|
||||
* controlled by the Freedom Before Commitment type system, see
|
||||
* {@link InitializationChecker} for more details.
|
||||
*
|
||||
* <p>
|
||||
* For static fields, the {@link NonNull} annotation indicates that this field
|
||||
* is never {@code null} <em>after the containing class is initialized</em>.
|
||||
*
|
||||
* <p>
|
||||
* This annotation is rarely written in source code, because it is the default.
|
||||
*
|
||||
* <p>
|
||||
* This annotation is associated with the {@link AbstractNullnessChecker}.
|
||||
*
|
||||
* @see Nullable
|
||||
* @see MonotonicNonNull
|
||||
* @see AbstractNullnessChecker
|
||||
* @checker_framework.manual #nullness-checker Nullness Checker
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
|
||||
public @interface NonNull {
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.checkerframework.checker.nullness.qual;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* {@link Nullable} is a type annotation that indicates that the value is not
|
||||
* known to be non-null (see {@link NonNull}). Only if an expression has a
|
||||
* {@link Nullable} type may it be assigned {@code null}.
|
||||
*
|
||||
* <p>
|
||||
* This annotation is associated with the {@link AbstractNullnessChecker}.
|
||||
*
|
||||
* @see NonNull
|
||||
* @see MonotonicNonNull
|
||||
* @see AbstractNullnessChecker
|
||||
* @checker_framework.manual #nullness-checker Nullness Checker
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
|
||||
public @interface Nullable {
|
||||
}
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 2013 Stephan Herrmann and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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 <code>null</code>.
|
||||
* <p>
|
||||
* If annotation based null analysis is enabled using this annotation has two consequences:
|
||||
* </p>
|
||||
* <ol>
|
||||
* <li>Dereferencing an expression of this type is safe, i.e., no <code>NullPointerException</code> can occur at runtime.</li>
|
||||
* <li>An attempt to bind a <code>null</code> value to an entity (field, local variable, method parameter or method return value)
|
||||
* of this type is a compile time error.</li>
|
||||
* </ol>
|
||||
* For the second case, diagnostics issued by the compiler should distinguish three situations:
|
||||
* <ol>
|
||||
* <li>Nullness of the value can be statically determined, the entity is definitely bound from either of:
|
||||
* <ul><li>the value <code>null</code>, or</li>
|
||||
* <li>an entity with a {@link Nullable @Nullable} type.</li></ul></li>
|
||||
* <li>Nullness cannot definitely be determined, because different code branches yield different results.</li>
|
||||
* <li>Nullness cannot be determined, because other program elements are involved for which
|
||||
* null annotations are lacking.</li>
|
||||
* </ol>
|
||||
* <p>
|
||||
* <b>Note:</b> Since org.eclipse.jdt.annotation 2.0.0, the
|
||||
* <code>@Target</code> is <code>{TYPE_USE}</code>. For the old API, see
|
||||
* <a href="http://help.eclipse.org/kepler/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/NonNull.html">
|
||||
* <code>@NonNull</code> in 1.1.0</a>.
|
||||
* </p>
|
||||
* @since 1.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ TYPE_USE })
|
||||
public @interface NonNull {
|
||||
// marker annotation with no members
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 2013 Stephan Herrmann and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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 explicitly includes the value <code>null</code>.
|
||||
* <p>
|
||||
* If annotation based null analysis is enabled using this annotation has two consequences:
|
||||
* </p>
|
||||
* <ol>
|
||||
* <li>Binding a <code>null</code> value to an entity (field, local variable, method parameter or method return value)
|
||||
* of this type is legal.</li>
|
||||
* <li>Dereferencing an expression of this type is unsafe, i.e., a <code>NullPointerException</code> can occur at runtime.</li>
|
||||
* </ol>
|
||||
* <p>
|
||||
* <b>Note:</b> Since org.eclipse.jdt.annotation 2.0.0, the
|
||||
* <code>@Target</code> is <code>{TYPE_USE}</code>. For the old API, see
|
||||
* <a href="http://help.eclipse.org/kepler/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/Nullable.html">
|
||||
* <code>@Nullable</code> in 1.1.0</a>.
|
||||
* </p>
|
||||
* @since 1.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ TYPE_USE })
|
||||
public @interface Nullable {
|
||||
// marker annotation with no members
|
||||
}
|
||||
Reference in New Issue
Block a user