/**
  * Instantiates the given EventListener class and performs any required resource injection into
  * the new EventListener instance before returning it.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (T) doPrivileged("createListener", new Object[] {clazz});
   } else {
     return context.createListener(clazz);
   }
 }
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public <T extends EventListener> T createListener(Class<T> c) throws ServletException {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     try {
       return (T) invokeMethod(context, "createListener", new Object[] {c});
     } catch (Throwable t) {
       ExceptionUtils.handleThrowable(t);
       if (t instanceof ServletException) {
         throw (ServletException) t;
       }
       return null;
     }
   } else {
     return context.createListener(c);
   }
 }