From 82072fc47fd37b9c1fff457b66f2112d88e4a396 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 18 Mar 2013 01:33:09 +0100 Subject: [PATCH] make ES compile with java 8 - that isAnnotationPresent bug is known, and probably will be fixed in later versions, but it costs us nothing to not use it now - some tests fail, mainly due to consistent ordering expected from Map (within versions) which does not seem to be preserved, need to fix those tests to be agnostic to it --- src/main/java/org/elasticsearch/common/inject/Key.java | 2 +- .../elasticsearch/common/inject/internal/Annotations.java | 6 +++--- .../common/inject/internal/ProviderMethod.java | 2 +- .../common/inject/internal/ProviderMethodsModule.java | 2 +- .../common/inject/spi/DefaultBindingTargetVisitor.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/elasticsearch/common/inject/Key.java b/src/main/java/org/elasticsearch/common/inject/Key.java index e8ee244fbc4..f92ff7ec991 100644 --- a/src/main/java/org/elasticsearch/common/inject/Key.java +++ b/src/main/java/org/elasticsearch/common/inject/Key.java @@ -506,6 +506,6 @@ public class Key { static boolean isBindingAnnotation( Class annotationType) { - return annotationType.isAnnotationPresent(BindingAnnotation.class); + return annotationType.getAnnotation(BindingAnnotation.class) != null; } } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Annotations.java b/src/main/java/org/elasticsearch/common/inject/internal/Annotations.java index 0910c827d34..91a889e85aa 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Annotations.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Annotations.java @@ -56,7 +56,7 @@ public class Annotations { Class found = null; for (Annotation annotation : annotations) { - if (annotation.annotationType().isAnnotationPresent(ScopeAnnotation.class)) { + if (annotation.annotationType().getAnnotation(ScopeAnnotation.class) != null) { if (found != null) { errors.duplicateScopeAnnotations(found, annotation.annotationType()); } else { @@ -69,7 +69,7 @@ public class Annotations { } public static boolean isScopeAnnotation(Class annotationType) { - return annotationType.isAnnotationPresent(ScopeAnnotation.class); + return annotationType.getAnnotation(ScopeAnnotation.class) != null; } /** @@ -107,7 +107,7 @@ public class Annotations { Annotation found = null; for (Annotation annotation : annotations) { - if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) { + if (annotation.annotationType().getAnnotation(BindingAnnotation.class) != null) { if (found != null) { errors.duplicateBindingAnnotations(member, found.annotationType(), annotation.annotationType()); diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java index 603a42aa2da..590ccd9d68b 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java @@ -53,7 +53,7 @@ public class ProviderMethod implements ProviderWithDependencies { this.dependencies = dependencies; this.method = method; this.parameterProviders = parameterProviders; - this.exposed = method.isAnnotationPresent(Exposed.class); + this.exposed = method.getAnnotation(Exposed.class) != null; method.setAccessible(true); } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java index 9192e577a72..6c29361d90f 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java @@ -76,7 +76,7 @@ public final class ProviderMethodsModule implements Module { List> result = Lists.newArrayList(); for (Class c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) { for (Method method : c.getDeclaredMethods()) { - if (method.isAnnotationPresent(Provides.class)) { + if (method.getAnnotation(Provides.class) != null) { result.add(createProviderMethod(binder, method)); } } diff --git a/src/main/java/org/elasticsearch/common/inject/spi/DefaultBindingTargetVisitor.java b/src/main/java/org/elasticsearch/common/inject/spi/DefaultBindingTargetVisitor.java index c7f69ae9d03..d730357b076 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/DefaultBindingTargetVisitor.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/DefaultBindingTargetVisitor.java @@ -71,6 +71,6 @@ public abstract class DefaultBindingTargetVisitor implements BindingTarget // javac says it's an error to cast ProviderBinding to Binding @SuppressWarnings("unchecked") public V visit(ProviderBinding providerBinding) { - return visitOther((Binding) providerBinding); + return visitOther((Binding) providerBinding); } }