Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are some subtle differences:</p> <ul> <li>Context <ul> <li>An invocation context is associated with the caller <ul> <li>e.g. the parameters you're using to invoke a method are the actual parameters</li> </ul></li> <li>An execution context is associated with the callee <ul> <li>e.g. the parameters you're using in a method execution are formal parameters</li> </ul></li> </ul></li> <li>Dynamic dispatch <ul> <li>A method invokation can lead to the execution of any one of many methods</li> <li>An executing method is precisely one executing method</li> </ul></li> <li>Order: invocation precedes execution <ul> <li>Invocation of a method doesn't immediately start its execution <ul> <li>Imagine if the method is remote</li> <li>Invocation failure could be caused by broken connection, error in handling the arguments over the wire, etc</li> </ul></li> <li>A method only starts executing after invocation is successful</li> </ul></li> </ul> <p>See also: <a href="http://java.sun.com/docs/books/tutorial/rmi/index.html" rel="nofollow noreferrer">Overview of Remote Method Invocation</a>. When you consider the method to be remote, the difference between invocation (a request to start the execution of something) and execution (something that is happening somewhere if the request is successful) becomes more apparent.</p> <p>Consider also the case with reflection. This is a method of <a href="http://java.sun.com/javase/6/docs/api/java/lang/reflect/Method.html#invoke%28java.lang.Object,%20java.lang.Object...%29" rel="nofollow noreferrer"><code>java.lang.reflect.Method</code></a>:</p> <pre><code>public Object invoke(Object obj, Object... args) throws IllegalAccessException, // failure during invocation IllegalArgumentException, // failure during invocation InvocationTargetException // invocation was successful, // but exception was thrown during execution </code></pre> <p>Here also clearly invocation and execution are two different things. If you need more convincing, consider the case of an invocation vs execution <code>NullPointerException</code> in this reflection context:</p> <ul> <li>It can be thrown during invocation, when <code>obj == null</code> when the method is an instance method</li> <li>It can be thrown during execution, in which case it will be wrapped as <em>the cause</em> of an <code>InvocationTargetException</code></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload