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


Java InstructionAdapter.visitVarInsn方法代码示例

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


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

示例1: generateDelegatingConstructor

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateDelegatingConstructor(final Constructor<?> ctor) {
    final Type originalCtorType = Type.getType(ctor);
    final Type[] argTypes = originalCtorType.getArgumentTypes();

    // All constructors must be public, even if in the superclass they were protected.
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT,
            Type.getMethodDescriptor(originalCtorType.getReturnType(), argTypes), null, null));

    mv.visitCode();
    // Invoke super constructor with the same arguments.
    mv.visitVarInsn(ALOAD, 0);
    int offset = 1; // First arg is at position 1, after this.
    for (final Type argType: argTypes) {
        mv.load(offset, argType);
        offset += argType.getSize();
    }
    mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor(), false);

    endInitMethod(mv);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JavaAdapterBytecodeGenerator.java

示例2: generateOverridingConstructorWithObjectParam

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateOverridingConstructorWithObjectParam(final InstructionAdapter mv, final Constructor<?> ctor, final String ctorDescriptor) {
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    final Class<?>[] argTypes = ctor.getParameterTypes();
    int offset = 1; // First arg is at position 1, after this.
    for (int i = 0; i < argTypes.length; ++i) {
        final Type argType = Type.getType(argTypes[i]);
        mv.load(offset, argType);
        offset += argType.getSize();
    }
    mv.invokespecial(superClassName, INIT, ctorDescriptor, false);
    mv.visitVarInsn(ALOAD, offset);
    mv.visitInsn(ACONST_NULL);
    mv.visitInsn(ACONST_NULL);
    mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_OBJECT_DESCRIPTOR, false);
    endInitMethod(mv);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:JavaAdapterBytecodeGenerator.java

示例3: emitSuperCall

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc) {
    mv.visitVarInsn(ALOAD, 0);
    int nextParam = 1;
    final Type methodType = Type.getMethodType(methodDesc);
    for(final Type t: methodType.getArgumentTypes()) {
        mv.load(nextParam, t);
        nextParam += t.getSize();
    }

    // default method - non-abstract, interface method
    if (Modifier.isInterface(owner.getModifiers())) {
        mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false);
    } else {
        mv.invokespecial(superClassName, name, methodDesc, false);
    }
    mv.areturn(methodType.getReturnType());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:JavaAdapterBytecodeGenerator.java

示例4: emitSuperCall

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private int emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc, final boolean constructor) {
    mv.visitVarInsn(ALOAD, 0);
    int nextParam = 1;
    final Type methodType = Type.getMethodType(methodDesc);
    for(final Type t: methodType.getArgumentTypes()) {
        mv.load(nextParam, t);
        nextParam += t.getSize();
    }

    // default method - non-abstract, interface method
    if (!constructor && Modifier.isInterface(owner.getModifiers())) {
        // we should call default method on the immediate "super" type - not on (possibly)
        // the indirectly inherited interface class!
        final Class<?> superType = findInvokespecialOwnerFor(owner);
        mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(superType), name, methodDesc,
            Modifier.isInterface(superType.getModifiers()));
    } else {
        mv.invokespecial(superClassName, name, methodDesc, false);
    }
    return nextParam;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JavaAdapterBytecodeGenerator.java

示例5: emitSuperCall

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc) {
    mv.visitVarInsn(ALOAD, 0);
    int nextParam = 1;
    final Type methodType = Type.getMethodType(methodDesc);
    for(final Type t: methodType.getArgumentTypes()) {
        mv.load(nextParam, t);
        nextParam += t.getSize();
    }

    // default method - non-abstract, interface method
    if (Modifier.isInterface(owner.getModifiers())) {
        // we should call default method on the immediate "super" type - not on (possibly)
        // the indirectly inherited interface class!
        mv.invokespecial(Type.getInternalName(findInvokespecialOwnerFor(owner)), name, methodDesc, false);
    } else {
        mv.invokespecial(superClassName, name, methodDesc, false);
    }
    mv.areturn(methodType.getReturnType());
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:20,代码来源:JavaAdapterBytecodeGenerator.java

示例6: generateDelegatingConstructor

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateDelegatingConstructor(final Constructor<?> ctor) {
    final Type originalCtorType = Type.getType(ctor);
    final Type[] argTypes = originalCtorType.getArgumentTypes();

    // All constructors must be public, even if in the superclass they were protected.
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC |
            (ctor.isVarArgs() ? ACC_VARARGS : 0), INIT,
            Type.getMethodDescriptor(originalCtorType.getReturnType(), argTypes), null, null));

    mv.visitCode();
    // Invoke super constructor with the same arguments.
    mv.visitVarInsn(ALOAD, 0);
    int offset = 1; // First arg is at position 1, after this.
    for (final Type argType: argTypes) {
        mv.load(offset, argType);
        offset += argType.getSize();
    }
    mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor(), false);

    endInitMethod(mv);
}
 
