本文整理汇总了Java中org.objectweb.asm.commons.Remapper类的典型用法代码示例。如果您正苦于以下问题:Java Remapper类的具体用法?Java Remapper怎么用?Java Remapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Remapper类属于org.objectweb.asm.commons包,在下文中一共展示了Remapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
public ObfMapping map(Remapper mapper) {
if (mapper == null)
return this;
if (isMethod())
s_name = mapper.mapMethodName(s_owner, s_name, s_desc);
else if (isField())
s_name = mapper.mapFieldName(s_owner, s_name, s_desc);
s_owner = mapper.mapType(s_owner);
if (isMethod())
s_desc = mapper.mapMethodDesc(s_desc);
else if (s_desc.length() > 0)
s_desc = mapper.mapDesc(s_desc);
return this;
}
示例2: map
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
public ObfMapping map(Remapper mapper) {
if (mapper == null) {
return this;
}
if (isMethod()) {
s_name = mapper.mapMethodName(s_owner, s_name, s_desc);
} else if (isField()) {
s_name = mapper.mapFieldName(s_owner, s_name, s_desc);
}
s_owner = mapper.mapType(s_owner);
if (isMethod()) {
s_desc = mapper.mapMethodDesc(s_desc);
} else if (s_desc.length() > 0) {
s_desc = mapper.mapDesc(s_desc);
}
return this;
}
示例3: createFaviconServletExtension
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
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();
}
示例4: createFaviconErrorHandler
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
static byte[] createFaviconErrorHandler(String name) throws IOException {
ClassReader reader = new ClassReader(FaviconErrorHandler.class.getClassLoader().getResourceAsStream(FaviconErrorHandler.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/FaviconErrorHandler")) {
return slashName;
}
return super.map(typeName);
}
};
ClassRemapper adapter = new ClassRemapper(writer, remapper);
reader.accept(adapter, ClassReader.EXPAND_FRAMES);
writer.visitEnd();
return writer.toByteArray();
}
示例5: create
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
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();
}
示例6: map
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
public ObfMapping map(Remapper mapper) {
if (isMethod()) {
s_name = mapper.mapMethodName(s_owner, s_name, s_desc);
} else if (isField()) {
s_name = mapper.mapFieldName(s_owner, s_name, s_desc);
}
s_owner = mapper.mapType(s_owner);
if (isMethod()) {
s_desc = mapper.mapMethodDesc(s_desc);
} else if (s_desc.length() > 0) {
s_desc = mapper.mapDesc(s_desc);
}
return this;
}
示例7: create
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
static byte[] create(String name, String path) throws IOException {
ClassReader reader = new ClassReader(DefaultApplication.class.getClassLoader().getResourceAsStream(DefaultApplication.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/jaxrs/internal/DefaultApplication")) {
return slashName;
}
return super.map(typeName);
}
};
RemappingClassAdapter adapter = new RemappingClassAdapter(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();
}
示例8: create
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
static byte[] create() throws IOException {
ClassReader reader = new ClassReader(FaviconExceptionMapper.class.getClassLoader().getResourceAsStream(FaviconExceptionMapper.class.getName().replace('.', '/') + ".class"));
ClassWriter writer = new ClassWriter(0);
Remapper remapper = new Remapper() {
@Override
public String map(String typeName) {
if (typeName.equals("org/wildfly/swarm/jaxrs/internal/FaviconExceptionMapper")) {
return "org/wildfly/swarm/generated/FaviconExceptionMapper";
}
return super.map(typeName);
}
};
RemappingClassAdapter adapter = new RemappingClassAdapter(writer, remapper);
reader.accept(adapter, 0);
writer.visitAnnotation("Ljavax/ws/rs/ext/Provider;", true).visitEnd();
writer.visitEnd();
return writer.toByteArray();
}
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:23,代码来源:FaviconExceptionMapperFactory.java
示例9: CloseResourceMethodSpecializer
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
public CloseResourceMethodSpecializer(
ClassVisitor cv, String targetResourceInternalName, boolean isResourceAnInterface) {
super(
cv,
new Remapper() {
@Override
public String map(String typeName) {
if (typeName.equals("java/lang/AutoCloseable")) {
return targetResourceInternalName;
} else {
return typeName;
}
}
});
this.targetResourceInternalName = targetResourceInternalName;
this.isResourceAnInterface = isResourceAnInterface;
}
示例10: UnprefixingClassWriter
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
UnprefixingClassWriter(int flags) {
super(Opcodes.ASM6);
this.writer = new ClassWriter(flags);
this.cv = this.writer;
if (!prefix.isEmpty()) {
this.cv =
new ClassRemapper(
this.writer,
new Remapper() {
@Override
public String map(String typeName) {
return unprefix(typeName);
}
});
}
}
示例11: map
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
public ObfMapping map(Remapper mapper)
{
if(isMethod())
s_name = mapper.mapMethodName(s_owner, s_name, s_desc);
else if(isField())
s_name = mapper.mapFieldName(s_owner, s_name, s_desc);
s_owner = mapper.mapType(s_owner);
if(isMethod())
s_desc = mapper.mapMethodDesc(s_desc);
else if(s_desc.length() > 0)
s_desc = mapper.mapDesc(s_desc);
return this;
}
示例12: BackportingTypeRemapper
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
BackportingTypeRemapper(ClassVisitor cv) {
super(ASM5, cv, new Remapper() {
@Override public String map(String type) {
String remap = TYPES.get(type);
if (remap != null) {
System.out.println(" Mapping type " + type + " to " + remap);
return remap;
}
return type;
}
});
}
示例13: loadClassFromFile
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
private Class<?> loadClassFromFile(final String className)
throws IOException {
String relativePath = classNameToRelativePath(className);
File file = classesRootDirPath.resolve(relativePath).toFile();
byte[] bytes = FileUtils.readFileToByteArray(file);
final String newClassName = className + System.currentTimeMillis();
final String newClassInternalName = newClassName.replaceAll("\\.", "/");
final String classInternalName = className.replaceAll("\\.", "/");
ClassReader classReader = new ClassReader(bytes);
ClassWriter classWriter = new ClassWriter(classReader,
ClassWriter.COMPUTE_MAXS);
RemappingClassAdapter remappingClassAdapter = new RemappingClassAdapter(
classWriter, new Remapper() {
@Override
public String map(String type) {
if (classInternalName.equals(type)) {
return newClassInternalName;
} else {
return type;
}
}
});
classReader.accept(remappingClassAdapter, Opcodes.ASM5 | ClassReader.EXPAND_FRAMES);
byte[] newBytes = classWriter.toByteArray();
Class<?> klass = defineClass(newClassName, newBytes, 0, newBytes.length);
classNameToClass.put(className, klass);
return klass;
}
示例14: findClass
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
for (Entry<String, String> mapping : remappings.entrySet()) {
if (name.equals(mapping.getValue())) {
String path = mapping.getKey().replace('.', '/').concat(".class");
try {
try (InputStream resource = getResourceAsStream(path)) {
ClassReader reader = new ClassReader(resource);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassVisitor visitor = new ClassRemapper(writer, new Remapper() {
@Override
public String map(String from) {
String to = remappings.get(from.replace('/', '.'));
if (to == null) {
return from;
} else {
return to.replace('.', '/');
}
}
});
reader.accept(visitor, ClassReader.EXPAND_FRAMES);
byte[] classBytes = writer.toByteArray();
return defineClass(name, classBytes, 0, classBytes.length);
}
} catch (IOException e) {
throw new ClassNotFoundException("IOException while loading", e);
}
}
}
return super.findClass(name);
}
示例15: copyAndRenameMethod
import org.objectweb.asm.commons.Remapper; //导入依赖的package包/类
/**
* Copy a method and rename it; everything else will be exactly the same
* @return The renamed method copy
*/
public static MethodNode copyAndRenameMethod(ClassNode classNode, MethodNode method, String newMethodName)
{
MethodVisitor methodCopyVisitor = classNode.visitMethod(method.access, newMethodName, method.desc, method.signature, method.exceptions.toArray(new String[method.exceptions.size()]));
method.accept(new RemappingMethodAdapter(method.access, method.desc, methodCopyVisitor, new Remapper(){}));
return methodCopyVisitor instanceof MethodNode ? (MethodNode) methodCopyVisitor : null;
}