-
Bug
-
Resolution: Done
-
Major
-
None
-
6.0.1.Final
-
None
-
None
When declaring a fact type with an array field, where the array type is declared in the same package, for example:
declare Owner
name : String
end
declare Pet
owners : Owner[]
end
The following build error occurs:
[Message [id=1, level=ERROR, path=pets.drl, line=5, column=0
text=Unable to find class 'Owner']]
This error doesn't always occur when an array field is declared. It's dependent on the order in which each fact type is processed.
PackageBuilder attempts to order fact types for processing based on the declared super type and attribute types.
The following loop in PackageBuilder.sortByHierarchy() processes each field looking for field type dependencies:
for (TypeFieldDescr field : tdescr.getFields().values()) { QualifiedName typeName = new QualifiedName(field.getPattern().getObjectType()); if (!hasCircularDependency(name, typeName, taxonomy)) { supers.add(typeName); } }
However I don't think it correctly spots the dependency when the field type is an array.
This issue can be worked around by declaring an unused field of the same type as the array:
declare Owner
name : String
end
declare Pet
owners : Owner[]
_unused: Owner
end