diff --git a/ComponentCompiler/src/main/java/com/xiaojinzi/component/BaseProcessor.java b/ComponentCompiler/src/main/java/com/xiaojinzi/component/BaseProcessor.java index 73d1d87e..d9414724 100644 --- a/ComponentCompiler/src/main/java/com/xiaojinzi/component/BaseProcessor.java +++ b/ComponentCompiler/src/main/java/com/xiaojinzi/component/BaseProcessor.java @@ -122,11 +122,10 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) { mTypeNameString = TypeName.get(mTypeElementString.asType()); - // androidx 和 非 androidx 的两个注解 - mClassNameKeep = ClassName.get(mElements.getTypeElement(ComponentConstants.ANDROID_ANNOTATION_KEEP)); - mClassNameNonNull = ClassName.get(mElements.getTypeElement(ComponentConstants.ANDROID_ANNOTATION_NONNULL)); + TypeElement keepTypeElement = mElements.getTypeElement(ComponentConstants.ANDROID_ANNOTATION_KEEP); + TypeElement nonNullTypeElement = mElements.getTypeElement(ComponentConstants.ANDROID_ANNOTATION_NONNULL); - if (mClassNameKeep == null || mClassNameNonNull == null) { + if (keepTypeElement == null || nonNullTypeElement == null) { String addDependencyTip = getAddDependencyTip(Arrays.asList( ComponentConstants.ANDROID_ANNOTATION_KEEP, ComponentConstants.ANDROID_ANNOTATION_NONNULL @@ -136,6 +135,10 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) { "\n else see https://github.com/xiaojinzi123/Component/wiki/%E4%BE%9D%E8%B5%96%E5%92%8C%E9%85%8D%E7%BD%AE"); } + // androidx 和 非 androidx 的两个注解 + mClassNameKeep = ClassName.get(keepTypeElement); + mClassNameNonNull = ClassName.get(nonNullTypeElement); + } protected String getAddDependencyTip(List classPathList, boolean isOr) { diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterCenter.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterCenter.java index ce593972..bf4403b7 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterCenter.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterCenter.java @@ -412,7 +412,9 @@ public void unregister(@NonNull String host) { public IComponentHostRouter findUiRouter(String host) { try { if (Component.getConfig().isOptimizeInit()) { - return ASMUtil.findModuleRouterAsmImpl(host); + return ASMUtil.findModuleRouterAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { Class clazz = null; String className = ComponentUtil.genHostRouterClassName(host); diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterDegradeCenter.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterDegradeCenter.java index edfc8246..aba8124f 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterDegradeCenter.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/RouterDegradeCenter.java @@ -147,7 +147,9 @@ public void unregister(@NonNull String host) { public IComponentHostRouterDegrade findModuleRouterDegrade(String host) { try { if (Component.getConfig().isOptimizeInit()) { - return ASMUtil.findModuleRouterDegradeAsmImpl(host); + return ASMUtil.findModuleRouterDegradeAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { Class clazz = null; String className = ComponentUtil.genHostRouterDegradeClassName(host); diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/application/ModuleManager.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/application/ModuleManager.java index 134d3621..30cad081 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/application/ModuleManager.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/application/ModuleManager.java @@ -141,7 +141,9 @@ public static IComponentHostApplication findModuleApplication(@NonNull String ho IComponentHostApplication result = null; if (Component.getConfig().isOptimizeInit()) { LogUtil.log("\"" + host + "\" will try to load by bytecode"); - result = ASMUtil.findModuleApplicationAsmImpl(host); + result = ASMUtil.findModuleApplicationAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { LogUtil.log("\"" + host + "\" will try to load by reflection"); if (result == null) { diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/fragment/FragmentCenter.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/fragment/FragmentCenter.java index 15f0c37a..587d1592 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/fragment/FragmentCenter.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/fragment/FragmentCenter.java @@ -82,7 +82,9 @@ public void unregister(@NonNull String host) { public IComponentHostFragment findModuleService(String host) { try { if (Component.getConfig().isOptimizeInit()) { - return ASMUtil.findModuleFragmentAsmImpl(host); + return ASMUtil.findModuleFragmentAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { Class clazz = null; String className = ComponentUtil.genHostFragmentClassName(host); diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/interceptor/InterceptorCenter.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/interceptor/InterceptorCenter.java index b9213d38..a4b7cde5 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/interceptor/InterceptorCenter.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/interceptor/InterceptorCenter.java @@ -171,7 +171,9 @@ public IComponentHostInterceptor findModuleInterceptor(String host) { Utils.checkMainThread(); try { if (Component.getConfig().isOptimizeInit()) { - return ASMUtil.findModuleInterceptorAsmImpl(host); + return ASMUtil.findModuleInterceptorAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { Class clazz = null; String className = ComponentUtil.genHostInterceptorClassName(host); diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/service/ServiceCenter.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/service/ServiceCenter.java index 6d62814e..27c69a63 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/service/ServiceCenter.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/impl/service/ServiceCenter.java @@ -80,7 +80,9 @@ public void unregister(@NonNull String host) { public IComponentHostService findModuleService(@NonNull String host) { try { if (Component.getConfig().isOptimizeInit()) { - return ASMUtil.findModuleServiceAsmImpl(host); + return ASMUtil.findModuleServiceAsmImpl( + ComponentUtil.transformHostForClass(host) + ); } else { Class clazz = null; String className = ComponentUtil.genHostServiceClassName(host); diff --git a/ComponentImpl/src/main/java/com/xiaojinzi/component/support/ASMUtil.java b/ComponentImpl/src/main/java/com/xiaojinzi/component/support/ASMUtil.java index d8725147..adbeead0 100644 --- a/ComponentImpl/src/main/java/com/xiaojinzi/component/support/ASMUtil.java +++ b/ComponentImpl/src/main/java/com/xiaojinzi/component/support/ASMUtil.java @@ -87,7 +87,7 @@ public static List getModuleNames() { * @return 返回对应模块的 Application {@link IComponentHostApplication} */ @Nullable - public static IComponentHostApplication findModuleApplicationAsmImpl(String host) { + public static IComponentHostApplication findModuleApplicationAsmImpl(@NonNull String host) { return null; } @@ -98,7 +98,7 @@ public static IComponentHostApplication findModuleApplicationAsmImpl(String host * @return 返回对应模块的 Application {@link IComponentHostInterceptor} */ @Nullable - public static IComponentHostInterceptor findModuleInterceptorAsmImpl(String host) { + public static IComponentHostInterceptor findModuleInterceptorAsmImpl(@NonNull String host) { return null; } @@ -109,7 +109,7 @@ public static IComponentHostInterceptor findModuleInterceptorAsmImpl(String host * @return 返回对应模块的 {@link IComponentHostRouter} */ @Nullable - public static IComponentHostRouter findModuleRouterAsmImpl(String host) { + public static IComponentHostRouter findModuleRouterAsmImpl(@NonNull String host) { return null; } @@ -120,7 +120,7 @@ public static IComponentHostRouter findModuleRouterAsmImpl(String host) { * @return 返回对应模块的 {@link IComponentHostRouterDegrade} */ @Nullable - public static IComponentHostRouterDegrade findModuleRouterDegradeAsmImpl(String host) { + public static IComponentHostRouterDegrade findModuleRouterDegradeAsmImpl(@NonNull String host) { return null; } @@ -131,7 +131,7 @@ public static IComponentHostRouterDegrade findModuleRouterDegradeAsmImpl(String * @return 返回对应模块的 {@link IComponentHostService} */ @Nullable - public static IComponentHostService findModuleServiceAsmImpl(String host) { + public static IComponentHostService findModuleServiceAsmImpl(@NonNull String host) { return null; } @@ -142,7 +142,7 @@ public static IComponentHostService findModuleServiceAsmImpl(String host) { * @return 返回对应模块的 {@link IComponentHostFragment} */ @Nullable - public static IComponentHostFragment findModuleFragmentAsmImpl(String host) { + public static IComponentHostFragment findModuleFragmentAsmImpl(@NonNull String host) { return null; }