Skip to content

Commit 3d3f74d

Browse files
fkgozalifacebook-github-bot
authored andcommitted
move @ReactMethod to the codegen'ed class so impl class don't need it anymore
Reviewed By: javache Differential Revision: D5074121 fbshipit-source-id: 1b23a5d26ffe27c5093677ae7ecca424b232c8aa
1 parent 0040b02 commit 3d3f74d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,17 @@ private void findMethods() {
7878
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "findMethods");
7979
Set<String> methodNames = new HashSet<>();
8080

81-
Method[] targetMethods = mModuleClass.getDeclaredMethods();
81+
Class<? extends NativeModule> classForMethods = mModuleClass;
82+
Class<? extends NativeModule> superClass =
83+
(Class<? extends NativeModule>) mModuleClass.getSuperclass();
84+
if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) {
85+
// For java module that is based on generated flow-type spec, inspect the
86+
// spec abstract class instead, which is the super class of the given java
87+
// module.
88+
classForMethods = superClass;
89+
}
90+
Method[] targetMethods = classForMethods.getDeclaredMethods();
91+
8292
for (Method targetMethod : targetMethods) {
8393
ReactMethod annotation = targetMethod.getAnnotation(ReactMethod.class);
8494
if (annotation != null) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
package com.facebook.react.bridge;
11+
12+
import com.facebook.proguard.annotations.DoNotStrip;
13+
14+
/**
15+
* An interface to be implemented by react modules that extends from the
16+
* generated spec class.
17+
* This is experimental.
18+
*/
19+
@DoNotStrip
20+
public interface ReactModuleWithSpec {
21+
}

0 commit comments

Comments
 (0)