
package bug; 

import java.lang.invoke.MethodHandle; 
import java.lang.invoke.MethodHandles; 
import java.lang.invoke.MethodType; 
import java.lang.invoke.MethodHandles.Lookup; 
import java.lang.reflect.Method; 
import java.util.Comparator; 

public class ModuleFindDefault { 
private static final Lookup LOOKUP = MethodHandles.lookup(); 

public static void main(String[] args) throws Throwable { 
Method method = Comparator.class.getMethod("reversed"); 
Comparator<Object> cmp = new TestInterf(); 

MethodHandle mhFind = findSpecial(method); 
Object findRev = mhFind.invoke(cmp); 
System.out.println(findRev); 
} 

static MethodHandle findSpecial(Method m) throws ReflectiveOperationException { 
return LOOKUP.findSpecial(m.getDeclaringClass(), m.getName(), 
MethodType.methodType(m.getReturnType(), m.getParameterTypes()), 
m.getDeclaringClass()); 
} 

static class TestInterf implements Comparator<Object> { 

public int compare(Object o1, Object o2) { 
return 0; 
} 

@Override 
public Comparator<Object> reversed() { 
System.out.println("ModuleFindDefault.TestInterf.reversed()"); 
return this; 
} 

} 
} 