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


Java MethodVisitor类代码示例

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


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

示例1: visitMethod

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(final int access, final String name,
        final String desc, final String signature, final String[] exceptions) {
    MethodVisitor mv;
    if ("<clinit>".equals(name)) {
        int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;
        String n = prefix + counter++;
        mv = cv.visitMethod(a, n, desc, signature, exceptions);

        if (clinit == null) {
            clinit = cv.visitMethod(a, name, desc, null, null);
        }
        clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc,
                false);
    } else {
        mv = cv.visitMethod(access, name, desc, signature, exceptions);
    }
    return mv;
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:20,代码来源:StaticInitMerger.java

示例2: accept

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
/**
 * Makes the given visitor visit this stack map frame.
 * 
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:29,代码来源:FrameNode.java

示例3: begin

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public void begin(final String name, final Attributes attrs) {
    String desc = attrs.getValue("desc");
    boolean visible = Boolean.valueOf(attrs.getValue("visible"))
            .booleanValue();
    int typeRef = Integer.parseInt(attrs.getValue("typeRef"));
    TypePath typePath = TypePath.fromString(attrs.getValue("typePath"));

    Object v = peek();
    if (v instanceof ClassVisitor) {
        push(((ClassVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof FieldVisitor) {
        push(((FieldVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof MethodVisitor) {
        push(((MethodVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    }
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:21,代码来源:ASMContentHandler.java

示例4: ASMAccessorOptimizer

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
private ASMAccessorOptimizer(ClassWriter cw, MethodVisitor mv,
                             ArrayList<ExecutableStatement> compiledInputs, String className, StringAppender buildLog, int compileDepth) {
    this.cw = cw;
    this.mv = mv;
    this.compiledInputs = compiledInputs;
    this.className = className;
    this.buildLog = buildLog;
    this.compileDepth = compileDepth + 1;

    noinit = true;
    deferFinish = true;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:13,代码来源:ASMAccessorOptimizer.java

示例5: _initJIT

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
/**
 * Does all the boilerplate for initiating the JIT.
 */
private void _initJIT() {
    if (isAdvancedDebugging()) {
        buildLog = new StringAppender();
    }

    cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

    synchronized (Runtime.getRuntime()) {
        cw.visit(OPCODES_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className = "ASMAccessorImpl_"
                + valueOf(cw.hashCode()).replaceAll("\\-", "_") + (System.currentTimeMillis() / 10) +
                ((int) Math.random() * 100),
                null, "java/lang/Object", new String[]{NAMESPACE + "compiler/Accessor"});
    }

    MethodVisitor m = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);

    m.visitCode();
    m.visitVarInsn(Opcodes.ALOAD, 0);
    m.visitMethodInsn(INVOKESPECIAL, "java/lang/Object",
            "<init>", "()V");
    m.visitInsn(RETURN);

    m.visitMaxs(1, 1);
    m.visitEnd();

    (mv = cw.visitMethod(ACC_PUBLIC, "getValue",
            "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE
                    + "integration/VariableResolverFactory;)Ljava/lang/Object;", null, null)).visitCode();
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:33,代码来源:ASMAccessorOptimizer.java

示例6: _initJIT2

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
private void _initJIT2() {
    if (isAdvancedDebugging()) {
        buildLog = new StringAppender();
    }

    cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

    synchronized (Runtime.getRuntime()) {
        cw.visit(OPCODES_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className = "ASMAccessorImpl_"
                + valueOf(cw.hashCode()).replaceAll("\\-", "_") + (System.currentTimeMillis() / 10) +
                ((int) Math.random() * 100),
                null, "java/lang/Object", new String[]{NAMESPACE + "compiler/Accessor"});
    }

    MethodVisitor m = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);

    m.visitCode();
    m.visitVarInsn(Opcodes.ALOAD, 0);
    m.visitMethodInsn(INVOKESPECIAL, "java/lang/Object",
            "<init>", "()V");
    m.visitInsn(RETURN);

    m.visitMaxs(1, 1);
    m.visitEnd();

    (mv = cw.visitMethod(ACC_PUBLIC, "setValue",
            "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE
                    + "integration/VariableResolverFactory;Ljava/lang/Object;)Ljava/lang/Object;", null, null)).visitCode();
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:30,代码来源:ASMAccessorOptimizer.java

示例7: produceBytecodePut

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
public void produceBytecodePut(MethodVisitor mv, String propertyName, VariableResolverFactory factory) {
    mv.visitTypeInsn(CHECKCAST, "java/util/List");
    mv.visitInsn(ICONST_0);
    mv.visitLdcInsn("set");
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "set", "(ILjava/lang/Object;)Ljava/lang/Object;");
    mv.visitInsn(POP);
    mv.visitInsn(ACONST_NULL);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:9,代码来源:PropertyHandlerTests.java

