private static Object invokeDefaultMethodUsingPrivateLookup ( Class < ? > declaringClass , Object o , Method m , Object [ ] params ) throws WrappedException , NoSuchMethodException { try { final Method privateLookup = MethodHandles . class . getDeclaredMethod ( "privateLookupIn" , Class . class , MethodHandles . Lookup . class ) ; return ( ( MethodHandles . Lookup ) privateLookup . invoke ( null , declaringClass , MethodHandles . lookup ( ) ) ) . unreflectSpecial ( m , declaringClass ) . bindTo ( o ) . invokeWithArguments ( params ) ; } catch ( NoSuchMethodException t ) { throw t ; } catch ( Throwable t ) { throw new WrappedException ( t ) ; } }
For JDK 9 + we could use MethodHandles . privateLookupIn which is not available in JDK 8 .