-
Notifications
You must be signed in to change notification settings - Fork 878
How to define rules to avoid some methods during Java method discovering #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There are so many embedding options in Rhino and I'm not sure if anyone has given you a good idea yet. But is there a specific method annotation that Rhino should be looking for, or an enhancement to the java embedding mechanism that you could possibly use? |
in my case, the problem arise with methods annotated with tag @ApiLevel, so if the apilevel of the method is greater that the supported device level api, the method must be ignored. |
Maybe I should share my experiments, where I tried to add a securitymanager to rhino: The most interesting commits are Unfortunately, the class shutter is not flexible enough at this point:
That's why I changed the class shutter FOCONIS@9e4c32f and add some methods:
If you check for the @ApiLevel annotation in this method, you may hide some methods from your application code. I am planning to continue the work on this branch in a few weeks. |
Thank you, it looks exactly what I need. When is this branch expected to be included in a release? |
As the https://github.com/FOCONIS/rhino/commits/experimental-securitymanager branch is based on the now deprecated and slated to be removed Java Security Manager, I don't see this branch (in its current state) ever being merged into Rhino |
I'm trying to embedded mozilla rhino in an android project to use js scripting with android view components through liveConnect.
It works really well but I'm having a problem during the Java method inspection.
When a class has methods with a signature that uses classes not present in the api level of the device, the method inspection crashes with a ClassNotFoundException, this is expected.
In Android, this problem is avoided with method annotation, and the class still works as long as the methods with the missing classes are not used.
For example, TextClassifier appears in android in level 26. TextInputEditText has a method setTextClassifier annotated with @ApiLevel 26, and you can use a TextInputEditText in devices with api level < 26 as long as you don't use a TextClassifier.
The key of the problem is method JavaMembers.discoverAccessibleMethods(), the change is fairly simple, look for annotations in methods, define a rule to exclude classes or to eat-up the ClassNotFoundException.
But instead of patching the code, I wonder if there's a cleaner way to do this without having to modify the library.
Thank you.
The text was updated successfully, but these errors were encountered: