Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4071957

(reflect) Method.invoke access control does not understand inner class scoping

    Details

    • Subcomponent:
    • CPU:
      generic, x86, sparc
    • OS:
      generic, linux, solaris_2.5.1, windows_nt, windows_2000, windows_xp

      Backports

        Description

        Name: sg39081 Date: 08/14/97


        Running the following program, which should succeed, results in an
        IllegalAccessException.

        import java.lang.reflect.*;

        public class TestPrivateAccess extends Object
        {
          TPAInnerClass inner = new TPAInnerClass();

          private void privateMethod()
          {System.out.println("private method.");}

          class TPAInnerClass extends Object
          {
            void dynamicInvoke()
            {
              try
        {
        Method method =
        TestPrivateAccess.class.getDeclaredMethod("privateMethod", new Class[] {});
        method.invoke(TestPrivateAccess.this, new Object[] {});
        }
              catch (Exception e)
        {e.printStackTrace();}
            }
          }

          public static void main(String[] argv)
          {
            TestPrivateAccess tpa = new TestPrivateAccess();
            tpa.inner.dynamicInvoke();
          }
        }

        company - MIT Media Lab , email - ###@###.###
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  darcy Joe Darcy
                  Reporter:
                  sgoodsunw Sheri Good (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: