public void executeInstrumentation ( ) throws IOException { errors . clear ( ) ; // Iterate over all entries in the classes list for ( File f : this . classFiles ) { try { if ( ! f . canRead ( ) || ! f . canWrite ( ) ) { throw new IOException ( f + " can not be replaced" ) ; } instrumentClassFile ( f ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; errors . add ( e ) ; } } // Iterate over all entries in the jar list for ( File f : this . jarFiles ) { try { instrumentZipFile ( f ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; errors . add ( e ) ; } } // Chain the first exception and report the error count if ( ! errors . isEmpty ( ) ) { Throwable t = errors . get ( 0 ) ; IOException ioe = new IOException ( errors . size ( ) + " errors occurred" ) ; ioe . initCause ( t ) ; throw ioe ; } }
Instrument the classes and jar files .