@DoNotStripprivatevoidfindMethods() {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "findMethods");
// define a methodNames set,But we don't add methods to the collectionSet<String> methodNames = newHashSet<>();
Class<? extendsNativeModule> classForMethods = mModuleClass;
Class<? extendsNativeModule> superClass =
(Class<? extendsNativeModule>) 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 (MethodtargetMethod : targetMethods) {
ReactMethodannotation = targetMethod.getAnnotation(ReactMethod.class);
if (annotation != null) {
StringmethodName = targetMethod.getName();
if (methodNames.contains(methodName)) {
// We do not support method overloading since js sees a function as an object regardless// of number of params.thrownewIllegalArgumentException(
"Java Module " + getName() + " method name already registered: " + methodName);
}
MethodDescriptormd = newMethodDescriptor();
JavaMethodWrappermethod = newJavaMethodWrapper(this, targetMethod, annotation.isBlockingSynchronousMethod());
md.name = methodName;
md.type = method.getType();
if (md.type == BaseJavaModule.METHOD_TYPE_SYNC) {
md.signature = method.getSignature();
md.method = targetMethod;
}
mMethods.add(method);
mDescs.add(md);
}
}
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}At first,We define a set collection methodNames,then we call methodNames.contains(methodName) to determine whether there is a repeat method.But we don't add methods to the collection.I don't know what this methodNames set means
At first,We define a set collection methodNames,then we call methodNames.contains(methodName) to determine whether there is a repeat method.But we don't add methods to the collection.I don't know what this methodNames set means