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

(JSR-292) MethodHandleProxies.asInterfaceInstance() accepts private/protected nested interfaces

    Details

    • Subcomponent:
    • Resolved In Build:
      b10
    • CPU:
      generic, x86
    • OS:
      generic, linux, os_x
    • Verification:
      Not verified

      Backports

        Description

        The javadoc specification for the MethodHandleProxies.asInterfaceInstance method states:
          "The interface must be public. No additional access checks are performed."

        However, this method still accepts private/default-access/protected *nested* interfaces.

        Minimized test:
        ===============
        --- Test.java ---
        import java.lang.invoke.*;
        import static java.lang.invoke.MethodType.*;
        import static java.lang.invoke.MethodHandles.*;
        import static java.lang.invoke.MethodHandleProxies.*;

        public class Test {
           /*protected*/ /*private*/ interface PrivateIntf {
               void m();
           }

           public static class C {
               public static void m() {}
           }

           public static void main(String argv[]) throws Throwable {
               MethodHandle mh = lookup().findStatic(
                       C.class, "m", methodType(void.class));

               PrivateIntf intf = asInterfaceInstance(PrivateIntf.class, mh);
           }
        }
        --- Test.java ---

        Minimized test output:
        ======================
        $ java -showversion -verify Test
        java version "1.7.0-ea"
        Java(TM) SE Runtime Environment (build 1.7.0-ea-b145)
        Java HotSpot(TM) Server VM (build 21.0-b15, mixed mode)

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jrose John Rose
                  Reporter:
                  ygaevsky Yuri Gaevsky
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: