It's nice but it's just syntactic sugar so if it is slower than the current method I'd say no. If it impacts the speed of the current method I'd say no as well.
So I'd like to see some performance tests of the various methods before going ahead with this. Simon On Mon, Apr 30, 2018, 15:13 Joe Bowser <bows...@gmail.com> wrote: > I'm fine with this. The problem we have now with our extensive use of > reflection on Android is both with performance, as well as with being able > to use obfuscation tools like ProGuard, which many auditors want to use to > determine whether their code is "actually secure". I don't think > obfuscation makes anything more secure at all, but I don't write these > security analyzers. That's why I'm against adding more reflection into it. > > Also, I've been doing this long enough to remember the old > addJavascriptInterface reflection exploit. > > > > On Sun, Apr 29, 2018 at 2:43 PM, Wojciech Trocki <wtro...@gmail.com> > wrote: > > > I have created PR in Android repository to show idea. > > > > https://github.com/apache/cordova-android/pull/439 > > > > This change do not use reflection/annotations mentioned in original > > proposition. > > IMHO with this change plugin interface will be much simpler and more > object > > oriented. > > > > On Sun, Apr 29, 2018 at 4:55 PM, Rabindra Nayak < > rabindra.mob...@gmail.com > > > > > wrote: > > > > > How about iOS annotation @CordovaMethod.Because the way Android and iOS > > and > > > other OS plugin implementation should be same.We need think that > aspect. > > > > > > > > > On Sun, Apr 29, 2018, 21:08 Joe Bowser <bows...@gmail.com> wrote: > > > > > > > Cordova should be reducing the use of Reflection, not increasing > it. I > > > > don't think this is a good idea. > > > > > > > > On Sun, Apr 29, 2018, 8:28 AM Jesse, <purplecabb...@gmail.com> > wrote: > > > > > > > > > I would like to see proof of value. > > > > > I believe the lookup of an action is insignificant compared to the > > > > message > > > > > conversion between js and native. > > > > > Please write some tests to justify your position. > > > > > > > > > > > > > > > > On Apr 29, 2018, at 7:59 AM, julio cesar sanchez < > > > > jcesarmob...@gmail.com> > > > > > wrote: > > > > > > > > > > > > I think it's a good idea. > > > > > > > > > > > > FYI, there is a plugin that already allows this, you just have to > > add > > > > it > > > > > as > > > > > > a dependency, but it's not backward compatible > > > > > > https://github.com/edewit/aerogear-reflect-cordova > > > > > > > > > > > > 2018-04-29 16:44 GMT+02:00 Wojciech Trocki <wtro...@redhat.com>: > > > > > > > > > > > >> Hi Maksim > > > > > >> > > > > > >> `if (METHOD_1.equals(action))` is very similar way to how redux > > > works. > > > > > >> > > > > > >> I have playing with your proposition to see how this could be > > > > > implemented. > > > > > >> What I found is that processing annotations on runtime can > > > contribute > > > > to > > > > > >> slower application startup due to fact that annotation needs to > be > > > > > >> processed at runtime. > > > > > >> Deviceready event is delivered later, which is not desired. This > > > could > > > > > be > > > > > >> also processed on build time (something like dagger), but I did > > not > > > > > >> investigated that. > > > > > >> > > > > > >> I figured out simple way to extend this without any sacrifice on > > > > > >> performance. > > > > > >> This will simplify end user api and also still provide full > > > backwards > > > > > >> compatibility. > > > > > >> We could make improvement for developers without affecting end > > user > > > > app > > > > > >> performance. > > > > > >> > > > > > >> Linking gist with the idea: > > > > > >> > https://gist.github.com/wtrocki/43bfdda18c086a3283bb8ba3bf2d052e > > > > > >> > > > > > >> Happy to contribute that back to the Cordova. > > > > > >> > > > > > >> *Note: *I'm not maintainer of Cordova Android platform so my > > > response > > > > do > > > > > >> not mean that there will be approval for this change. > > > > > >> > > > > > >> > > > > > >> On Sun, Apr 29, 2018 at 9:58 AM, chemeri...@gmail.com < > > > > > >> chemeri...@gmail.com> > > > > > >> wrote: > > > > > >> > > > > > >>> Hi guys. cordova-ios has a nice method binding for plugins. > > > > > Unfortunately > > > > > >>> cordova-android requires at present boilerplate implementation > of > > > > > method > > > > > >>> execute: > > > > > >>> > > > > > >>> public class MyPlugin extends CordovaPlugin { > > > > > >>> ... > > > > > >>> @Override > > > > > >>> public boolean execute(String action, JSONArray args, > > > > > CallbackContext > > > > > >>> callbackContext) throws JSONException { > > > > > >>> if (METHOD_1.equals(action)) { > > > > > >>> method1(args, callbackContext); > > > > > >>> } else if (METHOD_2.equals(action)) { > > > > > >>> method2(args, callbackContext); > > > > > >>> ... > > > > > >>> } else { > > > > > >>> return false; > > > > > >>> } > > > > > >>> return true; > > > > > >>> } > > > > > >>> ... > > > > > >>> } > > > > > >>> > > > > > >>> I suggest to implement support for @CordovaMethod that will > allow > > > for > > > > > >>> plugin authors to reduce boilerplate code, so the > implementation > > > > above > > > > > >> will > > > > > >>> look like: > > > > > >>> > > > > > >>> public class MyPlugin extends CordovaPlugin { > > > > > >>> ... > > > > > >>> @CordovaMethod > > > > > >>> private void method1(JSONArray args, CallbackContext > > > > > callbackContext) > > > > > >>> throws JSONException { > > > > > >>> ... > > > > > >>> } > > > > > >>> > > > > > >>> @CordovaMethod > > > > > >>> private void method2(JSONArray args, CallbackContext > > > > > callbackContext) > > > > > >>> throws JSONException { > > > > > >>> ... > > > > > >>> } > > > > > >>> ... > > > > > >>> } > > > > > >>> > > > > > >>> Implementation of method execute in CordovaPlugin.java will > check > > > for > > > > > >>> methods marked with @CordovaMethod and if action argument > > matches a > > > > > >> method > > > > > >>> with @CordovaMethod, the method will be invoked. Developer can > > also > > > > > >> specify > > > > > >>> action manually via the name parameter: > > > > > >>> > > > > > >>> public class MyPlugin extends CordovaPlugin { > > > > > >>> ... > > > > > >>> @CordovaMethod(name = "method1") > > > > > >>> private void myMethod(JSONArray args, CallbackContext > > > > > >> callbackContext) > > > > > >>> throws JSONException { > > > > > >>> ... > > > > > >>> } > > > > > >>> ... > > > > > >>> } > > > > > >>> > > > > > >>> Important to note that backward compatibility is preserved - > old > > > > > plugins > > > > > >>> didn't have @CordovaMethod, but new ones can use it to simplify > > > code. > > > > > >>> > > > > > >>> What do you think? > > > > > >>> > > > > > >>> > > > > > >>> ------------------------------------------------------------ > > > --------- > > > > > >>> To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org > > > > > >>> For additional commands, e-mail: dev-h...@cordova.apache.org > > > > > >>> > > > > > >>> > > > > > >> > > > > > >> > > > > > >> -- > > > > > >> > > > > > >> WOJCIECH TROCKI > > > > > >> > > > > > >> Red Hat Mobile <https://www.redhat.com/> > > > > > >> > > > > > >> IM: wtrocki > > > > > >> <https://red.ht/sig> > > > > > >> > > > > > > > > > > ------------------------------------------------------------ > > --------- > > > > > To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org > > > > > For additional commands, e-mail: dev-h...@cordova.apache.org > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > WOJCIECH TROCKI > > > > Red Hat Mobile <https://www.redhat.com/> > > > > IM: wtrocki > > <https://red.ht/sig> > > >