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


Java ClassRemapper类代码示例

本文整理汇总了Java中org.objectweb.asm.commons.ClassRemapper的典型用法代码示例。如果您正苦于以下问题:Java ClassRemapper类的具体用法?Java ClassRemapper怎么用?Java ClassRemapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassRemapper类属于org.objectweb.asm.commons包,在下文中一共展示了ClassRemapper类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFaviconServletExtension

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的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

示例2: createFaviconErrorHandler

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的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

示例3: create

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的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

示例4: applyMappings

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
public static void applyMappings(Map<String, ClassNode> classMap, Map<String, String> remap) {
	log.debug("Applying mappings [");
	for (Map.Entry<String, String> entry : remap.entrySet()) {
		String k = entry.getKey();
		String v = entry.getValue();
		if (k.equals(v))
			continue;
		// skip members with same name
		// field format =   [ "<owner>.<name>"          : "<newname>" ]
		// method format =  [ "<owner>.<name> <desc>"   : "<newname>" ]
		int n = k.indexOf('.');
		if (n != -1 && v.length() >= n && v.substring(n).equals(k)) {
			continue;
		}
		log.debug(" Map {} to {}", entry.getKey(), entry.getValue());
	}
	log.debug("]");
	SimpleRemapper remapper = new SimpleRemapper(remap);
	for (ClassNode node : new ArrayList<>(classMap.values())) {
		ClassNode copy = new ClassNode();
		ClassRemapper adapter = new ClassRemapper(copy, remapper);
		node.accept(adapter);
		classMap.put(node.name, copy);
	}
}
 
开发者ID:CalebWhiting,项目名称:java-asm-obfuscator,代码行数:26,代码来源:BytecodeHelper.java

示例5: UnprefixingClassWriter

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的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

示例6: transform

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
@Override
public final boolean transform() throws Throwable {
    CustomRemapper remapper = new CustomRemapper();

    remap(remapper);

    Map<String, ClassNode> updated = new HashMap<>();
    Set<String> removed = new HashSet<>();

    classNodes().forEach(wr -> {
        removed.add(wr.name);

        ClassNode newNode = new ClassNode();
        ClassRemapper classRemapper = new ClassRemapper(newNode, remapper);
        wr.accept(classRemapper);
        updated.put(newNode.name, newNode);

        getDeobfuscator().setConstantPool(newNode, getDeobfuscator().getConstantPool(wr));
    });

    removed.forEach(classes::remove);
    removed.forEach(classpath::remove);
    classes.putAll(updated);
    classpath.putAll(updated);
    getDeobfuscator().resetHierachy();
    return true;
}
 
开发者ID:java-deobfuscator,项目名称:deobfuscator,代码行数:28,代码来源:AbstractNormalizer.java

示例7: apply

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
private byte[] apply(final RClass cls) {
	ClassReader reader = new ClassReader(cls.data);
	ClassWriter writer = new ClassWriter(0);
	int flags = removeFrames ? ClassReader.SKIP_FRAMES : ClassReader.EXPAND_FRAMES;
	reader.accept(new ClassRemapper(check ? new CheckClassAdapter(writer) : writer, remapper), flags);
	// TODO: compute frames (-Xverify:all -XX:-FailOverToOldVerifier)

	return writer.toByteArray();
}
 
开发者ID:FabricMC,项目名称:tiny-remapper,代码行数:10,代码来源:TinyRemapper.java

示例8: findClass

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的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

示例9: testTransform

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
@Test
public void testTransform() throws Exception {
    ClassRename rule = new ClassRename("java.lang.String", "com.tonicsystems.String");
    ClassRemapper t = new ClassRemapper(null, new PackageRemapper(rule));
    ClassReader reader = new ClassReader(getClass().getResourceAsStream("/Generics.class"));
    reader.accept(t, 0);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:8,代码来源:GenericsTest.java

示例10: writeTo

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
/**
 * Creates a class visitor which weaves all changes and additions on the fly.
 *
 * @param classVisitor    The class visitor to which this entry is to be written to.
 * @param typeInitializer The type initializer to apply.
 * @param contextRegistry A context registry to register the lazily created implementation context to.
 * @param writerFlags     The writer flags being used.
 * @param readerFlags     The reader flags being used.
 * @return A class visitor which is capable of applying the changes.
 */
private ClassVisitor writeTo(ClassVisitor classVisitor,
                             TypeInitializer typeInitializer,
                             ContextRegistry contextRegistry,
                             int writerFlags,
                             int readerFlags) {
    classVisitor = new RedefinitionClassVisitor(classVisitor, typeInitializer, contextRegistry, writerFlags, readerFlags);
    return originalType.getName().equals(instrumentedType.getName())
            ? classVisitor
            : new ClassRemapper(classVisitor, new SimpleRemapper(originalType.getInternalName(), instrumentedType.getInternalName()));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:TypeWriter.java

示例11: wrap

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
@Override
public ClassVisitor wrap(TypeDescription instrumentedType,
                         ClassVisitor classVisitor,
                         Implementation.Context implementationContext,
                         TypePool typePool,
                         FieldList<FieldDescription.InDefinedShape> fields,
                         MethodList<?> methods,
                         int writerFlags,
                         int readerFlags) {
    return new ClassRemapper(classVisitor, new SimpleRemapper(oldName, newName));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:ByteArrayClassLoaderChildFirstTest.java

示例12: transform

import org.objectweb.asm.commons.ClassRemapper; //导入依赖的package包/类
@Override
public ClassVisitor transform(ClassVisitor v) {
    return new ClassRemapper(v, remapper);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:5,代码来源:RemappingClassTransformer.java


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