本文整理匯總了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;
}