Il problema è dato dal fatto che il metodo class.forName non può sollevare un tipo di eccezione "EccezioneDefinitaDaUtente", e come mai potrebbe farlo è una custom exception, ecco perchè il compilatore (furbo) ti avverte della cosa.
Penso che quello che vorresti ottenere è qualcosa del genere
codice:
try{
Distributor source = null;
String className = "package1.distributori."+dst.getDistributorClass();
source = (Distributor) Class.forName(className).getConstructor(String.class).newInstance(child.getPath());
} catch (ClassNotFoundException ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
} catch (NoSuchMethodException ex){
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
} catch (InstantiationException ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
} catch (IllegalAccessException ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
} catch (IllegalArgumentException ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
} catch (InvocationTargetException ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
}
// Gestisci eccezione;
}
In maniere più sintetica puoi anche scriverlo cosi
codice:
try{
Distributor source = null;
String className = "package1.distributori."+dst.getDistributorClass();
source = (Distributor) Class.forName(className).getConstructor(String.class).newInstance(child.getPath());
} catch (Exception ex) {
msgArea.append(ex.getCause()+"\n");
throw new EccezioneDefinitaDaUtente(...);
}
// Gestisci eccezione;
}
Ciao