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

Expected IllegalAccessException is not thrown

XMLWordPrintable


      One licensee expected an exception IllegalAccessException when calling a
      public method of nested protected class via reflection from outside package.
      With attached test program, no such an exception was seen.

      The test program has two nested classes in bar/Outer.java. One is static
      nested class, the other is inner class(non-static). The modifiers of these
      two nested classes are set protected.

      The main program invoked public methods in these two nested classes through
      reflection API, the expected exception did not occur.

      Refer to JLS, 15.12.4.3. Check Accessibility of Type and Method
      http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.4.3

      Because the main class(foo/Tester.java) is not a subclass of bar/Outer.java,
      it should not be accessible to methods of those nested protected classes.

      Please check if it conforms to the specification.


            rpatil Ramanand Patil (Inactive)
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: