use of org.objectweb.asm.commons.Remapper in project ignite by apache.
the class HadoopHelperImpl method loadReplace.
/**
* {@inheritDoc}
*/
@Override
public byte[] loadReplace(InputStream in, final String originalName, final String replaceName) {
ClassReader rdr;
try {
rdr = new ClassReader(in);
} catch (IOException e) {
throw new RuntimeException(e);
}
ClassWriter w = new ClassWriter(Opcodes.ASM4);
rdr.accept(new RemappingClassAdapter(w, new Remapper() {
/**
*/
String replaceType = replaceName.replace('.', '/');
/**
*/
String nameType = originalName.replace('.', '/');
@Override
public String map(String type) {
if (type.equals(replaceType))
return nameType;
return type;
}
}), ClassReader.EXPAND_FRAMES);
return w.toByteArray();
}
use of org.objectweb.asm.commons.Remapper in project Lucee by lucee.
the class JarUtil method _getExternalImports.
private static void _getExternalImports(Set<String> imports, InputStream src, String[] ignores) throws IOException {
final ClassReader reader = new ClassReader(src);
final Remapper remapper = new Collector(imports, ignores);
final ClassVisitor inner = new EmptyVisitor();
final RemappingClassAdapter visitor = new RemappingClassAdapter(inner, remapper);
reader.accept(visitor, 0);
}
use of org.objectweb.asm.commons.Remapper in project wildfly-swarm by wildfly-swarm.
the class FaviconFactory method createFaviconServletExtension.
static byte[] createFaviconServletExtension(String name) throws IOException {
ClassReader reader = new ClassReader(FaviconServletExtension.class.getClassLoader().getResourceAsStream(FaviconServletExtension.class.getName().replace('.', '/') + ".class"));
String slashName = name.replace('.', '/');
ClassWriter writer = new ClassWriter(0);
Remapper remapper = new Remapper() {
@Override
public String map(String typeName) {
if (typeName.equals("org/wildfly/swarm/undertow/internal/FaviconServletExtension")) {
return slashName;
}
return super.map(typeName);
}
};
ClassRemapper adapter = new ClassRemapper(writer, remapper);
reader.accept(adapter, ClassReader.EXPAND_FRAMES);
writer.visitEnd();
return writer.toByteArray();
}
use of org.objectweb.asm.commons.Remapper in project wildfly-swarm by wildfly-swarm.
the class DefaultApplicationFactory method create.
public static byte[] create(String name, String path) throws IOException {
ClassReader reader = new ClassReader(basicClassBytes());
String slashName = name.replace('.', '/');
ClassWriter writer = new ClassWriter(0);
Remapper remapper = new Remapper() {
@Override
public String map(String typeName) {
if (typeName.equals("org/wildfly/swarm/jaxrs/runtime/DefaultApplication")) {
return slashName;
}
return super.map(typeName);
}
};
ClassRemapper adapter = new ClassRemapper(writer, remapper);
reader.accept(adapter, 0);
AnnotationVisitor ann = writer.visitAnnotation("Ljavax/ws/rs/ApplicationPath;", true);
ann.visit("value", path);
ann.visitEnd();
writer.visitEnd();
return writer.toByteArray();
}
use of org.objectweb.asm.commons.Remapper in project FoamFix by asiekierka.
the class FoamFixTransformer method replaceClasses.
public static ClassNode replaceClasses(final ClassNode nodeData, final byte[] dataSplice, final String className) {
System.out.println("replacing " + nodeData.name + " with " + className);
if (dataSplice == null) {
throw new RuntimeException("Class " + className + " not found! This is a FoamFix bug!");
}
final ClassReader readerSplice = new ClassReader(dataSplice);
final String className2 = className.replace('.', '/');
final String targetClassName2 = nodeData.name;
final String targetClassName = targetClassName2.replace('/', '.');
final Remapper remapper = new Remapper() {
public String map(final String name) {
return className2.equals(name) ? targetClassName2 : name;
}
};
ClassNode nodeSplice = new ClassNode();
readerSplice.accept(new ClassRemapper(nodeSplice, remapper), ClassReader.EXPAND_FRAMES);
return nodeSplice;
}
Aggregations