 <p>You just need to cast first, before attempting to call <code>execute</code>:</p> <pre><code>return ((Commands)type).execute(cmdParams); </code></pre> <p>The way you have it written, it's attempting to call <code>execute</code> on the un-casted type, and then to cast the result to <code>Commands</code>.</p>