I'm trying out JavaRebel with WebObjects and getting a very odd IllegalAccessException when I try to call a protected superclass of my class via reflection. Ignore the reasons for actually doing this (binary compatibility across multiple versions of the underlying framework), as it looks pretty weird, but:
public class ERXWOForm extends com.webobjects.appserver._private.WOHTMLDynamicElement {
...
protected void _appendHiddenFieldsToResponse(WOResponse response, WOContext context) {
Method computeQueryDictionaryInContextMethod = WOHTMLDynamicElement.class.getDeclaredMethod("computeQueryDictionaryInContext", new Class[] { WOAssociation.class, WOAssociation.class, WOAssociation.class, boolean.class, NSDictionary.class, WOContext.class });
hiddenFields = (NSDictionary) computeQueryDictionaryInContextMethod.invoke(this, new Object[] { _actionClass, _directActionName, _queryDictionary, Boolean.valueOf(flag), _otherQueryAssociations, context });
...
superclass:
public abstract class WOHTMLDynamicElement extends WODynamicGroup {
...
protected NSDictionary computeQueryDictionaryInContext(WOAssociation woassociation, WOAssociation woassociation1, WOAssociation woassociation2, boolean flag, NSDictionary nsdictionary, WOContext wocontext) {
....
At runtime, this yields:
Caused by: java.lang.IllegalAccessException: Class er.extensions.ERXWOForm$$M$6e113290 can not access a member of class com.webobjects.appserver._private.WOHTMLDynamicElement with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
at java.lang.reflect.Method.invoke(Method.java:578)
at er.extensions.ERXWOForm$$M$6e113290._appendHiddenFieldsToResponse(ERXWOForm.java:240)
This seems odd, because it is legal to call a protected method of your own superclass, and this DOES work when NOT running under JavaRebel. Let me know if there's anything else I can provide.
Thanks
ms
