Class MethodSizeMockTransformer

All Implemented Interfaces:
MockTransformer<javassist.CtClass>

public class MethodSizeMockTransformer extends MethodMockTransformer
According to JVM specification method size must be lower than 65536 bytes. When that limit is exceeded class loader will fail to load the class. Since instrumentation can increase method size significantly it must be ensured that JVM limit is not exceeded.

When the limit is exceeded method's body is replaced by exception throw. Method is then instrumented again to allow mocking and suppression.

See Also:
  • Field Details

    • MAX_METHOD_CODE_LENGTH_LIMIT

      private static final int MAX_METHOD_CODE_LENGTH_LIMIT
      See Also:
  • Constructor Details

    • MethodSizeMockTransformer

      public MethodSizeMockTransformer(TransformStrategy strategy)
  • Method Details

    • transform

      public javassist.CtClass transform(javassist.CtClass clazz) throws javassist.CannotCompileException, javassist.NotFoundException
      Specified by:
      transform in class AbstractJavaAssistMockTransformer
      Throws:
      javassist.CannotCompileException
      javassist.NotFoundException
    • isMethodSizeExceeded

      private boolean isMethodSizeExceeded(javassist.CtMethod method)