Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1724

DRL compilation error on a generic type property

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 6.5.0.Final
    • Fix Version/s: 7.3.1.Final
    • Component/s: None
    • Labels:
      None
    • Sprint:
      2017 Week 36-37
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      I got a DRL compilation error on accessing through a generic type property. Minimized object definition is below.

      public interface OrderLine<T extends Product> {
          T getProduct();
      }
      
      public interface Product {
          String getId();
          String getCategory();
      }
      
      // and I have concrete classes, ex. Book, BookOrderLine<Book>, DVD, DVDOrderLine<DVD>, ... etc
      

      DRL(snippet) is here

      when
          $orderLine: OrderLine()
      
          // compilation failed
          Product(
              id == $orderLine.product.id || category == $orderLine.product.category
          ) from discountProducts
      

      This causes below exception.

      java.lang.RuntimeException: [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=rules/checkorder-not-compiled.drl, line=15, column=0 text=Unable to Analyse Expression id == $orderLine.product.id || category == $orderLine.product.category:
      [Error: unable to resolve method using strict-mode: java.lang.Object.category()]
      [Near :

      Unknown macro: {... Line.product.id || category == $orderLine.product.category ....}

      ]
      ^
      [Line: 15, Column: 2]]]

      This is weird because it won't occur when the restriction has single condition like below. Drools could analyze this expression.

      when
          $orderLine: OrderLine()
      
          // this is compiled, even if `Product(id == $orderLine.product.id)`
          Product(
              category == $orderLine.product.category
          ) from discountProducts
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                ryo-murai Ryo Murai
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: