From 8e217517e2c515032dd0d661535d2133cd80123a Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jan 2018 13:35:44 +0900 Subject: [PATCH] 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 --- .../org/eclipse/jgit/lfs/server/LargeFileRepository.java | 2 +- .../src/org/eclipse/jgit/annotations/Nullable.java | 8 ++------ .../org/eclipse/jgit/errors/CorruptObjectException.java | 3 +-- .../src/org/eclipse/jgit/internal/fsck/FsckError.java | 3 +-- .../src/org/eclipse/jgit/transport/TransferConfig.java | 3 +-- 5 files changed, 6 insertions(+), 13 deletions(-) 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 cfa53af9cd..75bd549dda 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 @@ public interface LargeFileRepository { * @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 f8a7a366d4..e914140ce4 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 @@ import java.lang.annotation.Target; */ @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 4b503a302d..314c4e6dae 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 @@ public class CorruptObjectException extends IOException { * @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 131b0048ae..3c6f38efb0 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 @@ public class FsckError { } /** @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 4c70725e42..cd03a3d924 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 @@ public class TransferConfig { } } - @Nullable - static ObjectChecker.ErrorType parse(String key) { + static ObjectChecker.@Nullable ErrorType parse(String key) { return errors.get(toLowerCase(key)); } -- 2.39.5