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


Java InstructionAdapter类代码示例

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


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

示例1: generateConverterInit

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private void generateConverterInit(final InstructionAdapter mv, final boolean samOnly) {
    assert !samOnly || !classOverride;
    for(final Map.Entry<Class<?>, String> converterField: converterFields.entrySet()) {
        final Class<?> returnType = converterField.getKey();
        if(!classOverride) {
            mv.visitVarInsn(ALOAD, 0);
        }

        if(samOnly && !samReturnTypes.contains(returnType)) {
            mv.visitInsn(ACONST_NULL);
        } else {
            mv.aconst(Type.getType(converterField.getKey()));
            mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getObjectConverter", GET_CONVERTER_METHOD_DESCRIPTOR, false);
        }

        if(classOverride) {
            mv.putstatic(generatedClassName, converterField.getValue(), METHOD_HANDLE_TYPE_DESCRIPTOR);
        } else {
            mv.putfield(generatedClassName, converterField.getValue(), METHOD_HANDLE_TYPE_DESCRIPTOR);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:JavaAdapterBytecodeGenerator.java

示例2: 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

示例3: 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

示例4: 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

示例5: generateClassInit

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private void generateClassInit() {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_STATIC, CLASS_INIT,
            VOID_METHOD_DESCRIPTOR, null, null));

    // Assign "global = Context.getGlobal()"
    GET_NON_NULL_GLOBAL.invoke(mv);
    mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    GET_CLASS_OVERRIDES.invoke(mv);
    if(samName != null) {
        // If the class is a SAM, allow having ScriptFunction passed as class overrides
        mv.dup();
        mv.instanceOf(SCRIPT_FUNCTION_TYPE);
        mv.dup();
        mv.putstatic(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);
        final Label notFunction = new Label();
        mv.ifeq(notFunction);
        mv.dup();
        mv.checkcast(SCRIPT_FUNCTION_TYPE);
        emitInitCallThis(mv);
        mv.visitLabel(notFunction);
    }
    mv.putstatic(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

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

示例6: convertReturnValue

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private static void convertReturnValue(final InstructionAdapter mv, final Class<?> origReturnType) {
    if (origReturnType == void.class) {
        mv.pop();
    } else if (origReturnType == Object.class) {
        // Must hide ConsString (and potentially other internal Nashorn types) from callers
        EXPORT_RETURN_VALUE.invoke(mv);
    } else if (origReturnType == byte.class) {
        mv.visitInsn(I2B);
    } else if (origReturnType == short.class) {
        mv.visitInsn(I2S);
    } else if (origReturnType == float.class) {
        mv.visitInsn(D2F);
    } else if (origReturnType == char.class) {
        TO_CHAR_PRIMITIVE.invoke(mv);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JavaAdapterBytecodeGenerator.java

示例7: 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

示例8: generateClassInit

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private void generateClassInit() {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_STATIC, CLASS_INIT,
            VOID_METHOD_DESCRIPTOR, null, null));

    // Assign "global = Context.getGlobal()"
    GET_NON_NULL_GLOBAL.invoke(mv);
    mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    GET_CLASS_OVERRIDES.invoke(mv);
    if(samName != null) {
        // If the class is a SAM, allow having ScriptFunction passed as class overrides
        mv.dup();
        mv.instanceOf(SCRIPT_FUNCTION_TYPE);
                mv.dup();
        mv.putstatic(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);
        final Label notFunction = new Label();
        mv.ifeq(notFunction);
        mv.dup();
        mv.checkcast(SCRIPT_FUNCTION_TYPE);
        emitInitCallThis(mv);
        mv.visitLabel(notFunction);
    }
    mv.putstatic(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

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

示例9: 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!
        mv.invokespecial(Type.getInternalName(findInvokespecialOwnerFor(owner)), name, methodDesc, false);
    } else {
        mv.invokespecial(superClassName, name, methodDesc, false);
    }
    return nextParam;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:JavaAdapterBytecodeGenerator.java

示例10: 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:malaporte,项目名称:kaziranga,代码行数:22,代码来源:JavaAdapterBytecodeGenerator.java

示例11: 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

示例12: 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

示例13: loadMethodTypeAndGetHandle

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private static void loadMethodTypeAndGetHandle(final InstructionAdapter mv, final MethodInfo mi, final String getHandleDescriptor) {
    // NOTE: we're using generic() here because we'll be linking to the "generic" invoker version of
    // the functions anyway, so we cut down on megamorphism in the invokeExact() calls in adapter
    // bodies. Once we start linking to type-specializing invokers, this should be changed.
    mv.aconst(Type.getMethodType(mi.type.generic().toMethodDescriptorString()));
    mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", getHandleDescriptor, false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavaAdapterBytecodeGenerator.java

示例14: boxStackTop

import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; //导入依赖的package包/类
private static void boxStackTop(final InstructionAdapter mv, final Type t) {
    switch(t.getSort()) {
    case Type.BOOLEAN:
        invokeValueOf(mv, "Boolean", 'Z');
        break;
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        // bytes and shorts get boxed as integers
        invokeValueOf(mv, "Integer", 'I');
        break;
    case Type.CHAR:
        invokeValueOf(mv, "Character", 'C');
        break;
    case Type.FLOAT:
        // floats get boxed as doubles
        mv.visitInsn(Opcodes.F2D);
        invokeValueOf(mv, "Double", 'D');
        break;
    case Type.LONG:
        invokeValueOf(mv, "Long", 'J');
        break;
    case Type.DOUBLE:
        invokeValueOf(mv, "Double", 'D');
        break;
    case Type.ARRAY:
    case Type.METHOD:
        // Already boxed
        break;
    case Type.OBJECT:
        if(t.equals(OBJECT_TYPE)) {
            mv.invokestatic(SCRIPTUTILS_TYPE_NAME, "unwrap", UNWRAP_METHOD_DESCRIPTOR, false);
        }
        break;
    default:
        // Not expecting anything else (e.g. VOID)
        assert false;
        break;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:JavaAdapterBytecodeGenerator.java

示例15: 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


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