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


Java RemappingMethodAdapter类代码示例

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


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

示例1: transform

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
public static byte[] transform(byte[] bytes) {
    ClassNode cnode = ASMHelper.createClassNode(bytes, ClassReader.EXPAND_FRAMES);

    boolean changed = false;
    Iterator<MethodNode> it = cnode.methods.iterator();
    while(it.hasNext()) {
        MethodNode mnode = it.next();
        ReferenceDetector r = new ReferenceDetector();
        mnode.accept(new RemappingMethodAdapter(mnode.access, mnode.desc, new MethodVisitor(Opcodes.ASM4) {}, r));
        if(r.found) {
            it.remove();
            changed = true;
        }
    }
    if(changed)
        bytes = ASMHelper.createBytes(cnode, 0);
    return bytes;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:19,代码来源:MCStripTransformer.java

示例2: transform

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
public static byte[] transform(byte[] bytes) {
    ClassNode cnode = ASMHelper.createClassNode(bytes, ClassReader.EXPAND_FRAMES);

    boolean changed = false;
    Iterator<MethodNode> it = cnode.methods.iterator();
    while (it.hasNext()) {
        MethodNode mnode = it.next();
        ReferenceDetector r = new ReferenceDetector();
        mnode.accept(new RemappingMethodAdapter(mnode.access, mnode.desc, new MethodVisitor(Opcodes.ASM4) {
        }, r));
        if (r.found) {
            it.remove();
            changed = true;
        }
    }
    if (changed) {
        bytes = ASMHelper.createBytes(cnode, 0);
    }
    return bytes;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:21,代码来源:MCStripTransformer.java

示例3: visitEnd

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
@Override
public void visitEnd() {
  // add all the fields of the class we're going to merge.
  for (Iterator<?> it = classToMerge.fields.iterator(); it.hasNext();) {
    ((FieldNode) it.next()).accept(this);
  }

  // add all the methods that we to include.
  for (Iterator<?> it = classToMerge.methods.iterator(); it.hasNext();) {
    MethodNode mn = (MethodNode) it.next();

    if (mn.name.equals("<init>")) {
      continue;
    }

    String[] exceptions = new String[mn.exceptions.size()];
    mn.exceptions.toArray(exceptions);
    MethodVisitor mv = cv.visitMethod(mn.access | Modifier.FINAL, mn.name, mn.desc, mn.signature, exceptions);
    if (verifyBytecode) {
      mv = new CheckMethodVisitorFsm(api, mv);
    }

    mn.instructions.resetLabels();

    // mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, new
    // SimpleRemapper("org.apache.drill.exec.compile.ExampleTemplate", "Bunky")));
    ClassSet top = set;
    while (top.parent != null) {
      top = top.parent;
    }
    mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv,
        new SimpleRemapper(top.precompiled.slash, top.generated.slash)));

  }
  super.visitEnd();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:37,代码来源:MergeAdapter.java

示例4: copyAndRenameMethod

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

示例5: addMethod

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
/**
 * Adds the method to the base class
 * @param methodNode
 */
private void addMethod(MethodNode methodNode){
	String[] exceptions = new String[methodNode.exceptions.size()];
	methodNode.exceptions.toArray(exceptions);
	MethodVisitor mv = cv.visitMethod(methodNode.access, methodNode.name, methodNode.desc, methodNode.signature, exceptions);

	methodNode.instructions.resetLabels();
	// SimpleRemapper -> maps old name to new name
	// updates owners and descriptions appropriately
	methodNode.accept(new RemappingMethodAdapter(methodNode.access, methodNode.desc, mv, new SimpleRemapper(classToMerge.name, baseClassName)));
}
 
开发者ID:JReFrameworker,项目名称:JReFrameworker,代码行数:15,代码来源:MergeAdapter.java

示例6: createRemappingMethodAdapter

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
protected MethodVisitor createRemappingMethodAdapter(
        int access,
        String newDesc,
        MethodVisitor mv) {
    return new RemappingMethodAdapter(access, newDesc, mv, remapper) {
        @Override
        public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
            if (name.equals("<init>") && isObject && owner.equals("java/lang/Object")) {
                return;
            }

            super.visitMethodInsn(opcode, owner, stripMethodSuffix(name), desc, itf);
        }
    };
}
 
开发者ID:erkieh,项目名称:proxyhotswap,代码行数:16,代码来源:TestClassAdapter.java

示例7: createRemappingMethodAdapter

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
protected MethodVisitor createRemappingMethodAdapter(int access, String newDesc, MethodVisitor mv) {
	return new RemappingMethodAdapter(access, newDesc, mv, remapper) {
		@Override
		public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
			if (name.equals("<init>") && isObject && owner.equals("java/lang/Object")) {
				return;
			}
			
			super.visitMethodInsn(opcode, owner, stripMethodSuffix(name), desc, itf);
		}
	};
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:13,代码来源:TestClassAdapter.java

示例8: visitEnd

import org.objectweb.asm.commons.RemappingMethodAdapter; //导入依赖的package包/类
@Override
public void visitEnd() {
  // add all the fields of the class we're going to merge.
  for (Iterator<?> it = classToMerge.fields.iterator(); it.hasNext();) {

    // Special handling for nested classes. Drill uses non-static nested
    // "inner" classes in some templates. Prior versions of Drill would
    // create the generated nested classes as static, then this line
    // would copy the "this$0" field to convert the static nested class
    // into a non-static inner class. However, that approach is not
    // compatible with plain-old Java compilation. Now, Drill generates
    // the nested classes as non-static inner classes. As a result, we
    // do not want to copy the hidden fields; we'll end up with two if
    // we do.

    FieldNode field = (FieldNode) it.next();
    if (! field.name.startsWith("this$")) {
      field.accept(this);
    }
  }

  // add all the methods that we to include.
  for (Iterator<?> it = classToMerge.methods.iterator(); it.hasNext();) {
    MethodNode mn = (MethodNode) it.next();

    if (mn.name.equals("<init>")) {
      continue;
    }

    String[] exceptions = new String[mn.exceptions.size()];
    mn.exceptions.toArray(exceptions);
    MethodVisitor mv = cv.visitMethod(mn.access | Modifier.FINAL, mn.name, mn.desc, mn.signature, exceptions);
    if (verifyBytecode) {
      mv = new CheckMethodVisitorFsm(api, mv);
    }

    mn.instructions.resetLabels();

    // mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, new
    // SimpleRemapper("org.apache.drill.exec.compile.ExampleTemplate", "Bunky")));
    ClassSet top = set;
    while (top.parent != null) {
      top = top.parent;
    }
    mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv,
        new SimpleRemapper(top.precompiled.slash, top.generated.slash)));

  }
  super.visitEnd();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:51,代码来源:MergeAdapter.java


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