Java Code Examples for jdk.internal.org.objectweb.asm.Type#getReturnType()

The following examples show how to use jdk.internal.org.objectweb.asm.Type#getReturnType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdviceAdapter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitInvokeDynamicInsn(
    String name,
    String desc,
    Handle bsm,
    Object... bsmArgs)
{
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 2
Source File: Remapper.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public String mapMethodDesc(String desc) {
    if ("()V".equals(desc)) {
        return desc;
    }

    Type[] args = Type.getArgumentTypes(desc);
    StringBuilder sb = new StringBuilder("(");
    for (int i = 0; i < args.length; i++) {
        sb.append(mapDesc(args[i].getDescriptor()));
    }
    Type returnType = Type.getReturnType(desc);
    if (returnType == Type.VOID_TYPE) {
        sb.append(")V");
        return sb.toString();
    }
    sb.append(')').append(mapDesc(returnType.getDescriptor()));
    return sb.toString();
}
 
Example 3
Source File: AdviceAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 4
Source File: Remapper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public String mapMethodDesc(String desc) {
    if ("()V".equals(desc)) {
        return desc;
    }

    Type[] args = Type.getArgumentTypes(desc);
    StringBuffer s = new StringBuffer("(");
    for (int i = 0; i < args.length; i++) {
        s.append(mapDesc(args[i].getDescriptor()));
    }
    Type returnType = Type.getReturnType(desc);
    if (returnType == Type.VOID_TYPE) {
        s.append(")V");
        return s.toString();
    }
    s.append(')').append(mapDesc(returnType.getDescriptor()));
    return s.toString();
}
 
Example 5
Source File: AdviceAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 6
Source File: MethodGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
MethodGenerator(final MethodVisitor mv, final int access, final String name, final String descriptor) {
    super(Main.ASM_VERSION, mv);
    this.access        = access;
    this.name          = name;
    this.descriptor    = descriptor;
    this.returnType    = Type.getReturnType(descriptor);
    this.argumentTypes = Type.getArgumentTypes(descriptor);
}
 
Example 7
Source File: MethodGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
MethodGenerator(final MethodVisitor mv, final int access, final String name, final String descriptor) {
    super(ASM4, mv);
    this.access        = access;
    this.name          = name;
    this.descriptor    = descriptor;
    this.returnType    = Type.getReturnType(descriptor);
    this.argumentTypes = Type.getArgumentTypes(descriptor);
}
 
Example 8
Source File: AdviceAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    mv.visitMethodInsn(opcode, owner, name, desc, itf);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }
        switch (opcode) {
        // case INVOKESTATIC:
        // break;
        case INVOKEINTERFACE:
        case INVOKEVIRTUAL:
            popValue(); // objectref
            break;
        case INVOKESPECIAL:
            Object type = popValue(); // objectref
            if (type == THIS && !superInitialized) {
                onMethodEnter();
                superInitialized = true;
                // once super has been initialized it is no longer
                // necessary to keep track of stack state
                constructor = false;
            }
            break;
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 9
Source File: AdviceAdapter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void doVisitMethodInsn(final int opcode, final String descriptor) {
    if (isConstructor && !superClassConstructorCalled) {
        for (Type argumentType : Type.getArgumentTypes(descriptor)) {
            popValue();
            if (argumentType.getSize() == 2) {
                popValue();
            }
        }
        switch (opcode) {
            case INVOKEINTERFACE:
            case INVOKEVIRTUAL:
                popValue();
                break;
            case INVOKESPECIAL:
                Object value = popValue();
                if (value == UNINITIALIZED_THIS && !superClassConstructorCalled) {
                    superClassConstructorCalled = true;
                    onMethodEnter();
                }
                break;
            default:
                break;
        }

        Type returnType = Type.getReturnType(descriptor);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 10
Source File: AdviceAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    mv.visitMethodInsn(opcode, owner, name, desc, itf);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }
        switch (opcode) {
        // case INVOKESTATIC:
        // break;
        case INVOKEINTERFACE:
        case INVOKEVIRTUAL:
            popValue(); // objectref
            break;
        case INVOKESPECIAL:
            Object type = popValue(); // objectref
            if (type == THIS && !superInitialized) {
                onMethodEnter();
                superInitialized = true;
                // once super has been initialized it is no longer
                // necessary to keep track of stack state
                constructor = false;
            }
            break;
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
Example 11
Source File: GeneratorAdapter.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new {@link GeneratorAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param mv
 *            the method visitor to which this adapter delegates calls.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 */
protected GeneratorAdapter(final int api, final MethodVisitor mv,
        final int access, final String name, final String desc) {
    super(api, access, desc, mv);
    this.access = access;
    this.returnType = Type.getReturnType(desc);
    this.argumentTypes = Type.getArgumentTypes(desc);
}
 
Example 12
Source File: GeneratorAdapter.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new {@link GeneratorAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param mv
 *            the method visitor to which this adapter delegates calls.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 */
protected GeneratorAdapter(final int api, final MethodVisitor mv,
        final int access, final String name, final String desc) {
    super(api, access, desc, mv);
    this.access = access;
    this.returnType = Type.getReturnType(desc);
    this.argumentTypes = Type.getArgumentTypes(desc);
}
 
Example 13
Source File: GeneratorAdapter.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new {@link GeneratorAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param mv
 *            the method visitor to which this adapter delegates calls.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 */
protected GeneratorAdapter(final int api, final MethodVisitor mv,
        final int access, final String name, final String desc) {
    super(api, access, desc, mv);
    this.access = access;
    this.returnType = Type.getReturnType(desc);
    this.argumentTypes = Type.getArgumentTypes(desc);
}
 
Example 14
Source File: GeneratorAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new {@link GeneratorAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param mv
 *            the method visitor to which this adapter delegates calls.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 */
protected GeneratorAdapter(final int api, final MethodVisitor mv,
        final int access, final String name, final String desc) {
    super(api, access, desc, mv);
    this.access = access;
    this.returnType = Type.getReturnType(desc);
    this.argumentTypes = Type.getArgumentTypes(desc);
}
 
Example 15
Source File: Method.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}
 
Example 16
Source File: Method.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}
 
Example 17
Source File: Method.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}
 
Example 18
Source File: Method.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}
 
Example 19
Source File: Method.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}
 
Example 20
Source File: Method.java    From nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the return type of the method described by this object.
 *
 * @return the return type of the method described by this object.
 */
public Type getReturnType() {
    return Type.getReturnType(desc);
}