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

DRL compilation error on a generic type property

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.3.1.Final
    • 6.5.0.Final
    • None
    • None
    • 2017 Week 36-37
    • NEW
    • 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
      

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            ryo-murai_jira Ryo Murai (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: