// Check if the this Profile is on the visited stack
int position = visitedProfiles.search(this);
if (position != -1) {
// This profile is in the stack, throw an exception
CircularReferenceException e = new CircularReferenceException(
"circular reference via profile extension");
// Cast to List to allow the type to be cast to
// List<Identifiable>
List<? extends AbstractProfile> visited
= visitedProfiles.subList(
visitedProfiles.size() - position,
visitedProfiles.size());
e.setReferenceList(visited);
throw e;
}
final ProfileImpl extendedProfile = document.lookupExtendedProfile(data.getExtends());