Skip to content

Commit

Permalink
Make ReactModuleSpecProcessor print stacktrace when typeElement.getAn…
Browse files Browse the repository at this point in the history
…notation fails

Summary:
WHen porting TurboModules or adding new TurboModules, ReactModuleSpecProcessor may fail during buck build, and when the failure is caused by typeElement.getAnnotation, no useful information gets collected, making it difficult to debug.
So here I am adding a try & catch so we can get useful debugging info.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D35767207

fbshipit-source-id: 7e1f9dfbfd31339ab37af19c51d85085e100955a
  • Loading branch information
Alex Liang authored and facebook-github-bot committed Apr 22, 2022
1 parent ffaa5d6 commit 7454044
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ rn_java_library(
source = "8",
target = "8",
deps = [
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_target("java/com/facebook/react/common:common"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/javapoet:javapoet"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.tools.Diagnostic.Kind.ERROR;

import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.SuppressFieldNotInitialized;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfo;
Expand Down Expand Up @@ -87,7 +89,15 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}

TypeElement typeElement = (TypeElement) reactModuleListElement;
ReactModuleList reactModuleList = typeElement.getAnnotation(ReactModuleList.class);

ReactModuleList reactModuleList = null;
try {
reactModuleList = typeElement.getAnnotation(ReactModuleList.class);
} catch (Exception ex) {
FLog.i(
ReactConstants.TAG, "Could not reactModuleList from typeElement.getAnnotation()", ex);
throw ex;
}

if (reactModuleList == null) {
continue;
Expand Down

0 comments on commit 7454044

Please sign in to comment.