Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for AndroidX annotations.
- Loading branch information
Showing
10 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spotbugsTestCases/src/fakeAnnotations/androidx/annotation/NonNull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2013 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package androidx.annotation; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.LOCAL_VARIABLE; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PACKAGE; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Denotes that a parameter, field or method return value can never be null. | ||
* <p> | ||
* This is a marker annotation and it has no specific attributes. | ||
*/ | ||
@Documented | ||
@Retention(CLASS) | ||
@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE}) | ||
public @interface NonNull { | ||
} |
46 changes: 46 additions & 0 deletions
46
spotbugsTestCases/src/fakeAnnotations/androidx/annotation/Nullable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2013 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package androidx.annotation; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.LOCAL_VARIABLE; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PACKAGE; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Denotes that a parameter, field or method return value can be null. | ||
* <p> | ||
* When decorating a method call parameter, this denotes that the parameter can | ||
* legitimately be null and the method will gracefully deal with it. Typically | ||
* used on optional parameters. | ||
* <p> | ||
* When decorating a method, this denotes the method might legitimately return | ||
* null. | ||
* <p> | ||
* This is a marker annotation and it has no specific attributes. | ||
*/ | ||
@Documented | ||
@Retention(CLASS) | ||
@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE}) | ||
public @interface Nullable { | ||
} |
17 changes: 17 additions & 0 deletions
17
spotbugsTestCases/src/java/androidAnnotations/CheckedNullableReturn2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package androidAnnotations; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
public class CheckedNullableReturn2 { | ||
@Nullable | ||
String foo() { | ||
return null; | ||
} | ||
|
||
void bar() { | ||
String foo = foo(); | ||
if (foo != null) { | ||
System.out.println(foo.hashCode()); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
spotbugsTestCases/src/java/androidAnnotations/NullForNonNullParam2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package androidAnnotations; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class NullForNonNullParam2 { | ||
static void foo(@NonNull Object o) { | ||
} | ||
|
||
static void bar() { | ||
foo(null); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
spotbugsTestCases/src/java/androidAnnotations/ObjectForNonNullParam2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package androidAnnotations; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class ObjectForNonNullParam2 { | ||
static void foo(@NonNull Object o) { | ||
} | ||
|
||
static void bar() { | ||
foo(new Object()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
spotbugsTestCases/src/java/androidAnnotations/UncheckedNullableReturn2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package androidAnnotations; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
public class UncheckedNullableReturn2 { | ||
@Nullable | ||
String foo() { | ||
return null; | ||
} | ||
|
||
void bar() { | ||
System.out.println(foo().hashCode()); | ||
} | ||
} |