private void computeIndirectExposureCauses() {
// TODO(spoon): this only needs to consider immediate subtypes, not all
// subtypes
JClassType[] subtypes = baseType.getSubtypes();
for (JClassType subtype : subtypes) {
JGenericType isGeneric = subtype.isGenericType();
if (isGeneric == null) {
// Only generic types can cause a type parameter to be exposed
continue;
}
// any problems should already have been captured by our caller, so we
// make a throw-away ProblemReport here.
if (!SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(subtype,
typeFilter, new ProblemReport())) {
continue;
}
JParameterizedType asParameterizationOf = subtype.asParameterizationOf(baseType);
Set<JTypeParameter> paramsUsed = new LinkedHashSet<JTypeParameter>();
SerializableTypeOracleBuilder.recordTypeParametersIn(
asParameterizationOf.getTypeArgs()[ordinal], paramsUsed);
for (JTypeParameter paramUsed : paramsUsed) {
recordCausesExposure(isGeneric, paramUsed.getOrdinal(), 0);
}
}
JClassType type = baseType;
while (type != null) {
if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(type, typeFilter,
new ProblemReport())) {
JField[] fields = type.getFields();
for (JField field : fields) {
if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(TreeLogger.NULL,
context, field)) {
continue;
}
JParameterizedType isParameterized = field.getType().getLeafType().isParameterized();
if (isParameterized == null) {
continue;
}
JClassType[] typeArgs = isParameterized.getTypeArgs();
for (int i = 0; i < typeArgs.length; ++i) {
if (referencesTypeParameter(typeArgs[i], getTypeParameter())) {
JGenericType genericFieldType = isParameterized.getBaseType();
recordCausesExposure(genericFieldType, i, 0);
JArrayType typeArgIsArray = typeArgs[i].isArray();
if (typeArgIsArray != null && typeArgIsArray.getLeafType() == getTypeParameter()) {
int dims = typeArgIsArray.getRank();
recordCausesExposure(genericFieldType, i, dims);