private static CtClass doModelModifications ( byte [ ] byteCode , Version modelVersion , ClassLoader ... loaders ) { if ( ! initiated ) { initiate ( ) ; } CtClass cc = null ; LoaderClassPath [ ] classloaders = new LoaderClassPath [ loaders . length ] ; try { InputStream stream = new ByteArrayInputStream ( byteCode ) ; cc = cp . makeClass ( stream ) ; if ( ! JavassistUtils . hasAnnotation ( cc , Model . class . getName ( ) ) ) { return null ; } LOGGER . debug ( "Model to enhance: {}" , cc . getName ( ) ) ; for ( int i = 0 ; i < loaders . length ; i ++ ) { classloaders [ i ] = new LoaderClassPath ( loaders [ i ] ) ; cp . appendClassPath ( classloaders [ i ] ) ; } doEnhancement ( cc , modelVersion ) ; LOGGER . info ( "Finished model enhancing for class {}" , cc . getName ( ) ) ; } catch ( IOException e ) { LOGGER . error ( "IOException while trying to enhance model" , e ) ; } catch ( RuntimeException e ) { LOGGER . error ( "RuntimeException while trying to enhance model" , e ) ; } catch ( CannotCompileException e ) { LOGGER . error ( "CannotCompileException while trying to enhance model" , e ) ; } catch ( NotFoundException e ) { LOGGER . error ( "NotFoundException while trying to enhance model" , e ) ; } catch ( ClassNotFoundException e ) { LOGGER . error ( "ClassNotFoundException while trying to enhance model" , e ) ; } finally { for ( int i = 0 ; i < loaders . length ; i ++ ) { if ( classloaders [ i ] != null ) { cp . removeClassPath ( classloaders [ i ] ) ; } } } return cc ; }
Try to perform the actual model enhancing .