• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConstantFieldref类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: visitFieldInstruction

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
/**
* Ensures the general preconditions of a FieldInstruction instance.
*/
public void visitFieldInstruction(FieldInstruction o){
	// visitLoadClass(o) has been called before: Every FieldOrMethod
	// implements LoadClass.
	// visitCPInstruction(o) has been called before.
// A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC 
	Constant c = cpg.getConstant(o.getIndex());
	if (!(c instanceof ConstantFieldref)){
		constraintViolated(o, "Index '"+o.getIndex()+"' should refer to a CONSTANT_Fieldref_info structure, but refers to '"+c+"'.");
	}
	// the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
	Type t = o.getType(cpg);
	if (t instanceof ObjectType){
		String name = ((ObjectType)t).getClassName();
		Verifier v = VerifierFactory.getVerifier( name );
		VerificationResult vr = v.doPass2();
		if (vr.getStatus() != VerificationResult.VERIFIED_OK){
			constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
		}
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:24,代码来源:InstConstraintVisitor.java


示例2: setField

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的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.ConstantFieldref; //导入依赖的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: addFieldref

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
/**
 * Add a new Fieldref constant to the ConstantPool, if it is not already 
 * in there.
 *
 * @param class_name class name string to add
 * @param field_name field name string to add
 * @param signature signature string to add
 * @return index of entry
 */
public int addFieldref( String class_name, String field_name, String signature ) {
    int ret;
    int class_index, name_and_type_index;
    if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) {
        return ret; // Already in CP
    }
    adjustSize();
    class_index = addClass(class_name);
    name_and_type_index = addNameAndType(field_name, signature);
    ret = index;
    constants[index++] = new ConstantFieldref(class_index, name_and_type_index);
    String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature;
    if (!cp_table.containsKey(key)) {
        cp_table.put(key, new Index(ret));
    }
    return ret;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:27,代码来源:ConstantPoolGen.java


示例5: checkCode

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
public boolean checkCode(InstructionHandle[] match)
{
    InstructionHandle ih = match[2];
    CPInstruction putfield = (CPInstruction) ih.getInstruction();
    Constant cc = cpool.getConstant(putfield.getIndex());
    if (cc.getTag() != CONSTANT_Fieldref)
        return false;
    ConstantFieldref cfield = (ConstantFieldref) cc;
    ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cfield.getNameAndTypeIndex());
    if (!cnt.getName(cpool.getConstantPool()).equals("this$0"))
        return false;
    return true;
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:14,代码来源:Downgrader.java


示例6: visitConstantFieldref

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
@Override
public void visitConstantFieldref(ConstantFieldref obj) {
	String name = obj.getClass(this.cp);
	jClass.getDetail().addVariableType(name);
	if (this.parser.isDebug()) {
		this.parser.debug("visitConstantFieldref: variable type = " + name);
	}
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:9,代码来源:SmallClassFileVisitor.java


示例7: visitConstantFieldref

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
public void visitConstantFieldref(ConstantFieldref obj){
	if (obj.getTag() != Constants.CONSTANT_Fieldref){
		throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
	}
	checkIndex(obj, obj.getClassIndex(), CONST_Class);
	checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:8,代码来源:Pass2Verifier.java


示例8: visit

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
public void visit(ConstantFieldref obj) {
    visit((ConstantCP) obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例9: visitConstantFieldref

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
public void visitConstantFieldref(ConstantFieldref obj) {
    visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例10: visit

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
@Override
public void visit(JavaClass obj) {
    compute();
    ConstantPool cp = obj.getConstantPool();
    Constant[] constants = cp.getConstantPool();
    checkConstant: for (int i = 0; i < constants.length; i++) {
        Constant co = constants[i];
        if (co instanceof ConstantDouble || co instanceof ConstantLong)
            i++;
        if (co instanceof ConstantClass) {
            String ref = getClassName(obj, i);
            if ((ref.startsWith("java") || ref.startsWith("org.w3c.dom")) && !defined.contains(ref))
                bugReporter.reportBug(new BugInstance(this, "VR_UNRESOLVABLE_REFERENCE", NORMAL_PRIORITY).addClass(obj)
                        .addString(ref));

        } else if (co instanceof ConstantFieldref) {
            // do nothing until we handle static fields defined in
            // interfaces
        } else if (co instanceof ConstantCP) {
            ConstantCP co2 = (ConstantCP) co;
            String className = getClassName(obj, co2.getClassIndex());

            // System.out.println("checking " + ref);
            if (className.equals(obj.getClassName()) || !defined.contains(className)) {
                // System.out.println("Skipping check of " + ref);
                continue checkConstant;
            }
            ConstantNameAndType nt = (ConstantNameAndType) cp.getConstant(co2.getNameAndTypeIndex());
            String name = ((ConstantUtf8) obj.getConstantPool().getConstant(nt.getNameIndex(), CONSTANT_Utf8)).getBytes();
            String signature = ((ConstantUtf8) obj.getConstantPool().getConstant(nt.getSignatureIndex(), CONSTANT_Utf8))
                    .getBytes();

            try {
                JavaClass target = Repository.lookupClass(className);
                if (!find(target, name, signature))
                    bugReporter.reportBug(new BugInstance(this, "VR_UNRESOLVABLE_REFERENCE", NORMAL_PRIORITY).addClass(obj)
                            .addString(getMemberName(target.getClassName(), name, signature)));

            } catch (ClassNotFoundException e) {
                bugReporter.reportMissingClass(e);
            }
        }

    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:46,代码来源:ResolveAllReferences.java


示例11: visitConstantFieldref

import org.apache.bcel.classfile.ConstantFieldref; //导入依赖的package包/类
public void visitConstantFieldref(ConstantFieldref obj) {
    tostring = toString(obj);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VersionTree类代码示例发布时间:2022-05-22
下一篇:
Java TextHeader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap