variableref.java

来自「java 到c的转换程序的原代码.对喜欢C程序而不懂JAVA程序的人很有帮助」· Java 代码 · 共 53 行

JAVA
53
字号
//  FieldRef.java -- a Field ref in a Constant tablepackage toba.classfile;public class VariableRef extends FieldRef {    public VariableRef(ClassRef cl, String n, String s) { super(cl, n, s); }    protected Field    findVariable (ClassData cdata)    {        Field [] vt;        int i;        /* This method is fundamentally wrong: it fails to account for cases         * where fields have the same name and signature, as in hiding         * a superclass public field, overriding a superclass private field,         * or obscuring a superclass instance/static variable with a subclass         * static/instance variable.  What we do to decrease the frequency         * of screwup is go through the static var table first (because         * the serialization code hits this bug with a reference to a static         * field that ends up accessing a parent instance field), and by         * going from the end of the table down, since that's the order         * of priority (heading towards superclasses). */                vt = cdata.cvtable;        i = vt.length;        while (0 <= --i) {	    if ((name == vt[i].name) && 		(signature == vt[i].signature)) {		return vt[i];            }	}        /* No static field found; try the instance fields */	vt = cdata.ivtable;        i = vt.length;        while (0 <= --i) {	    if ((name == vt[i].name) && 		(signature == vt[i].signature)) {		return vt[i];            }	}        /* No field with this name. */	throw new NoSuchFieldError(cdata.name + "." + name + "(" + signature + ")");    }    public void resolveWith(ClassData cdata) {	resolveTo(findVariable(cdata));    }};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?