nericTemplate 窃?
賠汽 4. 窃侏紋算旗鷹
public class TypeDirectory
{
...
/** Map from generic classes descriptor to generic class information. */
private HashMap<String,GenericTemplate> m_templateMap =
new HashMap<String,GenericTemplate>();
...
/**
* Get description for generic class with specific type substitutions.
*
* @param sig field signature with type substitutions
* @param types actual types used for instance (values may be
* <code>null</code> if no substitution defined)
* @return type description
*/
public TypeDescription getSignatureInstance(String sig,
TypeDescription[] types) {
// first check for direct match on substituted signature
TypeDescription desc = (TypeDescription)m_typeMap.get(sig);
if (desc == null) {
// no direct match, first handle array
if (sig.charAt(0) == ''['') {
desc = new ArrayClassDescriptor(sig,
getSignatureInstance(sig.substring(1), types));
} else {
// not an array, get the generic class descriptor
String dtor = sig;
int split = dtor.indexOf(''<'');
if (split >= 0) {
dtor = dtor.substring(0, split) + '';'';
}
GenericTemplate gdesc = m_templateMap.get(dtor);
if (gdesc == null) {
byte[] byts = m_loader.getBytes(dtor);
gdesc = new GenericTemplate(dtor, byts, this);
}
// handle type substitution to generic version of class
desc = gdesc.getParameterized(sig, types);
}
}
return desc;
}
/**
* Get description for signature with type mapping.
*
* @param sig field signature for type variables
* @param tmap type mapping for variables
* @return type description
*/
public TypeDescription getMappedSignatureInstance(String sig,
HashMap<String,TypeDescription> tmap) {
SignatureDecompositionVisitor vtor =
new SignatureDecompositionVisitor(tmap);
new SignatureReader(sig).acceptType(vtor);
return vtor.getDescription();
}
/**
* Visitor for processing a signature with type substitutions. This uses
* itself recursively to process nested signatures, substituting actual
* types for any type variable references found.
*/
public class SignatureDecompositionVisitor extends EmptySignatureVisitor
{
private final HashMap<String,TypeDescription> m_parameterMap;
private in
|