lundi 6 juin 2016

How to protect against the IllegalAccessException?

I research following JDK method:

java.lang.reflect.Field#get

it throws IllegalAccessException if the underlying field is inaccessible.

Am I right I can protect my code against the exception if I will add following line

field.setAccessible(true);

?

Is there another ways to get this exception?





Aucun commentaire:

Enregistrer un commentaire