On 13.04.2016 14:10, Alan Bateman wrote:
On 11/04/2016 16:57, Jochen Theodorou wrote:
[...]
org.codehaus.groovy.runtime.InterfaceConversionTest >
testDefaultInterfaceMethodCallOnProxy FAILED
java.lang.AssertionError: java.util.Comparator/2
at
java.lang.invoke.MethodHandles$Lookup.toString(java.base@9-ea/MethodHandles.java:792)
at java.lang.String.valueOf(java.base@9-ea/String.java:2806)
at
java.lang.StringBuilder.append(java.base@9-ea/StringBuilder.java:135)
at
java.lang.invoke.MemberName.makeAccessException(java.base@9-ea/MemberName.java:867)
at
java.lang.invoke.MethodHandles$Lookup.checkAccess(java.base@9-ea/MethodHandles.java:1642)
at
java.lang.invoke.MethodHandles$Lookup.checkMethod(java.base@9-ea/MethodHandles.java:1582)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(java.base@9-ea/MethodHandles.java:1731)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(java.base@9-ea/MethodHandles.java:1725)
at
java.lang.invoke.MethodHandles$Lookup.unreflectSpecial(java.base@9-ea/MethodHandles.java:1336)
at
org.codehaus.groovy.vmplugin.v7.Java7.getInvokeSpecialHandle(Java7.java:96)
at
org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:109)
at com.sun.proxy.$Proxy47.reversed(Unknown Source)
at java_util_Comparator$reversed$0.call(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at
org.codehaus.groovy.runtime.InterfaceConversionTest.testDefaultInterfaceMethodCallOnProxy(InterfaceConversionTest.groovy:52)
but if I see the trace correctly, this is already due to a failed
access check and just a secondary error, or wrong?
I suspect there is a bug here as I think how it is possible to have a
Lookup with this lookup mode. Are you able to establish where this
Lookup is created and if it indeed created with only the PRIVATE mode set.
hmm... I see now... I had to do some trickery that backfires now - I
totally forgot about this (wanted to actually).
So I call
private Lookup(Class<?> lookupClass, int allowedModes)
with PRIVATE mode set only.. exactly as you assumed. I guess, it would
need to set the other modes as well...
What I would prefer though is a proper generic way to call a default
method on an interface without having an implementing instance. A
MethodHandles.lookup().in(Comperator.class) won't give me access to
invokespecial Comperator#reversed, or am I wrong here?
bye Jochen