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


Java ClassVisitor.visitMethod方法代码示例

本文整理汇总了Java中jdk.internal.org.objectweb.asm.ClassVisitor.visitMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ClassVisitor.visitMethod方法的具体用法?Java ClassVisitor.visitMethod怎么用?Java ClassVisitor.visitMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.internal.org.objectweb.asm.ClassVisitor的用法示例。


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

示例1: addGetter

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ClassGenerator.java

示例2: addSetter

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:ClassGenerator.java

示例3: accept

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
/**
 * Makes the given class visitor visit this method.
 *
 * @param cv
 *            a class visitor.
 */
public void accept(final ClassVisitor cv) {
    String[] exceptions = new String[this.exceptions.size()];
    this.exceptions.toArray(exceptions);
    MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
            exceptions);
    if (mv != null) {
        accept(mv);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:MethodNode.java

示例4: makeConstructor

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
static MethodGenerator makeConstructor(final ClassVisitor cv) {
    final int access = 0;
    final String name = INIT;
    final String desc = DEFAULT_INIT_DESC;
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    return new MethodGenerator(mv, access, name, desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ClassGenerator.java

示例5: Method

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
public Method(ClassConstruct ownerClass, ClassVisitor cv, String name, String descriptor, int access,
              ClassBuilder.ExecutionMode execMode) {
    this.ownerClassName = ownerClass.getName();
    this.ownerClass = ownerClass;
    this.execMode = execMode;
    this.cv = cv;
    mv = cv.visitMethod(access, name, descriptor, null, null);
    mv.visitCode();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Method.java

示例6: generateTestMethod

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
private static void generateTestMethod(ClassVisitor cv,
        Label unstableIfLocation) {
    MethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME,
            "(Z)V", null, null);
    mv.visitCode();

    Label end = new Label();
    Label falseBranch = new Label();

    // push "field" field's value and 1 to stack
    mv.visitFieldInsn(GETSTATIC, CLASS_NAME, FIELD_NAME, "I");
    mv.visitInsn(ICONST_1);
    // load argument's value
    mv.visitVarInsn(ILOAD, 0); // alwaysTrue
    // here is our unstable if
    mv.visitLabel(unstableIfLocation);
    mv.visitJumpInsn(IFEQ, falseBranch);
    // increment on "true"
    mv.visitInsn(IADD);
    mv.visitJumpInsn(GOTO, end);
    // decrement on "false"
    mv.visitLabel(falseBranch);
    mv.visitInsn(ISUB);
    mv.visitLabel(end);
    // bye bye
    mv.visitInsn(RETURN);

    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestUnstableIfTrap.java

示例7: Method

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
public Method(ClassConstruct ownerClass, ClassVisitor cv, String name, String descriptor, int access,
              ClassBuilder.ExecutionMode execMode) {
    this.ownerClassName = ownerClass.getName();
    this.ownerClass = ownerClass;
    this.isInterface = ownerClass.isInterface();
    this.execMode = execMode;
    this.cv = cv;
    mv = cv.visitMethod(access, name, descriptor, null, null);
    mv.visitCode();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:Method.java

示例8: makeStaticInitializer

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
static MethodGenerator makeStaticInitializer(final ClassVisitor cv, final String name) {
    final int access =  ACC_PUBLIC | ACC_STATIC;
    final String desc = DEFAULT_INIT_DESC;
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    return new MethodGenerator(mv, access, name, desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ClassGenerator.java

示例9: makeMethod

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
static MethodGenerator makeMethod(final ClassVisitor cv, final int access, final String name, final String desc) {
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    return new MethodGenerator(mv, access, name, desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:ClassGenerator.java

示例10: GeneratorAdapter

import jdk.internal.org.objectweb.asm.ClassVisitor; //导入方法依赖的package包/类
/**
 * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this
 * constructor</i>. Instead, they must use the
 * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)}
 * version.
 *
 * @param access
 *            access flags of the adapted method.
 * @param method
 *            the adapted method.
 * @param signature
 *            the signature of the adapted method (may be <tt>null</tt>).
 * @param exceptions
 *            the exceptions thrown by the adapted method (may be
 *            <tt>null</tt>).
 * @param cv
 *            the class visitor to which this adapter delegates calls.
 */
public GeneratorAdapter(final int access, final Method method,
        final String signature, final Type[] exceptions,
        final ClassVisitor cv) {
    this(access, method, cv
            .visitMethod(access, method.getName(), method.getDescriptor(),
                    signature, getInternalNames(exceptions)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:GeneratorAdapter.java


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