ZeroTurnaround Support Forum » JRebel Support

odd IllegalAccessException calling superclass method

(4 posts)

  1. mschrag

    Member
    Posts: 1

    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

    Posted 2 years ago #
  2. ekabanov

    LeadRebel
    Posts: 546

    Looks like a bug, I'll take a look at that.

    Posted 2 years ago #
  3. ekabanov

    LeadRebel
    Posts: 546

    For a workaround you can call setAccessible(true) before calling the method.

    Posted 2 years ago #
  4. ekabanov

    LeadRebel
    Posts: 546

    Should be fixed in 1.1.1, can you confirm?

    Posted 2 years ago #

RSS feed for this topic

Reply

(required)

(required)

(optional)

(required)

Allowed markup: a blockquote code em strong ul ol li.
Put code in between `backticks`.

Olark Livehelp