title: How to specify exception types using reflection?
body: <p>I am using reflection in my code, to give the user opportunity to call directly the methods, without writing tones of if...else statements or switches, but I have a problem.
  I have a method called Exit(), which i want to throw my custom exception, but when i add a catch statement for the method.invoke() line, the compiler tells me that that kind of exception is never thrown in that statement, but it's absolutely possible that the user will call that method, how can i find a solution for this problem?</p>
  
  <p>here is my reflection code</p>
  
  <pre><code>try {
                      methodName = input.nextLine();
  
                      Class&lt;?&gt; facade = StoreFacade.getInstance().getClass();
                      Method method = facade.getDeclaredMethod(methodName);
                      method.setAccessible(true);
                      method.invoke(StoreFacade.getInstance());
  
                  } catch (InvocationTargetException e) {
                      e.printStackTrace();
                  } catch (NoSuchMethodException e) {
                      e.printStackTrace();
                  } catch (IllegalAccessException e) {
                      e.printStackTrace();
                  }catch (Exceptions.EndOfSessionException e){
                      System.out.println(e.getMessage());
                  }
  </code></pre>