java - when and how will ImageIO.write throw nullpointerexception? -
in imageio.write(renderedimage,string,file) method, imageoutputstream created through stream = createimageoutputstream (output);. in createimageoutputstream runtime exception caught , returns null catch block. try { iter = theregistry.getserviceproviders(imageoutputstreamspi.class,true); } catch (illegalargumentexception e) { return null; } can me understand: what reason behind catching runtime exception here?(unless crappy coding) on condition, code throw illegal argument exception? (i dont see reason throw) please help. it case of code has evolved on time , no 1 cared clean up, or implementers of imageio relied on contract of serviceregistry , rather implementation details of it. in current implementation of imageio , serviceregistry don't see how ever happen. the thing can see it, potentially change implementation of iioregistry or serviceregistry lazy loading of categories example, or perhaps flush...