jeudi 6 février 2020

Cannot access a method using Reflection API

I'm trying to access a setter and change the value at run-time, using reflection API. I have a JasperReport object which has a method named getDefaultStyle, which in turn allows me to call setFontName method, like this

jasperReport.getDefaultStyle().setFontName()

'setFontName' takes a String as method argument and sets that as font. I'm trying to change the font value during the rutime like this

on(jasperReport).call("getDefaultStyle").call("setFontName").set("fontName", "Helvetica");

But, I'm getting this error

org.jooq.tools.reflect.ReflectException: java.lang.NoSuchMethodException: No similar method setFontName with params [] could be found on type class java.lang.Object.

Not so experienced in reflection API, could use some help.





Aucun commentaire:

Enregistrer un commentaire