示例8: ASMAccessorOptimizer

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
private ASMAccessorOptimizer(ClassWriter cw, MethodVisitor mv,
                             ArrayList<ExecutableStatement> compiledInputs, String className,
                             StringAppender buildLog, int compileDepth) {
  this.cw = cw;
  this.mv = mv;
  this.compiledInputs = compiledInputs;
  this.className = className;
  this.buildLog = buildLog;
  this.compileDepth = compileDepth + 1;

  noinit = true;
  deferFinish = true;
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:14,代码来源:ASMAccessorOptimizer.java

示例9: _initJIT

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
/**
 * Does all the boilerplate for initiating the JIT.
 */
private void _initJIT() {
  if (isAdvancedDebugging()) {
    buildLog = new StringAppender();
  }

  cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

  synchronized (Runtime.getRuntime()) {
    cw.visit(OPCODES_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className = "ASMAccessorImpl_"
        + valueOf(cw.hashCode()).replaceAll("\\-", "_") + (System.currentTimeMillis() / 10) +
        ((int) Math.random() * 100),
        null, "java/lang/Object", new String[]{NAMESPACE + "compiler/Accessor"});
  }

  MethodVisitor m = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);

  m.visitCode();
  m.visitVarInsn(Opcodes.ALOAD, 0);
  m.visitMethodInsn(INVOKESPECIAL, "java/lang/Object",
      "<init>", "()V");
  m.visitInsn(RETURN);

  m.visitMaxs(1, 1);
  m.visitEnd();

  (mv = cw.visitMethod(ACC_PUBLIC, "getValue",
      "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE
          + "integration/VariableResolverFactory;)Ljava/lang/Object;", null, null)).visitCode();
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:33,代码来源:ASMAccessorOptimizer.java

示例10: _initJIT2

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
private void _initJIT2() {
  if (isAdvancedDebugging()) {
    buildLog = new StringAppender();
  }

  cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

  synchronized (Runtime.getRuntime()) {
    cw.visit(OPCODES_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className = "ASMAccessorImpl_"
        + valueOf(cw.hashCode()).replaceAll("\\-", "_") + (System.currentTimeMillis() / 10) +
        ((int) Math.random() * 100),
        null, "java/lang/Object", new String[]{NAMESPACE + "compiler/Accessor"});
  }

  MethodVisitor m = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);

  m.visitCode();
  m.visitVarInsn(Opcodes.ALOAD, 0);
  m.visitMethodInsn(INVOKESPECIAL, "java/lang/Object",
      "<init>", "()V");
  m.visitInsn(RETURN);

  m.visitMaxs(1, 1);
  m.visitEnd();

  (mv = cw.visitMethod(ACC_PUBLIC, "setValue",
      "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE
          + "integration/VariableResolverFactory;Ljava/lang/Object;)Ljava/lang/Object;", null, null)).visitCode();
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:30,代码来源:ASMAccessorOptimizer.java

示例11: visitMethod

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(final int access, final String name,
        final String desc, final String signature, final String[] exceptions) {
    if (computeSVUID) {
        if ("<clinit>".equals(name)) {
            hasStaticInitializer = true;
        }
        /*
         * Remembers non private constructors and methods for SVUID
         * computation For constructor and method modifiers, only the
         * ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
         * ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and ACC_STRICT flags
         * are used.
         */
        int mods = access
                & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
                        | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
                        | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED
                        | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT);

        // all non private methods
        if ((access & Opcodes.ACC_PRIVATE) == 0) {
            if ("<init>".equals(name)) {
                svuidConstructors.add(new Item(name, mods, desc));
            } else if (!"<clinit>".equals(name)) {
                svuidMethods.add(new Item(name, mods, desc));
            }
        }
    }

    return super.visitMethod(access, name, desc, signature, exceptions);
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:33,代码来源:SerialVersionUIDAdder.java

示例12: visitMethod

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
    String newDesc = remapper.mapMethodDesc(desc);
    MethodVisitor mv = super.visitMethod(access, remapper.mapMethodName(
            className, name, desc), newDesc, remapper.mapSignature(
            signature, false),
            exceptions == null ? null : remapper.mapTypes(exceptions));
    return mv == null ? null : createRemappingMethodAdapter(access,
            newDesc, mv);
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:12,代码来源:RemappingClassAdapter.java

示例13: visitMethod

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(final int access, final String name,
        final String desc, final String signature, final String[] exceptions) {
    MethodNode mn = new MethodNode(access, name, desc, signature,
            exceptions);
    methods.add(mn);
    return mn;
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:9,代码来源:ClassNode.java

示例14: accept

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
/**
 * Makes the given visitor visit all of the instructions in this list.
 * 
 * @param mv
 *            the method visitor that must visit the instructions.
 */
public void accept(final MethodVisitor mv) {
    AbstractInsnNode insn = first;
    while (insn != null) {
        insn.accept(mv);
        insn = insn.next;
    }
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:14,代码来源:InsnList.java

示例15: accept

import org.mvel2.asm.MethodVisitor; //导入依赖的package包/类
@Override
public void accept(final MethodVisitor mv) {
    int[] keys = new int[this.keys.size()];
    for (int i = 0; i < keys.length; ++i) {
        keys[i] = this.keys.get(i).intValue();
    }
    Label[] labels = new Label[this.labels.size()];
    for (int i = 0; i < labels.length; ++i) {
        labels[i] = this.labels.get(i).getLabel();
    }
    mv.visitLookupSwitchInsn(dflt.getLabel(), keys, labels);
    acceptAnnotations(mv);
}
 
开发者ID:osswangxining,项目名称:mvel-jsr223,代码行数:14,代码来源:LookupSwitchInsnNode.java


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