當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。