title: Unreported exception must be caught or declared to be thrown:
body: <p>I have this code which although have the Lombok <code>SneakyThrows</code> annotation, the compiler still complains that <code>Error:(65, 58) java: unreported exception java.rmi.RemoteException; must be caught or declared to be thrown:</code></p>
  <pre><code>@SneakyThrows
  @Override
  public Optional&lt;Boolean&gt; unregister() throws RemoteException {
      if(registry != null) {
        Arrays.asList(registry.list()).forEach(className -&gt; {
          registry.unbind(className);
        });
      }
      return Optional.of(true);
  }
  </code></pre>
  <p>The method that calls this method above is this:</p>
  <pre><code>@SneakyThrows
  public void stopDatabase() {
      if(registrar == null) {
        LOG.error(&quot;Database has not started&quot;);
      } else {
        registrar.unregister();
      }
  }
  </code></pre>
  <p><strong>Updating the code to this (solves the issue)</strong>
  but we don't want to change to using for-loop like this:</p>
  <pre><code>@SneakyThrows
  @Override
  public Optional&lt;Boolean&gt; unregister() {
         if (registry != null) {
             String[] classNames = registry.list();
             for(int i=0;i&lt;classNames.length;i++) {
                registry.unbind(classNames[i]);
             }
        }
        return Optional.of(true);
  }
  </code></pre>