Here you can find the source of getBytes(Class clazz)
private static byte[] getBytes(Class clazz) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { private static byte[] getBytes(Class clazz) throws IOException { ByteArrayOutputStream result = new ByteArrayOutputStream(); try (InputStream in = getResourceAsStrem(getBytecodeRelativePath(clazz))) { byte[] buffer = new byte[1024]; for (int read = in.read(buffer); read > -1; read = in.read(buffer)) { result.write(buffer, 0, read); }/*from w w w .j a v a 2 s.c om*/ } return result.toByteArray(); } private static InputStream getResourceAsStrem(String name) { return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); } private static String getBytecodeRelativePath(Class clazz) { return clazz.getName().replace('.', '/') + ".class"; } }