(reflect) Method.invoke() -- can't call methods privately inherited.

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 1.1, 1.1.3, 1.1.4
    • Component/s: core-libs
    • generic, x86, sparc
    • solaris_2.5.1, windows_95

      I have

      package P

      protected class A implements B {
          blabla...
      }

      public interface B {
      public void bongo();
      }

      And then I do the things below outside of package P

      B a = somehowGetAHandleOfAnInstanceOfA

      Method m = a.getClass().getMethod("bongo", new Class[] {Void.class});

      When I do

      m.invoke(a, null);

      I get a IllegalAccessException.

      At least the docs should point out this behavior (so it's at least a docu bug).
      I don't know if the behavior is not a bug.
      getMethod should work for all methods that A understands.
      After all I can do a.bongo(), and reflection should support
      everything that can be done directly.

      The workaround is

      a.getInterfaces() and then look in the interfaces for the right Method instance.



            Assignee:
            Anand Palaniswamy (Inactive)
            Reporter:
            J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: