private static < T > double reduceByR ( final double [ ] array , T object ) { try { Method method = Invoker . invokeReducerLongIntReturnLongMethod ( object ) ; double sum = 0 ; for ( double v : array ) { sum = ( double ) method . invoke ( object , sum , v ) ; } return sum ; } catch ( Throwable throwable ) { return handle ( Long . class , throwable , "Unable to perform reduceBy" ) ; } }
Fallback to reflection if the call - site will not work or did not work