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


Java ConstantNameAndType.getName方法代码示例

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


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

示例1: visitConstantMethodref

import org.apache.bcel.classfile.ConstantNameAndType; //导入方法依赖的package包/类
public void visitConstantMethodref(ConstantMethodref ref)
{
    ConstantPool    pool = javaClass.getConstantPool();
    String          cstr = ref.getClass(pool);

    if (cstr.equals("java.lang.Class"))
    {
        int     iname = ref.getNameAndTypeIndex();
        String  name = ((ConstantNameAndType)pool.getConstant(iname)).getName(pool);

        if (name.equals("forName")) {
            System.out.println("found Class.forName('" + javaClass.getClassName() + "')");
            ConstantNameAndType cnat = (ConstantNameAndType)pool.getConstant(iname);
            String cfnStr = cnat.getName(pool);
            if (lastConst != null) {
                refClasses.add(lastConst.replace('.', '/'));
                lastConst = null;
            }
        }
    }
}
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:22,代码来源:ClassVisitorSearchCFN.java

示例2: setField

import org.apache.bcel.classfile.ConstantNameAndType; //导入方法依赖的package包/类
/**
 * Called to indicate that a field load or store was encountered.
 *
 * @param cpIndex
 *            the constant pool index of the fieldref
 * @param isStatic
 *            true if it is a static field access
 * @param isLoad
 *            true if the access is a load
 */
private void setField(int cpIndex, boolean isStatic, boolean isLoad) {
    // We only allow one field access for an accessor method.
    accessCount++;
    if (accessCount != 1) {
        access = null;
        return;
    }

    ConstantPool cp = javaClass.getConstantPool();
    ConstantFieldref fieldref = (ConstantFieldref) cp.getConstant(cpIndex);

    ConstantClass cls = (ConstantClass) cp.getConstant(fieldref.getClassIndex());
    String className = cls.getBytes(cp).replace('/', '.');

    ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(fieldref.getNameAndTypeIndex());
    String fieldName = nameAndType.getName(cp);
    String fieldSig = nameAndType.getSignature(cp);


        XField xfield = Hierarchy.findXField(className, fieldName, fieldSig, isStatic);
        if (xfield != null && xfield.isStatic() == isStatic && isValidAccessMethod(methodSig, xfield, isLoad)) {
            access = new InnerClassAccess(methodName, methodSig, xfield, isLoad);
        }
   
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:36,代码来源:InnerClassAccessMap.java

示例3: setField

import org.apache.bcel.classfile.ConstantNameAndType; //导入方法依赖的package包/类
/**
 * Called to indicate that a field load or store was encountered.
 *
 * @param cpIndex
 *            the constant pool index of the fieldref
 * @param isStatic
 *            true if it is a static field access
 * @param isLoad
 *            true if the access is a load
 */
private void setField(int cpIndex, boolean isStatic, boolean isLoad) {
    // We only allow one field access for an accessor method.
    accessCount++;
    if (accessCount != 1) {
        access = null;
        return;
    }

    ConstantPool cp = javaClass.getConstantPool();
    ConstantFieldref fieldref = (ConstantFieldref) cp.getConstant(cpIndex);

    ConstantClass cls = (ConstantClass) cp.getConstant(fieldref.getClassIndex());
    String className = cls.getBytes(cp).replace('/', '.');

    ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(fieldref.getNameAndTypeIndex());
    String fieldName = nameAndType.getName(cp);
    String fieldSig = nameAndType.getSignature(cp);


        XField xfield = Hierarchy.findXField(className, fieldName, fieldSig, isStatic);
        if (xfield != null && xfield.isStatic() == isStatic && isValidAccessMethod(methodSig, xfield, isLoad)) {
            access = new InnerClassAccess(methodName, methodSig, xfield, isLoad);
        }

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:36,代码来源:InnerClassAccessMap.java

示例4: visitConstantNameAndType

import org.apache.bcel.classfile.ConstantNameAndType; //导入方法依赖的package包/类
/**
 * Visit a name and type ref
 *
 * Look for class references in this
 *
 * @param obj the name and type reference being visited.
 */
@Override
public void visitConstantNameAndType(final ConstantNameAndType obj) {
    final String name = obj.getName(constantPool);
    if ("Ljava/lang/Class;".equals(obj.getSignature(constantPool))
            && name.startsWith("class$")) {
        String classname
            = name.substring("class$".length()).replace('$', '.');
        // does the class have a package structure
        final int index = classname.lastIndexOf('.');
        if (index > 0) {
            char start;
            // check if the package structure is more than 1 level deep
            final int index2 = classname.lastIndexOf('.', index - 1);
            if (index2 != -1) {
                // class name has more than 1 package level 'com.company.Class'
                start = classname.charAt(index2 + 1);
            } else {
                // class name has only 1 package level 'package.Class'
                start = classname.charAt(0);
            }
            // Check to see if it's an inner class 'com.company.Class$Inner'
            // CheckStyle:MagicNumber OFF
            if ((start > 0x40) && (start < 0x5B)) {
                // first letter of the previous segment of the class name 'Class'
                // is upper case ascii. so according to the spec it's an inner class
                classname = classname.substring(0, index) + "$"
                    + classname.substring(index + 1);
                addClass(classname);
            } else {
                // Add the class in dotted notation 'com.company.Class'
                addClass(classname);
            }
            // CheckStyle:MagicNumber ON
        } else {
            // Add a class with no package 'Class'
            addClass(classname);
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:47,代码来源:DependencyVisitor.java

示例5: visit

import org.apache.bcel.classfile.ConstantNameAndType; //导入方法依赖的package包/类
@Override
public void visit(ConstantNameAndType obj) {
    String methodName = obj.getName(getConstantPool());
    String methodSig = obj.getSignature(getConstantPool());
    if (!methodName.equals("clone"))
        return;
    if (!methodSig.startsWith("()"))
        return;
    referencesCloneMethod = true;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:CloneIdiom.java


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