title: UndeclaredThrowableException thrown by IndexOutOfBoundsException
body: <p>I am using the decorator pattern for a <code>List&lt;WebElement&gt;</code>.Part of this decoration entails using a proxy. </p>
  
  <p>When I call <code>get(index)</code> with an index that is out of bounds, it throws an <code>IndexOutOfBounds</code> exception, which is then caught by the proxy, and wrapped with an <code>UndeclaredThrowableException</code>.</p>
  
  <p>My understanding is that it should <strong>only</strong> do this if its a checked exception.  <code>IndexOutOfBounds</code> is an <em>unchecked</em> exception, so why is it getting wrapped?</p>
  
  <p>It still gets wrapped even if I add <code>throws IndexOutOfBounds</code> to my <code>invoke</code> function.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public WebElementList findWebElementList(final By by){
      return new WebElementList(
              (List&lt;WebElement&gt;) Proxy.newProxyInstance(this.getClass().getClassLoader(),
                      new Class&lt;?&gt;[] { List.class }, new InvocationHandler() {
          // Lazy initialized instance of WebElement
          private List&lt;WebElement&gt; webElements;
  
          public Object invoke(Object proxy, Method method, Object[] args)
                  throws Throwable {
              if (webElements == null) {
                  webElements = findElements(by);
              }
              return method.invoke(webElements, args);
          }
      }), driver);
  }
  </code></pre>
  
  <p>Here's part of my stacktrace:</p>
  
  <pre><code>java.lang.reflect.UndeclaredThrowableException
  at com.sun.proxy.$Proxy30.get(Unknown Source)
  at org.lds.ldsp.enhancements.WebElementList.get(WebElementList.java:29)
  ...
  Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  at java.util.ArrayList.rangeCheck(ArrayList.java:604)
  at java.util.ArrayList.get(ArrayList.java:382)
  ... 41 more
  </code></pre>