diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java index 746a3347f..9f59fef1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java @@ -78,7 +78,17 @@ public class JavaModuleWrapper { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "findMethods"); Set methodNames = new HashSet<>(); - Method[] targetMethods = mModuleClass.getDeclaredMethods(); + Class classForMethods = mModuleClass; + Class superClass = + (Class) mModuleClass.getSuperclass(); + if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) { + // For java module that is based on generated flow-type spec, inspect the + // spec abstract class instead, which is the super class of the given java + // module. + classForMethods = superClass; + } + Method[] targetMethods = classForMethods.getDeclaredMethods(); + for (Method targetMethod : targetMethods) { ReactMethod annotation = targetMethod.getAnnotation(ReactMethod.class); if (annotation != null) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java new file mode 100644 index 000000000..b0af8b485 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package com.facebook.react.bridge; + +import com.facebook.proguard.annotations.DoNotStrip; + +/** + * An interface to be implemented by react modules that extends from the + * generated spec class. + * This is experimental. + */ +@DoNotStrip +public interface ReactModuleWithSpec { +}