开发者ID:JetBrains,项目名称:jdk8u_nashorn,代码行数:22,代码来源:JavaAdapterBytecodeGenerator.java

示例7: generateDelegatingConstructor

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateDelegatingConstructor(final Constructor<?> ctor) {
    final Type originalCtorType = Type.getType(ctor);
    final Type[] argTypes = originalCtorType.getArgumentTypes();

    // All constructors must be public, even if in the superclass they were protected.
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT,
            Type.getMethodDescriptor(originalCtorType.getReturnType(), argTypes), null, null));

    mv.visitCode();
    // Invoke super constructor with the same arguments.
    mv.visitVarInsn(ALOAD, 0);
    int offset = 1; // First arg is at position 1, after this.
    for (Type argType: argTypes) {
        mv.load(offset, argType);
        offset += argType.getSize();
    }
    mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor());

    endInitMethod(mv);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:21,代码来源:JavaAdapterBytecodeGenerator.java

示例8: emitFinally

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JavaAdapterBytecodeGenerator.java

示例9: generateFinalizerDelegate

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateFinalizerDelegate(final String finalizerDelegateName) {
    // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll
    // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see
    // generateFinalizerOverride()).
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC,
            finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null));

    // Simply invoke super.finalize()
    mv.visitVarInsn(ALOAD, 0);
    mv.checkcast(Type.getType(generatedClassName));
    mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false);

    mv.visitInsn(RETURN);
    endMethod(mv);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:JavaAdapterBytecodeGenerator.java

示例10: generateFinalizerOverride

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateFinalizerOverride(final String finalizerDelegateName) {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize",
            VOID_NOARG_METHOD_DESCRIPTOR, null, null));
    // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ...
    mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, finalizerDelegateName,
            Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE)));
    mv.visitVarInsn(ALOAD, 0);
    // ...and invoke it through JavaAdapterServices.invokeNoPermissions
    mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "invokeNoPermissions",
            Type.getMethodDescriptor(METHOD_HANDLE_TYPE, OBJECT_TYPE), false);
    mv.visitInsn(RETURN);
    endMethod(mv);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:JavaAdapterBytecodeGenerator.java

示例11: loadField

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void loadField(final InstructionAdapter mv, final String name, final String desc) {
    if(classOverride) {
        mv.getstatic(generatedClassName, name, desc);
    } else {
        mv.visitVarInsn(ALOAD, 0);
        mv.getfield(generatedClassName, name, desc);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:JavaAdapterBytecodeGenerator.java

示例12: generateFinalizerDelegate

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateFinalizerDelegate() {
    // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll
    // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see
    // generateFinalizerOverride()).
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC,
            FINALIZER_DELEGATE_NAME, FINALIZER_DELEGATE_METHOD_DESCRIPTOR, null, null));

    // Simply invoke super.finalize()
    mv.visitVarInsn(ALOAD, 0);
    mv.checkcast(Type.getType(generatedClassName));
    mv.invokespecial(superClassName, "finalize", VOID_METHOD_DESCRIPTOR, false);

    mv.visitInsn(RETURN);
    endMethod(mv);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:JavaAdapterBytecodeGenerator.java

示例13: generateFinalizerOverride

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void generateFinalizerOverride() {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize",
            VOID_METHOD_DESCRIPTOR, null, null));
    // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ...
    mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, FINALIZER_DELEGATE_NAME,
            FINALIZER_DELEGATE_METHOD_DESCRIPTOR, false));
    mv.visitVarInsn(ALOAD, 0);
    // ...and invoke it through JavaAdapterServices.invokeNoPermissions
    INVOKE_NO_PERMISSIONS.invoke(mv);
    mv.visitInsn(RETURN);
    endMethod(mv);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JavaAdapterBytecodeGenerator.java

示例14: loadField

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
private void loadField(final InstructionAdapter mv, final String name, final String desc) {
    if(classOverride) {
mv.getstatic(generatedClassName, name, desc);
    } else {
        mv.visitVarInsn(ALOAD, 0);
mv.getfield(generatedClassName, name, desc);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:9,代码来源:JavaAdapterBytecodeGenerator.java

示例15: generateFinalizerOverride

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void generateFinalizerOverride() {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize",
            VOID_METHOD_DESCRIPTOR, null, null));
    // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ...
    mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, FINALIZER_DELEGATE_NAME,
            FINALIZER_DELEGATE_METHOD_DESCRIPTOR));
    mv.visitVarInsn(ALOAD, 0);
    // ...and invoke it through JavaAdapterServices.invokeNoPermissions
    INVOKE_NO_PERMISSIONS.invoke(mv);
    mv.visitInsn(RETURN);
    endMethod(mv);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:14,代码来源:JavaAdapterBytecodeGenerator.java


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