Created
July 7, 2014 17:54
-
-
Save gissuebot/f67240ddef8f556cab62 to your computer and use it in GitHub Desktop.
Migrated attachment for Guice issue 40, comment 3
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
# HG changeset patch | |
# User Dustin Sallings <dustin@spy.net> | |
# Date 1186625420 25200 | |
# Node ID ceba171c2ae135b92ca9fa0c57efb130fbbb23a7 | |
# Parent b1d246c11d0719217acc94f9b27fda3d7ab038ce | |
Cleaning up compiler warnings | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/Binder.java | |
--- a/src/com/google/inject/Binder.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/Binder.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -16,14 +16,15 @@ | |
package com.google.inject; | |
+import java.lang.annotation.Annotation; | |
+import java.lang.reflect.Method; | |
+ | |
+import org.aopalliance.intercept.MethodInterceptor; | |
+ | |
import com.google.inject.binder.AnnotatedBindingBuilder; | |
import com.google.inject.binder.AnnotatedConstantBindingBuilder; | |
import com.google.inject.binder.LinkedBindingBuilder; | |
import com.google.inject.matcher.Matcher; | |
-import com.google.inject.spi.Message; | |
-import java.lang.annotation.Annotation; | |
-import java.lang.reflect.Method; | |
-import org.aopalliance.intercept.MethodInterceptor; | |
/** | |
* Collects configuration information (primarily <i>bindings</i>) which will be | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/BinderImpl.java | |
--- a/src/com/google/inject/BinderImpl.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/BinderImpl.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -363,8 +363,12 @@ class BinderImpl implements Binder { | |
private static Set<Class<?>> FORBIDDEN_TYPES = forbiddenTypes(); | |
+ // generic array created for varargs param. | |
+ // The compiler seems to assume that a generic array of | |
+ // Class<? extends Object> is a bad idea. | |
+ @SuppressWarnings("unchecked") | |
private static Set<Class<?>> forbiddenTypes() { | |
- Set<Class<?>> set = new HashSet<Class<?>>(); | |
+ Set<Class<? extends Object>> set = new HashSet<Class<? extends Object>>(); | |
Collections.addAll(set, | |
// It's unfortunate that we have to maintain a blacklist of specific | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/BindingBuilderImpl.java | |
--- a/src/com/google/inject/BindingBuilderImpl.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/BindingBuilderImpl.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -323,9 +323,10 @@ class BindingBuilderImpl<T> implements A | |
public void notify(final InjectorImpl injector) { | |
injector.withDefaultSource(source, new Runnable() { | |
+ @SuppressWarnings("unchecked") // Generic cast | |
public void run() { | |
implicitFactory = injector.getImplicitBinding(null, | |
- (Class) key.getTypeLiteral().getRawType(), scope); | |
+ (Class<T>) key.getTypeLiteral().getRawType(), scope); | |
} | |
}); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/ConstructorInjector.java | |
--- a/src/com/google/inject/ConstructorInjector.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/ConstructorInjector.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -73,7 +73,7 @@ class ConstructorInjector<T> { | |
Constructor<T> found = null; | |
@SuppressWarnings("unchecked") | |
Constructor<T>[] constructors | |
- = (Constructor<T>[]) implementation.getDeclaredConstructors(); | |
+ = implementation.getDeclaredConstructors(); | |
for (Constructor<T> constructor : constructors) { | |
Inject inject = constructor.getAnnotation(Inject.class); | |
if (inject != null) { | |
@@ -174,6 +174,9 @@ class ConstructorInjector<T> { | |
Object construct(InternalContext context, Class<?> expectedType) { | |
throw new UnsupportedOperationException(); | |
} | |
+ // XXX: I don't really understand this. I assume it may be used | |
+ // via reflection. | |
+ @SuppressWarnings("unused") | |
public T get() { | |
throw new UnsupportedOperationException(); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/InjectorImpl.java | |
--- a/src/com/google/inject/InjectorImpl.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/InjectorImpl.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -195,14 +195,14 @@ class InjectorImpl implements Injector { | |
} | |
// Auto[un]box primitives. | |
- Class<?> primitiveCounterpart | |
- = PRIMITIVE_COUNTERPARTS.get(rawType); | |
+ @SuppressWarnings("unchecked") // generic cast | |
+ Class<T> primitiveCounterpart | |
+ = (Class<T>) PRIMITIVE_COUNTERPARTS.get(rawType); | |
if (primitiveCounterpart != null) { | |
- BindingImpl<?> counterpartBinding | |
+ BindingImpl<T> counterpartBinding | |
= getBinding(key.ofType(primitiveCounterpart)); | |
if (counterpartBinding != null) { | |
- return (InternalFactory<? extends T>) | |
- counterpartBinding.getInternalFactory(); | |
+ return counterpartBinding.getInternalFactory(); | |
} | |
} | |
@@ -222,6 +222,7 @@ class InjectorImpl implements Injector { | |
// their own converters. | |
// Do we need a primitive? | |
+ @SuppressWarnings("unchecked") // generic cast | |
Converter<T> converter = (Converter<T>) PRIMITIVE_CONVERTERS.get(rawType); | |
if (converter != null) { | |
try { | |
@@ -238,7 +239,9 @@ class InjectorImpl implements Injector { | |
if (Enum.class.isAssignableFrom(rawType)) { | |
T t; | |
try { | |
- t = (T) Enum.valueOf((Class) rawType, value); | |
+ @SuppressWarnings("unchecked") // lots of unsafe ops here | |
+ T tmp=(T) Enum.valueOf((Class)rawType, value); | |
+ t = tmp; | |
} | |
catch (IllegalArgumentException e) { | |
return handleConstantConversionError( | |
@@ -251,7 +254,10 @@ class InjectorImpl implements Injector { | |
if (rawType == Class.class) { | |
try { | |
// TODO: Make sure we use the right classloader. | |
- return new ConstantFactory<T>((T) Class.forName(value)); | |
+ @SuppressWarnings("unchecked") // generic cast | |
+ ConstantFactory<T> rv= | |
+ new ConstantFactory<T>((T) Class.forName(value)); | |
+ return rv; | |
} | |
catch (ClassNotFoundException e) { | |
return handleConstantConversionError( | |
@@ -261,7 +267,6 @@ class InjectorImpl implements Injector { | |
} | |
// Don't try to inject primitives, arrays, or enums. | |
- int modifiers = rawType.getModifiers(); | |
if (rawType.isArray() || rawType.isEnum() || rawType.isPrimitive()) { | |
// Look for a factory bound to a key without annotation attributes if | |
// necessary. | |
@@ -296,16 +301,26 @@ class InjectorImpl implements Injector { | |
}; | |
try { | |
// note: intelliJ thinks this cast is superfluous, but is it? | |
- return (InternalFactory<? extends T>) getImplicitBinding(member, | |
- rawType, null); | |
+ // XXX: rawType is defined as <? super T> while this is expecting | |
+ // <? extends T>. | |
+ @SuppressWarnings("unchecked") | |
+ InternalFactory<? extends T> rv= | |
+ (InternalFactory<? extends T>) getImplicitBinding( | |
+ member, rawType, null); | |
+ return rv; | |
} | |
finally { | |
this.errorHandler = previous; | |
} | |
} | |
// note: intelliJ thinks this cast is superfluous, but is it? | |
- return (InternalFactory<? extends T>) getImplicitBinding(member, rawType, | |
- null); | |
+ // XXX: rawType is defined as <? super T> while this is expecting | |
+ // <? extends T>. | |
+ @SuppressWarnings("unchecked") | |
+ InternalFactory<? extends T> rv= | |
+ (InternalFactory<? extends T>)getImplicitBinding( | |
+ member, rawType, null); | |
+ return rv; | |
} | |
private <T> InternalFactory<T> handleConstantConversionError( | |
@@ -337,7 +352,7 @@ class InjectorImpl implements Injector { | |
* Recursively adds injectors for fields and methods from the given class to | |
* the given list. Injects parent classes before sub classes. | |
*/ | |
- void addInjectors(Class clazz, List<SingleMemberInjector> injectors) { | |
+ void addInjectors(Class<?> clazz, List<SingleMemberInjector> injectors) { | |
if (clazz == Object.class) { | |
return; | |
} | |
@@ -586,9 +601,9 @@ class InjectorImpl implements Injector { | |
IllegalAccessException, InvocationTargetException; | |
} | |
+ @SuppressWarnings("unchecked") // untyped ConstructorInjector | |
final Map<Class<?>, ConstructorInjector> constructors | |
= new ReferenceCache<Class<?>, ConstructorInjector>() { | |
- @SuppressWarnings("unchecked") | |
protected ConstructorInjector<?> create(Class<?> implementation) { | |
if (implementation.isInterface()) { | |
errorHandler.handle(defaultSource, | |
@@ -601,7 +616,10 @@ class InjectorImpl implements Injector { | |
return ConstructorInjector.invalidConstructor(); | |
} | |
- return new ConstructorInjector(InjectorImpl.this, implementation); | |
+ @SuppressWarnings("unchecked") // untyped generic | |
+ ConstructorInjector<?> rv= | |
+ new ConstructorInjector(InjectorImpl.this, implementation); | |
+ return rv; | |
} | |
}; | |
@@ -664,7 +682,7 @@ class InjectorImpl implements Injector { | |
* values. | |
*/ | |
static Object[] getParameters(InternalContext context, | |
- SingleParameterInjector[] parameterInjectors) { | |
+ SingleParameterInjector<?>[] parameterInjectors) { | |
if (parameterInjectors == null) { | |
return null; | |
} | |
@@ -768,12 +786,12 @@ class InjectorImpl implements Injector { | |
/** | |
* Gets a constructor function for a given implementation class. | |
*/ | |
- @SuppressWarnings("unchecked") | |
+ @SuppressWarnings("unchecked") // untyped ConstructorInjector in the map | |
<T> ConstructorInjector<T> getConstructor(Class<T> implementation) { | |
return constructors.get(implementation); | |
} | |
- @SuppressWarnings("unchecked") | |
+ @SuppressWarnings("unchecked") // untyped ConstructorInjector in the map | |
<T> ConstructorInjector<T> getConstructor(TypeLiteral<T> implementation) { | |
return constructors.get(implementation.getRawType()); | |
} | |
@@ -906,14 +924,18 @@ class InjectorImpl implements Injector { | |
return invalidFactory(); | |
} | |
- return (InternalFactory<T>) getInternalFactory( | |
- member, Key.get(implementationType)); | |
+ @SuppressWarnings("unchecked") // generic cast | |
+ InternalFactory<T> rv=(InternalFactory<T>) getInternalFactory( | |
+ member, Key.get(implementationType)); | |
+ return rv; | |
} | |
// Look for @DefaultProvider. | |
ProvidedBy providedBy = type.getAnnotation(ProvidedBy.class); | |
if (providedBy != null) { | |
- final Class<? extends Provider<?>> providerType = providedBy.value(); | |
+ @SuppressWarnings("unchecked") // generic cast | |
+ final Class<? extends Provider<T>> providerType = | |
+ (Class<? extends Provider<T>>) providedBy.value(); | |
// Make sure it's not the same type. TODO: Can we check for deeper loops? | |
if (providerType == type) { | |
@@ -925,12 +947,12 @@ class InjectorImpl implements Injector { | |
// TODO: Make sure the provided type extends type. We at least check | |
// the type at runtime below. | |
- InternalFactory<? extends Provider<?>> providerFactory | |
+ InternalFactory<? extends Provider<T>> providerFactory | |
= getInternalFactory(member, Key.get(providerType)); | |
- Key<? extends Provider<?>> providerKey = Key.get(providerType); | |
- return (InternalFactory<T>) new BoundProviderFactory( | |
+ Key<? extends Provider<T>> providerKey = Key.get(providerType); | |
+ InternalFactory<T> rv=new BoundProviderFactory<T>( | |
providerKey, providerFactory, StackTraceElements.forType(type)) { | |
- public Object get(InternalContext context) { | |
+ public T get(InternalContext context) { | |
Object o = super.get(context); | |
try { | |
return type.cast(o); | |
@@ -941,6 +963,7 @@ class InjectorImpl implements Injector { | |
} | |
} | |
}; | |
+ return rv; | |
} | |
// TODO: Method interceptors could actually enable us to implement | |
@@ -1013,6 +1036,7 @@ class InjectorImpl implements Injector { | |
this.constructorInjector = constructorInjector; | |
} | |
+ @SuppressWarnings("unchecked") // generic cast | |
public T get(InternalContext context) { | |
return (T) constructorInjector.construct(context, | |
context.getExpectedType()); | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/Key.java | |
--- a/src/com/google/inject/Key.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/Key.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -293,8 +293,8 @@ public abstract class Key<T> { | |
* Returns a new key of the specified type with the same annotation as this | |
* key. | |
*/ | |
- <T> Key<T> ofType(Class<T> type) { | |
- return new SimpleKey<T>(type, annotationStrategy); | |
+ <KT> Key<KT> ofType(Class<KT> type) { | |
+ return new SimpleKey<KT>(type, annotationStrategy); | |
} | |
/** | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/ProviderMethods.java | |
--- a/src/com/google/inject/ProviderMethods.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/ProviderMethods.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -112,7 +112,8 @@ public class ProviderMethods { | |
}; | |
// TODO: Fix type warnings. | |
- Class type = method.getReturnType(); | |
+ @SuppressWarnings("unchecked") // generic cast | |
+ Class<Object> type = (Class<Object>) method.getReturnType(); | |
if (scopeAnnotation == null && bindingAnnotation == null) { | |
bind(type).toProvider(provider); | |
} else if (scopeAnnotation == null) { | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/ProviderMethodsTest.java | |
--- a/src/com/google/inject/ProviderMethodsTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/ProviderMethodsTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -43,7 +43,7 @@ public class ProviderMethodsTest extends | |
assertNotSame(bob, clone); | |
assertSame(bob.getDaughter(), clone.getDaughter()); | |
- Key soleBobKey = Key.get(Bob.class, Sole.class); | |
+ Key<Bob> soleBobKey = Key.get(Bob.class, Sole.class); | |
assertSame( | |
injector.getInstance(soleBobKey), | |
injector.getInstance(soleBobKey) | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/ProxyFactory.java | |
--- a/src/com/google/inject/ProxyFactory.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/ProxyFactory.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -164,7 +164,7 @@ class ProxyFactory implements Constructi | |
* Creates a construction proxy given a class and parameter types. | |
*/ | |
<T> ConstructionProxy<T> createConstructionProxy(Class<?> clazz, | |
- Class[] parameterTypes) { | |
+ Class<?>[] parameterTypes) { | |
FastClass fastClass = GuiceFastClass.create(clazz); | |
final FastConstructor fastConstructor | |
= fastClass.getConstructor(parameterTypes); | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/Scopes.java | |
--- a/src/com/google/inject/Scopes.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/Scopes.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -39,6 +39,7 @@ public class Scopes { | |
private volatile T instance; | |
// DCL on a volatile is safe as of Java 5, which we obviously require. | |
+ // Note that eclipse is unhappy with this suppression token. | |
@SuppressWarnings("DoubleCheckedLocking") | |
public T get() { | |
if (instance == null) { | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/FinalizableReferenceQueue.java | |
--- a/src/com/google/inject/internal/FinalizableReferenceQueue.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/FinalizableReferenceQueue.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -33,7 +33,7 @@ class FinalizableReferenceQueue extends | |
private FinalizableReferenceQueue() {} | |
- void cleanUp(Reference reference) { | |
+ void cleanUp(Reference<?> reference) { | |
try { | |
((FinalizableReference) reference).finalizeReferent(); | |
} catch (Throwable t) { | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/GuiceFastClass.java | |
--- a/src/com/google/inject/internal/GuiceFastClass.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/GuiceFastClass.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -25,11 +25,11 @@ import net.sf.cglib.reflect.FastClass; | |
*/ | |
public class GuiceFastClass { | |
- public static FastClass create(Class type) { | |
+ public static FastClass create(Class<?> type) { | |
return create(type.getClassLoader(), type); | |
} | |
- public static FastClass create(ClassLoader loader, Class type) { | |
+ public static FastClass create(ClassLoader loader, Class<?> type) { | |
FastClass.Generator generator = new FastClass.Generator(); | |
generator.setType(type); | |
generator.setClassLoader(loader); | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/LineNumbers.java | |
--- a/src/com/google/inject/internal/LineNumbers.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/LineNumbers.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -41,8 +41,8 @@ import org.objectweb.asm.Type; | |
*/ | |
public class LineNumbers { | |
- private final Class cls; | |
- private Map<String, Integer> lines = new HashMap<String, Integer>(); | |
+ private final Class<?> cls; | |
+ private final Map<String, Integer> lines = new HashMap<String, Integer>(); | |
private String source; | |
private int firstLine = Integer.MAX_VALUE; | |
@@ -54,7 +54,7 @@ public class LineNumbers { | |
* found | |
* @throws IOException if an error occurs while reading bytecode | |
*/ | |
- public LineNumbers(Class cls) throws IOException { | |
+ public LineNumbers(Class<?> cls) throws IOException { | |
this.cls = cls; | |
InputStream in = cls | |
.getResourceAsStream("/" + cls.getName().replace('.', '/') + ".class"); | |
@@ -105,15 +105,16 @@ public class LineNumbers { | |
return member.getName() + Type.getMethodDescriptor((Method) member); | |
} | |
else { | |
- return "<init>" + getConstructorDescriptor((Constructor) member); | |
- } | |
- } | |
- | |
- public static String getConstructorDescriptor(Constructor c) { | |
+ return "<init>" + getConstructorDescriptor((Constructor<?>) member); | |
+ } | |
+ } | |
+ | |
+ public static String getConstructorDescriptor(Constructor<?> c) { | |
StringBuilder sb = new StringBuilder(); | |
sb.append('('); | |
- for (Class param : c.getParameterTypes()) | |
- sb.append(Type.getDescriptor(param)); | |
+ for (Class<?> param : c.getParameterTypes()) { | |
+ sb.append(Type.getDescriptor(param)); | |
+ } | |
return sb.append(")V").toString(); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/ReferenceMap.java | |
--- a/src/com/google/inject/internal/ReferenceMap.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/ReferenceMap.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -517,7 +517,7 @@ public class ReferenceMap<K, V> implemen | |
return map.delegate.putIfAbsent(keyReference, valueReference); | |
} | |
}; | |
- }; | |
+ } | |
private static PutStrategy defaultPutStrategy; | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/StackTraceElements.java | |
--- a/src/com/google/inject/internal/StackTraceElements.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/StackTraceElements.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -48,7 +48,7 @@ public class StackTraceElements { | |
return SourceProviders.UNKNOWN_SOURCE; | |
} | |
- Class declaringClass = member.getDeclaringClass(); | |
+ Class<?> declaringClass = member.getDeclaringClass(); | |
LineNumbers lineNumbers = lineNumbersCache.get(declaringClass); | |
Integer lineNumber = lineNumbers.getLineNumber(member); | |
String memberName | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/internal/ToStringBuilder.java | |
--- a/src/com/google/inject/internal/ToStringBuilder.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/internal/ToStringBuilder.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -35,7 +35,7 @@ public class ToStringBuilder { | |
this.name = name; | |
} | |
- public ToStringBuilder(Class type) { | |
+ public ToStringBuilder(Class<?> type) { | |
this.name = type.getSimpleName(); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/matcher/Matchers.java | |
--- a/src/com/google/inject/matcher/Matchers.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/matcher/Matchers.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -119,10 +119,10 @@ public class Matchers { | |
* Returns a matcher which matches subclasses of the given type (as well as | |
* the given type). | |
*/ | |
- public static Matcher<Class> subclassesOf(final Class<?> superclass) { | |
+ public static Matcher<Class<?>> subclassesOf(final Class<?> superclass) { | |
Objects.nonNull(superclass, "superclass"); | |
- return new AbstractMatcher<Class>() { | |
- public boolean matches(Class subclass) { | |
+ return new AbstractMatcher<Class<?>>() { | |
+ public boolean matches(Class<?> subclass) { | |
return superclass.isAssignableFrom(subclass); | |
} | |
@@ -167,10 +167,10 @@ public class Matchers { | |
/** | |
* Returns a matcher which matches classes in the given package. | |
*/ | |
- public static Matcher<Class> inPackage(final Package p) { | |
+ public static Matcher<Class<?>> inPackage(final Package p) { | |
Objects.nonNull(p, "package"); | |
- return new AbstractMatcher<Class>() { | |
- public boolean matches(Class c) { | |
+ return new AbstractMatcher<Class<?>>() { | |
+ public boolean matches(Class<?> c) { | |
return c.getPackage().equals(p); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 src/com/google/inject/tools/jmx/ManagedBinding.java | |
--- a/src/com/google/inject/tools/jmx/ManagedBinding.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/src/com/google/inject/tools/jmx/ManagedBinding.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -20,9 +20,9 @@ import com.google.inject.Binding; | |
class ManagedBinding implements ManagedBindingMBean { | |
- final Binding binding; | |
+ final Binding<?> binding; | |
- ManagedBinding(Binding binding) { | |
+ ManagedBinding(Binding<?> binding) { | |
this.binding = binding; | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/BinderTest.java | |
--- a/test/com/google/inject/BinderTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/BinderTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -25,6 +25,7 @@ public class BinderTest extends TestCase | |
Provider<Foo> fooProvider; | |
+ @SuppressWarnings("cast") // asserting foo's provider returns a foo. | |
public void testProviderFromBinder() { | |
Guice.createInjector(new Module() { | |
public void configure(Binder binder) { | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/BoundInstanceInjectionTest.java | |
--- a/test/com/google/inject/BoundInstanceInjectionTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/BoundInstanceInjectionTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -26,7 +26,7 @@ public class BoundInstanceInjectionTest | |
public void testInstancesAreInjected() throws CreationException { | |
final O o = new O(); | |
- Injector injector = Guice.createInjector(new AbstractModule() { | |
+ Guice.createInjector(new AbstractModule() { | |
protected void configure() { | |
bind(O.class).toInstance(o); | |
bind(int.class).toInstance(5); | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/ConstantConversionTest.java | |
--- a/test/com/google/inject/ConstantConversionTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/ConstantConversionTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -153,6 +153,7 @@ public class ConstantConversionTest exte | |
BinderImpl b = new BinderImpl(); | |
b.bind(String.class).toInstance("5"); | |
b.bind(LongHolder.class); | |
+ @SuppressWarnings("unused") // I don't see what this test does. | |
Injector c = b.createInjector(); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/ErrorHandlingTest.java | |
--- a/test/com/google/inject/ErrorHandlingTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/ErrorHandlingTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -124,6 +124,7 @@ public class ErrorHandlingTest { | |
bind(TooManyScopes.class); | |
bindScope(BadScope.class, Scopes.SINGLETON); | |
bind(Object.class).toInstance(new Object() { | |
+ @SuppressWarnings("unused") | |
@Inject void foo() { | |
throw new RuntimeException(); | |
} | |
@@ -134,6 +135,7 @@ public class ErrorHandlingTest { | |
Object o = "2"; | |
try { | |
+ @SuppressWarnings("unused") // Not sure why this is here. | |
Integer i = (Integer) o; | |
} catch (Exception e) { | |
addError(e); | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/InjectorTest.java | |
--- a/test/com/google/inject/InjectorTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/InjectorTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -207,11 +207,13 @@ public class InjectorTest extends TestCa | |
String fromConstructor; | |
int fromMethod; | |
+ @SuppressWarnings("unused") | |
@Inject | |
private Private(String fromConstructor) { | |
this.fromConstructor = fromConstructor; | |
} | |
+ @SuppressWarnings("unused") | |
@Inject | |
private void setInt(int i) { | |
this.fromMethod = i; | |
@@ -250,6 +252,7 @@ public class InjectorTest extends TestCa | |
Guice.createInjector(new AbstractModule() { | |
protected void configure() { | |
bind(Object.class).toInstance(new Object() { | |
+ @SuppressWarnings("unused") | |
@Inject Runnable r; | |
}); | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/ScopesTest.java | |
--- a/test/com/google/inject/ScopesTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/ScopesTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -25,6 +25,7 @@ public class ScopesTest extends TestCase | |
public void testSingletonAnnotation() throws CreationException { | |
BinderImpl binder = new BinderImpl(); | |
+ @SuppressWarnings("unused") | |
BindingBuilderImpl<SampleSingleton> bindingBuilder | |
= binder.bind(SampleSingleton.class); | |
Injector injector = binder.createInjector(); | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/StaticInjectionTest.java | |
--- a/test/com/google/inject/StaticInjectionTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/StaticInjectionTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -37,6 +37,7 @@ public class StaticInjectionTest extends | |
builder.bindConstant().annotatedWith(I.class).to(5); | |
builder.requestStaticInjection(StaticInjectionTest.Static.class); | |
+ @SuppressWarnings("unused") | |
Injector c = builder.createInjector(); | |
assertEquals("test", StaticInjectionTest.Static.s); | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/TypeLiteralTest.java | |
--- a/test/com/google/inject/TypeLiteralTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/TypeLiteralTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -50,6 +50,7 @@ public class TypeLiteralTest extends Tes | |
assertEquals(t4, t5); | |
} | |
+ @SuppressWarnings("unchecked") // TypeLiteral anonymous class is never used | |
public void testMissingTypeParameter() { | |
try { | |
new TypeLiteral() {}; | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/example/ClientServiceWithGuice.java | |
--- a/test/com/google/inject/example/ClientServiceWithGuice.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/example/ClientServiceWithGuice.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -84,6 +84,7 @@ public static void main(String[] args) t | |
public static void main(String[] args) throws CreationException { | |
new ClientServiceWithGuice().testClient(); | |
Injector injector = Guice.createInjector(new MyModule()); | |
+ @SuppressWarnings("unused") | |
Client client = injector.getInstance(Client.class); | |
} | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/example/ClientServiceWithGuiceDefaults.java | |
--- a/test/com/google/inject/example/ClientServiceWithGuiceDefaults.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/example/ClientServiceWithGuiceDefaults.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -80,6 +80,7 @@ public static void main(String[] args) t | |
public static void main(String[] args) throws CreationException { | |
new ClientServiceWithGuiceDefaults().testClient(); | |
Injector injector = Guice.createInjector(); | |
+ @SuppressWarnings("unused") | |
Client client = injector.getProvider(Client.class).get(); | |
} | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/example/JndiProviderClient.java | |
--- a/test/com/google/inject/example/JndiProviderClient.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/example/JndiProviderClient.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -28,6 +28,7 @@ class JndiProviderClient { | |
class JndiProviderClient { | |
public static void main(String[] args) throws CreationException { | |
+ @SuppressWarnings("unused") | |
Injector injector = Guice.createInjector(new AbstractModule() { | |
protected void configure() { | |
// Bind Context to the default InitialContext. | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/internal/ReferenceCacheTest.java | |
--- a/test/com/google/inject/internal/ReferenceCacheTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/internal/ReferenceCacheTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -30,7 +30,7 @@ public class ReferenceCacheTest extends | |
public void testRuntimeException() { | |
class CreationException extends RuntimeException {} | |
try { | |
- new ReferenceCache() { | |
+ new ReferenceCache<Object, Object>() { | |
protected Object create(Object key) { | |
throw new CreationException(); | |
} | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/internal/ReferenceMapTest.java | |
--- a/test/com/google/inject/internal/ReferenceMapTest.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/internal/ReferenceMapTest.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -92,6 +92,10 @@ public class ReferenceMapTest extends Te | |
reference.enqueue(); | |
break; | |
} | |
+ case GC: | |
+ // XXX: Note that this wasn't here before warning cleanup. I added it | |
+ // to the switch so it'd be happier, but it doesnt do anything. | |
+ break; | |
} | |
// wait up to 5s | |
diff -r b1d246c11d07 -r ceba171c2ae1 test/com/google/inject/internal/ReferenceMapTestSuite.java | |
--- a/test/com/google/inject/internal/ReferenceMapTestSuite.java Wed Aug 08 19:07:56 2007 -0700 | |
+++ b/test/com/google/inject/internal/ReferenceMapTestSuite.java Wed Aug 08 19:10:20 2007 -0700 | |
@@ -239,6 +239,7 @@ public class ReferenceMapTestSuite { | |
assertEquals(3, map.count); | |
} | |
+ // Note: eclipse doesn't like this suppression token | |
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") | |
public Object serializeAndDeserialize(Object o) throws IOException, | |
ClassNotFoundException { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment