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


Java ConstantPool.getLength方法代码示例

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


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

示例1: flagTests

import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
public void flagTests(HashSet<String> tests) {
    if (true == _clazz.isAbstract()) {
        return;
    }

    ConstantPool pool = _clazz.getConstantPool();
    for (int i = 0; i < pool.getLength(); ++i) {
        Constant constant = pool.getConstant(i);
        if (null == constant) {
            continue;
        }
        Byte tag = constant.getTag();
        if (Constants.CONSTANT_Utf8 != tag) {
            continue;
        }
        String constantAsString = pool.constantToString(constant);
        if (constantAsString.contains("Lorg/junit/Test")) {
            tests.add(_clazz.getClassName());
        }
    }
}
 
开发者ID:burkemw3,项目名称:turbo-athena,代码行数:22,代码来源:TestVisitor.java

示例2: init

import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
private void init(JavaClass jclass) {
    ConstantPool cp = jclass.getConstantPool();
    int numConstants = cp.getLength();
    for (int i = 0; i < numConstants; ++i) {
        try {
            Constant c = cp.getConstant(i);
            if (c instanceof ConstantMethodref) {
                ConstantMethodref cmr = (ConstantMethodref) c;
                ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex(),
                        CONSTANT_NameAndType);
                String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), CONSTANT_Utf8)).getBytes();
                String className = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
                String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), CONSTANT_Utf8)).getBytes();

                String classNameLC = className.toLowerCase();
                String methodNameLC = methodName.toLowerCase();
              
                boolean voidReturnType = methodSig.endsWith(")V");
                boolean boolReturnType = methodSig.endsWith(")Z");
                
                

                if (DEBUG) {
                    System.out.print("Is " + className + "." + methodName + " assertion method: " + voidReturnType);
                }

                if (isUserAssertionMethod(className, methodName)
                        || className.endsWith("Assert")
                        && methodName.startsWith("is")
                        || (voidReturnType || boolReturnType)
                        && (classNameLC.indexOf("assert") >= 0 || methodNameLC.startsWith("throw")
                                || methodName.startsWith("affirm") || methodName.startsWith("panic")
                                || methodName.equals("logTerminal") || methodName.startsWith("logAndThrow")
                                || methodNameLC.equals("insist") || methodNameLC.equals("usage")
                                || methodNameLC.equals("exit") || methodNameLC.startsWith("fail")
                                || methodNameLC.startsWith("fatal") || methodNameLC.indexOf("assert") >= 0
                                || methodNameLC.indexOf("legal") >= 0 || methodNameLC.indexOf("error") >= 0
                                || methodNameLC.indexOf("abort") >= 0 
                                // || methodNameLC.indexOf("check") >= 0 
                                || methodNameLC.indexOf("failed") >= 0) || methodName.equals("addOrThrowException")) {
                    assertionMethodRefSet.set(i);
                    if (DEBUG) {
                        System.out.println("==> YES");
                    }
                } else {
                    if (DEBUG) {
                        System.out.println("==> NO");
                    }
                }
            }
        } catch (ClassFormatException e) {
            // FIXME: should report
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:56,代码来源:AssertionMethods.java

示例3: init

import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
private void init(JavaClass jclass) {
    ConstantPool cp = jclass.getConstantPool();
    int numConstants = cp.getLength();
    for (int i = 0; i < numConstants; ++i) {
        try {
            Constant c = cp.getConstant(i);
            if (c instanceof ConstantMethodref) {
                ConstantMethodref cmr = (ConstantMethodref) c;
                ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex(),
                        CONSTANT_NameAndType);
                String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), CONSTANT_Utf8)).getBytes();
                String className = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
                String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), CONSTANT_Utf8)).getBytes();

                String classNameLC = className.toLowerCase();
                String methodNameLC = methodName.toLowerCase();

                boolean voidReturnType = methodSig.endsWith(")V");
                boolean boolReturnType = methodSig.endsWith(")Z");



                if (DEBUG) {
                    System.out.print("Is " + className + "." + methodName + " assertion method: " + voidReturnType);
                }

                if (isUserAssertionMethod(className, methodName)
                        || className.endsWith("Assert")
                        && methodName.startsWith("is")
                        || (voidReturnType || boolReturnType)
                        && (classNameLC.indexOf("assert") >= 0 || methodNameLC.startsWith("throw")
                                || methodName.startsWith("affirm") || methodName.startsWith("panic")
                                || methodName.equals("logTerminal") || methodName.startsWith("logAndThrow")
                                || methodNameLC.equals("insist") || methodNameLC.equals("usage")
                                || methodNameLC.equals("exit") || methodNameLC.startsWith("fail")
                                || methodNameLC.startsWith("fatal") || methodNameLC.indexOf("assert") >= 0
                                || methodNameLC.indexOf("legal") >= 0 || methodNameLC.indexOf("error") >= 0
                                || methodNameLC.indexOf("abort") >= 0
                                // || methodNameLC.indexOf("check") >= 0
                                || methodNameLC.indexOf("failed") >= 0) || methodName.equals("addOrThrowException")) {
                    assertionMethodRefSet.set(i);
                    if (DEBUG) {
                        System.out.println("==> YES");
                    }
                } else {
                    if (DEBUG) {
                        System.out.println("==> NO");
                    }
                }
            }
        } catch (ClassFormatException e) {
            // FIXME: should report
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:56,代码来源:AssertionMethods.java


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