use of org.powermock.api.mockito.repackaged.asm.ClassWriter in project powermock by powermock.
the class AbstractClassLoader method loadClass.
public Class loadClass(String name) throws ClassNotFoundException {
Class loaded = findLoadedClass(name);
if (loaded != null) {
if (loaded.getClassLoader() == this) {
return loaded;
}
//else reload with this class loader
}
if (!filter.accept(name)) {
return super.loadClass(name);
}
ClassReader r;
try {
java.io.InputStream is = classPath.getResourceAsStream(name.replace('.', '/') + ".class");
if (is == null) {
throw new ClassNotFoundException(name);
}
try {
r = new ClassReader(is);
} finally {
is.close();
}
} catch (IOException e) {
throw new ClassNotFoundException(name + ":" + e.getMessage());
}
try {
ClassWriter w = new DebuggingClassWriter(ClassWriter.COMPUTE_MAXS);
getGenerator(r).generateClass(w);
byte[] b = w.toByteArray();
Class c = super.defineClass(name, b, 0, b.length, DOMAIN);
postProcess(c);
return c;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new CodeGenerationException(e);
}
}
use of org.powermock.api.mockito.repackaged.asm.ClassWriter in project powermock by powermock.
the class DefaultGeneratorStrategy method generate.
public byte[] generate(ClassGenerator cg) throws Exception {
ClassWriter cw = getClassWriter();
transform(cg).generateClass(cw);
return transform(cw.toByteArray());
}
Aggregations