ClassCastException should never appear here. In case when selected element isn't instance of ISelection the ExecutionException will be thrown from org.eclipse.ui.handlers.HandlerUtil.getCurrentSelectionChecked(ExecutionEvent) and we can't prevent from throwing this exception. Therefore I don't think that making currentSelection to be an type of Object make any sense here.