[Misc] Improvement suggested by Sergiu to fix the "Cannot retrieve method getname from object of class java.lang.Class due to security restrictions." message displayed in the logs (see XWIKI-8754)