Problem with java reflection

Hello,

In my java code I use reflection:

field.setAccessible(true).

When I test my code locally it works but when I deploy my code on Backendless and execute the code this exception is thrown:

access denied (“java.lang.reflect.ReflectPermission” “suppressAccessChecks”)

Could you help me to understand why ?

Thank you

Hello @Seb777

Unfortunately, we are limiting reflection access. But I have created an internal ticket BKNDLSS-30269 to find a solution for your problem. We will let you know the result in this thread.

Regards,
Inna

Hi, @Seb777 .
I’ve wrote my example with reflective access to the class fields/methods. Both to the my custom classes (my custom logic which i compile) and to the classes from the libs dir.
Everything works fine. Maybe it is related to the specific class/field/method.

Could you, please, describe your case more precisely.

Hi @oleg-vyalyh

Reflection works well. It’s just that field.setAccessible(true) throws an exception when the field is private. To solve my problem I had two possibilities. Set my field to public or use the related getter method. I take the last option and it works. So now it’s ok for me :slight_smile:

Don’t you have the same problem with private fields?

Thank you for your help.

hello @Seb777

no, we actually haven’t, because we always use getter or setter to access the fields.

But it would be interesting to look at your sample code (simple example of custom service which isn’t work).