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


Java SimpleVerifier类代码示例

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


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

示例1: verify

import jdk.internal.org.objectweb.asm.tree.analysis.SimpleVerifier; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:CheckClassAdapter.java

示例2: verify

import jdk.internal.org.objectweb.asm.tree.analysis.SimpleVerifier; //导入依赖的package包/类
/**
 * 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().toString()));
    }

    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();
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:54,代码来源:CheckClassAdapter.java


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