Compiler Error J0259

Exception 'identifier' from method 'identifier' is not a subclass of any exceptions declared thrown by delegate 'identifier'

The compiler detected a delegate that was initialized with a method that throws an exception that is incompatible with the delegate's declared set of exceptions. Each exception thrown by the method must be the same class or a subclass of an exception that the delegate throws. Change the set of exceptions thrown by either the delegate or the method and compile again.

The following example illustrates this error:

delegate void SimpleDelegate(String var1) throws Exception;

public class Simple{
   public void method1(String var1) throws Throwable{
      //do something here
   }
   public static void main (String args[]){
      
      Simple smp = new Simple();
      SimpleDelegate del1 = new SimpleDelegate(smp.method1);
      /* error: the method reference argument throws an exception that is
             not the same or a subclass of the exception declared by the
             delegate */
   }
}