/** * Performs the enhancement. * * @param className The name of the class whose bytecode is being enhanced. * @param originalBytes The class's original (pre-enhancement) byte code * * @return The enhanced bytecode. Could be the same as the original bytecode if the original was * already enhanced or we could not enhance it for some reason. * * @throws EnhancementException Indicates a problem performing the enhancement */ @Override public synchronized byte[] enhance(String className, byte[] originalBytes) throws EnhancementException { CtClass managedCtClass = null; try { managedCtClass = classPool.makeClassIfNew( new ByteArrayInputStream( originalBytes ) ); return enhance( managedCtClass ) ? getByteCode( managedCtClass ) : null; } catch (IOException e) { log.unableToBuildEnhancementMetamodel( className ); return null; } finally { if ( managedCtClass != null ) { managedCtClass.detach(); } } }
/** * Performs the enhancement. * * @param className The name of the class whose bytecode is being enhanced. * @param originalBytes The class's original (pre-enhancement) byte code * * @return The enhanced bytecode. Could be the same as the original bytecode if the original was * already enhanced or we could not enhance it for some reason. * * @throws EnhancementException Indicates a problem performing the enhancement */ @Override public synchronized byte[] enhance(String className, byte[] originalBytes) throws EnhancementException { CtClass managedCtClass = null; try { managedCtClass = classPool.makeClassIfNew( new ByteArrayInputStream( originalBytes ) ); return enhance( managedCtClass ) ? getByteCode( managedCtClass ) : null; } catch (IOException e) { log.unableToBuildEnhancementMetamodel( className ); return null; } finally { if ( managedCtClass != null ) { managedCtClass.detach(); } } }