Bug 1079950 - Package builder unable to find declared array class
Summary: Package builder unable to find declared array class
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ER1
: 6.0.2
Assignee: Mario Fusco
QA Contact: Tomas Schlosser
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-24 11:28 UTC by Mario Fusco
Modified: 2014-08-06 19:53 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-08-06 19:53:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-439 0 Major Resolved Package builder unable to find declared array class 2014-05-05 10:01:40 UTC

Description Mario Fusco 2014-03-24 11:28:14 UTC
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

Comment 2 JBoss JIRA Server 2014-03-24 11:29:45 UTC
Mario Fusco <mario.fusco> updated the status of jira DROOLS-439 to Resolved

Comment 4 Mario Fusco 2014-03-24 18:05:46 UTC
Cherry-picked to 6.0.x with https://github.com/droolsjbpm/drools/commit/514c957ad

Comment 5 Tomas Schlosser 2014-05-05 10:01:33 UTC
Verified in BRMS 6.0.2 ER2.


Note You need to log in before you can comment on or make changes to this bug.