Nullable: Switch to TYPE_USE
Since JGit now requires Java 8, we can switch to TYPE_USE instead
of explicitly specifying the target type.
Some of the existing uses of Nullable need to be reworked slightly
as described in [1] to prevent the compilation error:
scoping construct cannot be annotated with type-use annotation
[1] https://stackoverflow.com/a/21385939/381622
Change-Id: Idba48f67a09353b5237685996ce828c8ca398168
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
index cfa53af..75bd549 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
@@ -82,7 +82,7 @@
* @return Action for verifying the object, or {@code null} if the server
* doesn't support or require verification
*/
- public @Nullable Response.Action getVerifyAction(AnyLongObjectId id);
+ public Response.@Nullable Action getVerifyAction(AnyLongObjectId id);
/**
* Get size of an object
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/annotations/Nullable.java b/org.eclipse.jgit/src/org/eclipse/jgit/annotations/Nullable.java
index f8a7a36..e914140 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/annotations/Nullable.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/annotations/Nullable.java
@@ -43,12 +43,8 @@
package org.eclipse.jgit.annotations;
-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.PARAMETER;
-
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;
@@ -93,7 +89,7 @@
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
-@Target({ FIELD, METHOD, PARAMETER, LOCAL_VARIABLE })
+@Target(ElementType.TYPE_USE)
public @interface Nullable {
// marker annotation with no members
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
index 4b503a3..314c4e6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
@@ -140,8 +140,7 @@
* @return error condition or null.
* @since 4.2
*/
- @Nullable
- public ObjectChecker.ErrorType getErrorType() {
+ public ObjectChecker.@Nullable ErrorType getErrorType() {
return errorType;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java
index 131b004..3c6f38e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java
@@ -89,8 +89,7 @@
}
/** @return error type of the corruption. */
- @Nullable
- public ObjectChecker.ErrorType getErrorType() {
+ public ObjectChecker.@Nullable ErrorType getErrorType() {
return errorType;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
index 4c70725..cd03a3d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
@@ -265,8 +265,7 @@
}
}
- @Nullable
- static ObjectChecker.ErrorType parse(String key) {
+ static ObjectChecker.@Nullable ErrorType parse(String key) {
return errors.get(toLowerCase(key));
}