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
This commit is contained in:
Kevin Gozali 2017-05-22 11:43:15 -07:00 committed by Facebook Github Bot
parent 0040b02469
commit 3d3f74dc72
2 changed files with 32 additions and 1 deletions

View File

@ -78,7 +78,17 @@ public class JavaModuleWrapper {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "findMethods");
Set<String> methodNames = new HashSet<>();
Method[] targetMethods = mModuleClass.getDeclaredMethods();
Class<? extends NativeModule> classForMethods = mModuleClass;
Class<? extends NativeModule> superClass =
(Class<? extends NativeModule>) 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) {

View File

@ -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 {
}