I get the following error in my Java code:
java.lang.IllegalAccessException: Class org.apache.commons.digester.ObjectCreateRule can not access a member of class Response with modifiers ""
Is it maybe because class Response is not public class ? If so, how can I make it accessible and keep the class Response in the same file with the main class ?
thanks
Update, Code: http://www.smipple.net/snippet/aneuryzma/on:%20is%20related%20to%20public%20/%20private%20attribute%20for%20classes%20%3F
As far as I remember your class Response should follow the bean convention: should be public, should have public default constructor and should have setters and getters for all fields that you refer from your xml.
Yes it is, as IllegalAccessException documentation says.
You can circumvent access modifiers with reflection. For example, to access private fields, use Class.getDeclaredField(String)
to get a specific Field
(works also for private fields - using plain getField
can only get public members), and then set Field.setAccessible(true)
. Now the field can be used as if it was public.
You can also circumvent access modifier with JNI. It doesn't care about access modifiers at all. Yet one more way is to generate custom bytecode with a tool such as ASM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With