package com.github.wreulicke.bean.validation;

import java.io.IOException;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.NotFoundException;

public class ByteCodes {
  public static byte[] getByteCode(String className) {
    ClassPool pool = ClassPool.getDefault();
    try {
      return pool.get(className)
        .toBytecode();
    } catch (IOException | CannotCompileException | NotFoundException e) {
      throw new RuntimeException(e);
    }
  }

  public static byte[] getByteCode(Class<?> clazz) {
    return getByteCode(clazz.getName());
  }
}

@@ -63,24 +63,194 @@
 IOException;
+%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.channels.SeekableByteChannel;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.StandardOpenOption;
 %0A%0Aimport jav
@@ -756,11 +756,243 @@
 ());%0A  %7D
+%0A%0A  public static void dumpByteCode(Path path, byte%5B%5D bytes) throws IOException %7B%0A    try (SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.WRITE)) %7B%0A      channel.write(ByteBuffer.wrap(bytes));%0A    %7D%0A%0A  %7D
 %0A%7D%0A

add bytecode dump utility