当前位置: 首页>>代码示例>>Java>>正文


Java Remapper类代码示例

本文整理汇总了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;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:19,代码来源:ObfMapping.java

示例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;
    }
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:23,代码来源:ObfMapping.java

示例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();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:24,代码来源:FaviconFactory.java

示例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();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:24,代码来源:FaviconFactory.java

示例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();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:27,代码来源:DefaultApplicationFactory.java

示例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;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:18,代码来源:ObfMapping.java

示例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();
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:27,代码来源:ApplicationFactory2.java

示例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;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:18,代码来源:TryWithResourcesRewriter.java

示例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);
              }
            });
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:17,代码来源:CoreLibraryRewriter.java

示例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;
}
 
开发者ID:Chicken-Bones,项目名称:CCObfuscator,代码行数:17,代码来源:ObfMapping.java

示例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;
    }
  });
}
 
开发者ID:JakeWharton,项目名称:RxJava2-Java6,代码行数:13,代码来源:BackportingTypeRemapper.java

示例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;
}
 
开发者ID:Xianguang-Zhou,项目名称:java-hot-update,代码行数:32,代码来源:HotUpdateClassLoader.java

示例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);
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:36,代码来源:SerializablePortabilityTestUtilities.java

示例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;
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:11,代码来源:ASMHelper.java


注:本文中的org.objectweb.asm.commons.Remapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。