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


Java LocalVariablesSorter类代码示例

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


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

示例1: visitMethod

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
/**
 * For each method in the class being instrumented, <code>visitMethod</code>
 * is called and the returned MethodVisitor is used to visit the method.
 * Note that a new MethodVisitor is constructed for each method.
 */
@Override
public MethodVisitor visitMethod(int access, String base, String desc,
    String signature, String[] exceptions) {
  MethodVisitor mv =
    cv.visitMethod(access, base, desc, signature, exceptions);

  if (mv != null) {
    // We need to compute stackmaps (see
    // AllocationInstrumenter#instrument).  This can't really be
    // done for old bytecode that contains JSR and RET instructions.
    // So, we remove JSRs and RETs.
    JSRInlinerAdapter jsria = new JSRInlinerAdapter(
        mv, access, base, desc, signature, exceptions);
    AllocationMethodAdapter aimv =
      new AllocationMethodAdapter(jsria, recorderClass, recorderMethod);
    LocalVariablesSorter lvs = new LocalVariablesSorter(access, desc, aimv);
    aimv.lvs = lvs;
    mv = lvs;
  }
  return mv;
}
 
开发者ID:google,项目名称:allocation-instrumenter,代码行数:27,代码来源:AllocationClassAdapter.java

示例2: generateTraverseMethod

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
private void generateTraverseMethod() {
	LocalVariablesSorter mv = new LocalVariablesSorter(
			TRAVERSE_METHOD_ACC_FLAGS,
			TRAVERSE_METHOD_DESC,
			this.visitMethod(
					this.getTraverseMethodAccess(),
					this.getTraverseMethodName(),
					TRAVERSE_METHOD_DESC,
					null,
					null));
	mv.visitCode();

	if (isAllowed(this.thisClass.getFqn())) {
		this.generateTraverseMethodPreamble(mv);

		if (!this.fields.isEmpty()) {
			for (Pair<String, String> field : this.fields) {
				this.generateFieldAccess(mv, field);
			}
		}
	}
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
}
 
开发者ID:plum-umd,项目名称:rubah,代码行数:26,代码来源:AddTraverseMethod.java

示例3: visitMethod

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
/**
 * For each method in the class being instrumented,
 * <code>visitMethod</code> is called and the returned
 * MethodVisitor is used to visit the method.  Note that a new
 * MethodVisitor is constructed for each method.
 */
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
    String signature, String[] exceptions) {
  MethodVisitor mv =
    cv.visitMethod(access, name, desc, signature, exceptions);

  if ((mv != null) && "<init>".equals(name)){
    ConstructorMethodAdapter aimv = new ConstructorMethodAdapter(mv, cl);
    LocalVariablesSorter lvs = new LocalVariablesSorter(access, desc, aimv);
    aimv.lvs = lvs;
    mv = lvs;
  }
  return mv;
}
 
开发者ID:google,项目名称:allocation-instrumenter,代码行数:21,代码来源:ConstructorInstrumenter.java

示例4: newLocalVarsFromTypes

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
private static ArrayList<Integer> newLocalVarsFromTypes(
    ArrayList<Type> types, LocalVariablesSorter lvs) {
  ArrayList<Integer> vars = new ArrayList<Integer>();
  for (Type type : types) {
    vars.add(lvs.newLocal(type));
  }
  return vars;
}
 
开发者ID:google,项目名称:java-thread-sanitizer,代码行数:9,代码来源:LocalVarsSaver.java

示例5: generateFieldAccess

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
protected void generateFieldAccess(LocalVariablesSorter mv, Pair<String, String> field) {
	Type fieldType = Type.getType(field.getValue1());

	if (!isAllowed(fieldType.getClassName())) {
		return;
	}

	this.getFieldOwner(mv);
	mv.visitInsn(DUP);

	mv.visitFieldInsn(
			GETFIELD,
			this.thisClass.getASMType().getInternalName(),
			field.getValue0(),
			field.getValue1());
	mv.visitMethodInsn(
			INVOKESTATIC,
			REGISTER_METHOD_OWNER_NAME,
			REGISTER_METHOD_NAME,
			REGISTER_METHOD_SIMPLE_DESC,
			false);
	if (this.version != null) {
		mv.visitTypeInsn(CHECKCAST, this.version.eraseUpdatableType(this.namespace.getClass(fieldType)).getASMType().getInternalName());
	} else {
		mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
	}
	mv.visitFieldInsn(
			PUTFIELD,
			this.thisClass.getASMType().getInternalName(),
			field.getValue0(),
			field.getValue1());
}
 
开发者ID:plum-umd,项目名称:rubah,代码行数:33,代码来源:AddTraverseMethod.java

