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
This commit is contained in:
Shay Banon 2013-03-18 01:33:09 +01:00
parent e347a626da
commit 82072fc47f
5 changed files with 7 additions and 7 deletions

View File

@ -506,6 +506,6 @@ public class Key<T> {
static boolean isBindingAnnotation( static boolean isBindingAnnotation(
Class<? extends Annotation> annotationType) { Class<? extends Annotation> annotationType) {
return annotationType.isAnnotationPresent(BindingAnnotation.class); return annotationType.getAnnotation(BindingAnnotation.class) != null;
} }
} }

View File

@ -56,7 +56,7 @@ public class Annotations {
Class<? extends Annotation> found = null; Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) { for (Annotation annotation : annotations) {
if (annotation.annotationType().isAnnotationPresent(ScopeAnnotation.class)) { if (annotation.annotationType().getAnnotation(ScopeAnnotation.class) != null) {
if (found != null) { if (found != null) {
errors.duplicateScopeAnnotations(found, annotation.annotationType()); errors.duplicateScopeAnnotations(found, annotation.annotationType());
} else { } else {
@ -69,7 +69,7 @@ public class Annotations {
} }
public static boolean isScopeAnnotation(Class<? extends Annotation> annotationType) { public static boolean isScopeAnnotation(Class<? extends Annotation> annotationType) {
return annotationType.isAnnotationPresent(ScopeAnnotation.class); return annotationType.getAnnotation(ScopeAnnotation.class) != null;
} }
/** /**
@ -107,7 +107,7 @@ public class Annotations {
Annotation found = null; Annotation found = null;
for (Annotation annotation : annotations) { for (Annotation annotation : annotations) {
if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) { if (annotation.annotationType().getAnnotation(BindingAnnotation.class) != null) {
if (found != null) { if (found != null) {
errors.duplicateBindingAnnotations(member, errors.duplicateBindingAnnotations(member,
found.annotationType(), annotation.annotationType()); found.annotationType(), annotation.annotationType());

View File

@ -53,7 +53,7 @@ public class ProviderMethod<T> implements ProviderWithDependencies<T> {
this.dependencies = dependencies; this.dependencies = dependencies;
this.method = method; this.method = method;
this.parameterProviders = parameterProviders; this.parameterProviders = parameterProviders;
this.exposed = method.isAnnotationPresent(Exposed.class); this.exposed = method.getAnnotation(Exposed.class) != null;
method.setAccessible(true); method.setAccessible(true);
} }

View File

@ -76,7 +76,7 @@ public final class ProviderMethodsModule implements Module {
List<ProviderMethod<?>> result = Lists.newArrayList(); List<ProviderMethod<?>> result = Lists.newArrayList();
for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) { for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
for (Method method : c.getDeclaredMethods()) { for (Method method : c.getDeclaredMethods()) {
if (method.isAnnotationPresent(Provides.class)) { if (method.getAnnotation(Provides.class) != null) {
result.add(createProviderMethod(binder, method)); result.add(createProviderMethod(binder, method));
} }
} }

View File

@ -71,6 +71,6 @@ public abstract class DefaultBindingTargetVisitor<T, V> implements BindingTarget
// javac says it's an error to cast ProviderBinding<? extends T> to Binding<? extends T> // javac says it's an error to cast ProviderBinding<? extends T> to Binding<? extends T>
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public V visit(ProviderBinding<? extends T> providerBinding) { public V visit(ProviderBinding<? extends T> providerBinding) {
return visitOther((Binding) providerBinding); return visitOther((Binding<? extends T>) providerBinding);
} }
} }