I have this code
List<JComponent> myList = new ArrayList<>();
fillmyList(myList); //Some method filling the list
try{
menuList.stream()
.filter(m->m.getClass().getMethod("setFont", new Class[]{Font.class}) != null) //unreported exception NoSuchMethodException; must be caught or declared to be thrown
.forEach(m -> m.setFont(someFont));
}
catch (NullPointerException | NoSuchMethodException e) {} //exception NoSuchMethodException is never thrown in body of corresponding try statement
But, I have this error messages:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - exception java.lang.NoSuchMethodException is never thrown in body of corresponding try statement
How solve this?
Aucun commentaire:
Enregistrer un commentaire