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

The following examples show how to use jdk.internal.org.objectweb.asm.Type#getObjectType() . 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: InstructionAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
    case Opcodes.NEW:
        anew(t);
        break;
    case Opcodes.ANEWARRAY:
        newarray(t);
        break;
    case Opcodes.CHECKCAST:
        checkcast(t);
        break;
    case Opcodes.INSTANCEOF:
        instanceOf(t);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 2
Source File: InstructionAdapter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
        case Opcodes.NEW:
            anew(t);
            break;
        case Opcodes.ANEWARRAY:
            newarray(t);
            break;
        case Opcodes.CHECKCAST:
            checkcast(t);
            break;
        case Opcodes.INSTANCEOF:
            instanceOf(t);
            break;
        default:
            throw new IllegalArgumentException();
    }
}
 
Example 3
Source File: Remapper.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
Example 4
Source File: Remapper.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private Type mapType(Type t) {
    switch (t.getSort()) {
        case Type.ARRAY:
            String s = mapDesc(t.getElementType().getDescriptor());
            for (int i = 0; i < t.getDimensions(); ++i) {
                s = '[' + s;
            }
            return Type.getType(s);
        case Type.OBJECT:
            s = map(t.getInternalName());
            return s != null ? Type.getObjectType(s) : t;
        case Type.METHOD:
            return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
Example 5
Source File: Remapper.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
Example 6
Source File: Remapper.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
Example 7
Source File: InstructionAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type objectType = Type.getObjectType(type);
    switch (opcode) {
        case Opcodes.NEW:
            anew(objectType);
            break;
        case Opcodes.ANEWARRAY:
            newarray(objectType);
            break;
        case Opcodes.CHECKCAST:
            checkcast(objectType);
            break;
        case Opcodes.INSTANCEOF:
            instanceOf(objectType);
            break;
        default:
            throw new IllegalArgumentException();
    }
}
 
Example 8
Source File: InstructionAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
    case Opcodes.NEW:
        anew(t);
        break;
    case Opcodes.ANEWARRAY:
        newarray(t);
        break;
    case Opcodes.CHECKCAST:
        checkcast(t);
        break;
    case Opcodes.INSTANCEOF:
        instanceOf(t);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 9
Source File: InstructionAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
    case Opcodes.NEW:
        anew(t);
        break;
    case Opcodes.ANEWARRAY:
        newarray(t);
        break;
    case Opcodes.CHECKCAST:
        checkcast(t);
        break;
    case Opcodes.INSTANCEOF:
        instanceOf(t);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 10
Source File: InstructionAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
    case Opcodes.NEW:
        anew(t);
        break;
    case Opcodes.ANEWARRAY:
        newarray(t);
        break;
    case Opcodes.CHECKCAST:
        checkcast(t);
        break;
    case Opcodes.INSTANCEOF:
        instanceOf(t);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 11
Source File: Remapper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
Example 12
Source File: InstructionAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitTypeInsn(final int opcode, final String type) {
    Type t = Type.getObjectType(type);
    switch (opcode) {
    case Opcodes.NEW:
        anew(t);
        break;
    case Opcodes.ANEWARRAY:
        newarray(t);
        break;
    case Opcodes.CHECKCAST:
        checkcast(t);
        break;
    case Opcodes.INSTANCEOF:
        instanceOf(t);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 13
Source File: CheckClassAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 14
Source File: CheckClassAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 15
Source File: CheckClassAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 16
Source File: CheckClassAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 17
Source File: CheckClassAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 18
Source File: CheckClassAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks a given class.
 *
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
Example 19
Source File: Analyzer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
  * Computes the initial execution stack frame of the given method.
  *
  * @param owner the internal name of the class to which 'method' belongs.
  * @param method the method to be analyzed.
  * @return the initial execution stack frame of the 'method'.
  */
private Frame<V> computeInitialFrame(final String owner, final MethodNode method) {
    Frame<V> frame = newFrame(method.maxLocals, method.maxStack);
    int currentLocal = 0;
    boolean isInstanceMethod = (method.access & ACC_STATIC) == 0;
    if (isInstanceMethod) {
        Type ownerType = Type.getObjectType(owner);
        frame.setLocal(
                currentLocal, interpreter.newParameterValue(isInstanceMethod, currentLocal, ownerType));
        currentLocal++;
    }
    Type[] argumentTypes = Type.getArgumentTypes(method.desc);
    for (Type argumentType : argumentTypes) {
        frame.setLocal(
                currentLocal,
                interpreter.newParameterValue(isInstanceMethod, currentLocal, argumentType));
        currentLocal++;
        if (argumentType.getSize() == 2) {
            frame.setLocal(currentLocal, interpreter.newEmptyValue(currentLocal));
            currentLocal++;
        }
    }
    while (currentLocal < method.maxLocals) {
        frame.setLocal(currentLocal, interpreter.newEmptyValue(currentLocal));
        currentLocal++;
    }
    frame.setReturn(interpreter.newReturnTypeValue(Type.getReturnType(method.desc)));
    return frame;
}
 
Example 20
Source File: MethodGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void loadClass(final String className) {
    super.visitLdcInsn(Type.getObjectType(className));
}