示例6: visitMethod

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
    return methods == null || methods.contains(new ObfMapping(owner, name, desc)) ? new LocalVariablesSorter(access, desc, mv) : mv;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:6,代码来源:LocalVariablesSorterVisitor.java

示例7: InliningAdapter

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
public InliningAdapter(LocalVariablesSorter mv, int access, String desc, Label end) {
    super(Opcodes.ASM5, access, desc, mv);
    this.end = end;
    this.lvs = mv;
}
 
开发者ID:ruediste,项目名称:lambda-peg-parser,代码行数:6,代码来源:InliningAdapter.java

示例8: LocalVarsSaver

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
public LocalVarsSaver(MethodVisitor mv, LocalVariablesSorter lvs) {
  this.mv = mv;
  this.lvs = lvs;
}
 
开发者ID:google,项目名称:java-thread-sanitizer,代码行数:5,代码来源:LocalVarsSaver.java

示例9: setLocalVarsSorter

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
public void setLocalVarsSorter(LocalVariablesSorter lvs) {
  localVarsSorter = lvs;
}
 
开发者ID:google,项目名称:java-thread-sanitizer,代码行数:4,代码来源:MethodTransformer.java

示例10: visitMethod

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
		String signature, String[] exceptions) {

	if (name.equals(ProcessUpdateClass.METHOD_NAME) || name.equals(ProcessUpdateClass.METHOD_NAME_STATIC))
		return this.cv.visitMethod(access, name, desc, signature, exceptions);

	MethodVisitor ret = new MethodVisitor(ASM5) { };

	if (Modifier.isStatic(access))
		return ret;

	LocalVariablesSorter mv = new LocalVariablesSorter(
			access,
			desc,
			this.cv.visitMethod(METHOD_ACCESS, name, desc, signature, exceptions));

	String ownerName = this.owner.getASMType().getInternalName();

	int newObjectVar = mv.newLocal(OBJECT_TYPE.getASMType());

	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(
			INVOKESTATIC,
			RUBAH_TYPE.getInternalName(),
			"getConverted",
			Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE),
			false);
	mv.visitTypeInsn(CHECKCAST, ownerName);

	int arg = 1;

	for (Type t : Type.getArgumentTypes(desc)) {
		mv.visitVarInsn(t.getOpcode(ILOAD), arg);
		arg += t.getSize();
	}

	mv.visitMethodInsn(
			INVOKEVIRTUAL,
			ownerName,
			name,
			desc,
			false);
	mv.visitInsn(Type.getReturnType(desc).getOpcode(IRETURN));

	mv.visitMaxs(0, 0);
	mv.visitEnd();

	return ret;
}
 
开发者ID:plum-umd,项目名称:rubah,代码行数:52,代码来源:ProxyGenerator.java

示例11: testReaderHint

import org.objectweb.asm.commons.LocalVariablesSorter; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testReaderHint() throws Exception {
    AsmVisitorWrapper asmVisitorWrapper = mock(AsmVisitorWrapper.class);
    when(asmVisitorWrapper.wrap(any(TypeDescription.class),
            any(ClassVisitor.class),
            any(Implementation.Context.class),
            any(TypePool.class),
            any(FieldList.class),
            any(MethodList.class),
            anyInt(),
            anyInt())).then(new Answer<ClassVisitor>() {
        @Override
        public ClassVisitor answer(InvocationOnMock invocationOnMock) throws Throwable {
            return new ClassVisitor(Opcodes.ASM6, (ClassVisitor) invocationOnMock.getArguments()[1]) {
                @Override
                public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
                    return new LocalVariablesSorter(access, desc, super.visitMethod(access, name, desc, signature, exceptions));
                }
            };
        }
    });
    when(asmVisitorWrapper.mergeWriter(0)).thenReturn(ClassWriter.COMPUTE_MAXS);
    when(asmVisitorWrapper.mergeReader(0)).thenReturn(ClassReader.EXPAND_FRAMES);
    Class<?> type = create(StackMapFrames.class)
            .visit(asmVisitorWrapper)
            .make()
            .load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER)
            .getLoaded();
    assertThat(type.getDeclaredMethod(FOO).invoke(type.getDeclaredConstructor().newInstance()), is((Object) BAR));
    verify(asmVisitorWrapper).mergeWriter(0);
    verify(asmVisitorWrapper).mergeReader(0);
    verify(asmVisitorWrapper).wrap(any(TypeDescription.class),
            any(ClassVisitor.class),
            any(Implementation.Context.class),
            any(TypePool.class),
            any(FieldList.class),
            any(MethodList.class),
            anyInt(),
            anyInt());
    verifyNoMoreInteractions(asmVisitorWrapper);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:43,代码来源:AbstractDynamicTypeBuilderForInliningTest.java


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