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.
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.
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
Don’t you have the same problem with private fields?
for(Field field : object.getClass().getDeclaredFields()){
field.setAccessible(true); // This throws an exception for a private field.
try {
Object value = field.get(object);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
I think my colleague was more interested in the name of the class which causes that error. Reflection should work fine with your own classes which you defined in your data model.
Could you please provide fully qualified class name and, in case if it is your own class, it’s code?
Sorry I no longer have the code that was causing the problem because I did it differently. But if I encounter the problem again I will post my code here.