United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7054590 (JSR-292) MethodHandleProxies.asInterfaceInstance() accepts private/protected nested interfaces
JDK-7054590 : (JSR-292) MethodHandleProxies.asInterfaceInstance() accepts private/protected nested interfaces

Details
Type:
Bug
Submit Date:
2011-06-14
Status:
Closed
Updated Date:
2012-03-29
Project Name:
JDK
Resolved Date:
2012-03-29
Component:
core-libs
OS:
os_x,linux,generic
Sub-Component:
java.lang.invoke
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7,7u4
Fixed Versions:
7u4 (b10)

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:
Relates:

Sub Tasks

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)

                                    

Comments
EVALUATION

Correct.  We have a fix in hand for this.
                                     
2011-06-14



Hardware and Software, Engineered to Work Together