title: How to remove method body at runtime with ASM 5.2
body: <p>I'm trying to remove the method body of <code>test()</code> in the following program so that nothing is printed to the Console. I'm using using ASM 5.2 but everything I've tried doesn't seem to have any effect. </p>
  
  <p>Can someone explain what I'm doing wrong and also point me to some up-to-date tutorials or documentation on ASM? Almost everything Iv'e found on Stackoverflow and the ASM website seems outdated and/or unhelpful.</p>
  
  <pre><code>public class BytecodeMods {
  
      public static void main(String[] args) throws Exception {
          disableMethod(BytecodeMods.class.getMethod("test"));
          test();
      }
  
      public static void test() {
          System.out.println("This is a test");
      }
  
      private static void disableMethod(Method method) {
          new MethodReplacer()
                  .visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, method.getName(), Type.getMethodDescriptor(method), null, null);
      }
  
      public static class MethodReplacer extends ClassVisitor {
  
          public MethodReplacer() {
              super(Opcodes.ASM5);
          }
  
          @Override
          public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
              return null;
          }
  
      }
  
  }
  </code></pre>