From 525cb97df2458da90a4ff99c917b098c7c8b1db9 Mon Sep 17 00:00:00 2001 From: Christian Edward Gruber Date: Fri, 28 Jun 2013 09:33:41 -0700 Subject: [PATCH] Add some javadocs, plus more precisely narrow where an exception is caught. --- .../main/java/dagger/internal/FailoverLoader.java | 7 ++++--- .../dagger/internal/loaders/GeneratedAdapters.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/dagger/internal/FailoverLoader.java b/core/src/main/java/dagger/internal/FailoverLoader.java index 877fb0d2002..48b3e38eee0 100644 --- a/core/src/main/java/dagger/internal/FailoverLoader.java +++ b/core/src/main/java/dagger/internal/FailoverLoader.java @@ -32,13 +32,14 @@ public final class FailoverLoader implements Loader { * Obtains a module adapter for {@code module} from the first responding resolver. */ @Override public ModuleAdapter getModuleAdapter(Class type, T instance) { + ModuleAdapter result = null; try { - ModuleAdapter result = GeneratedAdapters.initModuleAdapter(type); - result.module = (instance != null) ? instance : result.newModule(); - return result; + result = GeneratedAdapters.initModuleAdapter(type); } catch (ClassNotFoundException e) { throw new TypeNotPresentException(type + GeneratedAdapters.MODULE_ADAPTER_SUFFIX, e); } + result.module = (instance != null) ? instance : result.newModule(); + return result; } @Override public Binding getAtInjectBinding(String key, String className, diff --git a/core/src/main/java/dagger/internal/loaders/GeneratedAdapters.java b/core/src/main/java/dagger/internal/loaders/GeneratedAdapters.java index 0907ad0cc34..6ef7445f0be 100644 --- a/core/src/main/java/dagger/internal/loaders/GeneratedAdapters.java +++ b/core/src/main/java/dagger/internal/loaders/GeneratedAdapters.java @@ -35,16 +35,28 @@ public final class GeneratedAdapters { private GeneratedAdapters() { } + /** + * Attempts to load an adapter named from the provided type plus a constant suffix + * {@link #MODULE_ADAPTER_SUFFIX}, or throws a ClassNotFoundException. + */ public static ModuleAdapter initModuleAdapter(Class moduleClass) throws ClassNotFoundException { return instantiate(moduleClass.getName() + MODULE_ADAPTER_SUFFIX, moduleClass.getClassLoader()); } + /** + * Attempts to load an adapter named from the provided class name plus a constant suffix + * {@link #INJECT_ADAPTER_SUFFIX}, or throws a ClassNotFoundException. + */ public static Binding initInjectAdapter(String className, ClassLoader classLoader) throws ClassNotFoundException { return instantiate(className + INJECT_ADAPTER_SUFFIX, classLoader); } + /** + * Attempts to load an adapter named from the provided type plus a constant suffix + * {@link #STATIC_INJECTION_SUFFIX}, or throws a ClassNotFoundException. + */ public static StaticInjection initStaticInjection(Class injectedClass) throws ClassNotFoundException { return instantiate(injectedClass.getName() + STATIC_INJECTION_SUFFIX,