private void simulateInvoke ( final InvokeInstruction instruction ) { final List < Element > arguments = new LinkedList <> ( ) ; MethodIdentifier identifier = instruction . getIdentifier ( ) ; IntStream . range ( 0 , identifier . getParameters ( ) . size ( ) ) . forEach ( i -> arguments . add ( runtimeStack . pop ( ) ) ) ; Collections . reverse ( arguments ) ; Element object = null ; Method method ; if ( ! identifier . isStaticMethod ( ) ) { object = runtimeStack . pop ( ) ; if ( object instanceof MethodHandle ) { method = ( Method ) object ; } else { method = methodPool . get ( identifier ) ; } } else { method = methodPool . get ( identifier ) ; } final Element returnedElement = method . invoke ( object , arguments ) ; if ( returnedElement != null ) runtimeStack . push ( returnedElement ) ; else if ( ! identifier . getReturnType ( ) . equals ( Types . PRIMITIVE_VOID ) ) runtimeStack . push ( new Element ( identifier . getReturnType ( ) ) ) ; }
Simulates the invoke instruction .