2. Assuper () method
/** * Return the (most specific) base type of t this starts with the * given symbol. If none exists, return null. * * @param t a type * @param sym a symbol * /public type assuper (type T, symbol Sym) { return assup Er.visit (t, sym); }
The Assuper object is defined as follows:
Private simplevisitor<type,symbol> Assuper = new simplevisitor<type,symbol> () {public Type Visitt Ype (Type T, Symbol sym) {return null; } @Override Public Type visitclasstype (ClassType T, Symbol sym) {if (T.tsym = = sym) return t; Type st = supertype (t); if (St.tag = = CLASS | | st.tag = = Typevar | | st.tag = = ERROR) {Type x = Assuper (St, sym); if (x = null) return x; } if ((Sym.flags () & INTERFACE)! = 0) {for (list<type> L = interfaces (t); L.N Onempty (); L = l.tail) {Type x = Assuper (L.head, sym); if (x = null) return x; }} return null; } @Override Public Type visitarraytype (ARRAytype T, Symbol sym) {return Issubtype (T, sym.type)? Sym.type:null; } @Override Public Type Visittypevar (Typevar T, Symbol sym) {if (T.tsym = = sym) return t; else return Assuper (T.bound, sym); } @Override Public Type visiterrortype (ErrorType T, Symbol sym) {return t; }};
By implementing the code you can see that the ClassType, ArrayType, and typevariable are handled. Where the sym symbol is found in T and its parent and implemented interfaces, because T is an array type, the symbol can only be clonable and serializable
Interpreting the types method of Javac 2