Beispiel #1
0
 // returns null, if not resolved.
 public Field getFieldRefAt(int which) {
   InstanceKlass klass = getFieldOrMethodKlassRefAt(which);
   if (klass == null) return null;
   Symbol name = getNameRefAt(which);
   Symbol sig = getSignatureRefAt(which);
   return klass.findField(name, sig);
 }
  /** Find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined. */
  public Field findField(Symbol name, Symbol sig) {
    // search order according to newest JVM spec (5.4.3.2, p.167).
    // 1) search for field in current klass
    Field f = findLocalField(name, sig);
    if (f != null) return f;

    // 2) search for field recursively in direct superinterfaces
    f = findInterfaceField(name, sig);
    if (f != null) return f;

    // 3) apply field lookup recursively if superclass exists
    InstanceKlass supr = (InstanceKlass) getSuper();
    if (supr != null) return supr.findField(name, sig);

    // 4) otherwise field lookup fails
    return null;
  }