question: byte [ ] transform ( ClassReader cr , boolean stubNativesOnly ) { boolean hasNativeMethods = hasNativeMethods ( cr ) ; String className = cr . getClassName ( ) ; String newName = transformName ( className ) ; if ( newName != className ) { mRenameCount ++ ; mClassesNotRenamed . remove ( className ) ; } mLog . debug ( "Transform %s%s%s%s" , className , newName == className ? "" : " (renamed to " + newName + ")" , hasNativeMethods ? " -- has natives" : "" , stubNativesOnly ? " -- stub natives only" : "" ) ; ClassWriter cw = new ClassWriter ( ClassWriter . COMPUTE_MAXS ) ; ClassVisitor rv = cw ; if ( newName != className ) { rv = new RenameClassAdapter ( cw , className , newName ) ; } ClassVisitor cv = new TransformClassAdapter ( mLog , mStubMethods , mDeleteReturns . get ( className ) , newName , rv , stubNativesOnly , stubNativesOnly || hasNativeMethods ) ; Set < String > delegateMethods = mDelegateMethods . get ( className ) ; if ( delegateMethods != null && ! delegateMethods . isEmpty ( ) ) { if ( hasNativeMethods || ! ( delegateMethods . size ( ) == 1 && delegateMethods . contains ( DelegateClassAdapter . ALL_NATIVES ) ) ) { cv = new DelegateClassAdapter ( mLog , cv , className , delegateMethods ) ; } } cr . accept ( cv , 0 ) ; return cw . toByteArray ( ) ; }
target:  Transforms a class. <p/> There are 3 kind of transformations: 1- For "mock" dependencies classes, we want to remove all code from methods and replace by a stub. Native methods must be implemented with this stub too. Abstract methods are left intact. Modified classes must be overridable (non-private, non-final). Native methods must be made non-final, non-private. 2- For "keep" classes, we want to rewrite all native methods as indicated above. If a class has native methods, it must also be made non-private, non-final. Note that unfortunately static methods cannot be changed to non-static (since static and non-static are invoked differently.)