diff options
Diffstat (limited to 'java/dagger/hilt/EntryPoints.java')
-rw-r--r-- | java/dagger/hilt/EntryPoints.java | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/java/dagger/hilt/EntryPoints.java b/java/dagger/hilt/EntryPoints.java index 3db77f903..32e231212 100644 --- a/java/dagger/hilt/EntryPoints.java +++ b/java/dagger/hilt/EntryPoints.java @@ -18,14 +18,10 @@ package dagger.hilt; import dagger.hilt.internal.GeneratedComponent; import dagger.hilt.internal.GeneratedComponentManager; -import dagger.hilt.internal.Preconditions; -import dagger.hilt.internal.TestSingletonComponent; -import java.lang.annotation.Annotation; import javax.annotation.Nonnull; /** Static utility methods for accessing objects through entry points. */ public final class EntryPoints { - private static final String EARLY_ENTRY_POINT = "dagger.hilt.android.EarlyEntryPoint"; /** * Returns the entry point interface given a component or component manager. Note that this @@ -43,20 +39,11 @@ public final class EntryPoints { @Nonnull public static <T> T get(Object component, Class<T> entryPoint) { if (component instanceof GeneratedComponent) { - if (component instanceof TestSingletonComponent) { - // @EarlyEntryPoint only has an effect in test environment, so we shouldn't fail in - // non-test cases. In addition, some of the validation requires the use of reflection, which - // we don't want to do in non-test cases anyway. - Preconditions.checkState( - !hasAnnotationReflection(entryPoint, EARLY_ENTRY_POINT), - "Interface, %s, annotated with @EarlyEntryPoint should be called with " - + "EarlyEntryPoints.get() rather than EntryPoints.get()", - entryPoint.getCanonicalName()); - } // Unsafe cast. There is no way for this method to know that the correct component was used. return entryPoint.cast(component); } else if (component instanceof GeneratedComponentManager) { - return get(((GeneratedComponentManager<?>) component).generatedComponent(), entryPoint); + // Unsafe cast. There is no way for this method to know that the correct component was used. + return entryPoint.cast(((GeneratedComponentManager<?>) component).generatedComponent()); } else { throw new IllegalStateException( String.format( @@ -65,15 +52,5 @@ public final class EntryPoints { } } - // Note: This method uses reflection but it should only be called in test environments. - private static boolean hasAnnotationReflection(Class<?> clazz, String annotationName) { - for (Annotation annotation : clazz.getAnnotations()) { - if (annotation.annotationType().getCanonicalName().contentEquals(annotationName)) { - return true; - } - } - return false; - } - private EntryPoints() {} } |