Class<?> defineClass (String name, byte[] bytes) throws ClassFormatError { try { Method method = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] {String.class, byte[].class, int.class,int.class}); method.setAccessible(true); return (Class<?>)method.invoke(getParent(), new Object[] {name, bytes, new Integer(0), new Integer(bytes.length)}); } catch (Exception ignored) { //do nothing } return defineClass(name, bytes, 0, bytes.length); } }
static ASMReflectAccessor createFor(Class<?> clazz){ synchronized (clazz) { ReflectLoader loader = new ReflectLoader(clazz.getClassLoader()); accessorClass = loader.loadClass(accessorClassName); } catch (ClassNotFoundException ignored) { accessorClass = loader.defineClass(accessorClassName, data);