for(SingularAttribute<? super X, ?> anAttribute : idAttributes) { // Verify type is correct - relax restriction on null and Object.class (from same classLoader) if(null == type || Object.class == type || ((type != null) && (type.getCanonicalName().equals(anAttribute.getJavaType().getCanonicalName())))) { idAttribute = (SingularAttribute<? super X, Y>) anAttribute; } else { throw new IllegalArgumentException(ExceptionLocalization.buildMessage( "metamodel_identifiable_id_attribute_type_incorrect", new Object[] { anAttribute, this, type, anAttribute.getJavaType() })); } }