[jboss-jira] [JBoss JIRA] (DROOLS-1724) DRL compilation error on a generic type property

Mario Fusco (JIRA) issues at jboss.org
Mon Sep 11 05:16:00 EDT 2017


    [ https://issues.jboss.org/browse/DROOLS-1724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461776#comment-13461776 ] 

Mario Fusco commented on DROOLS-1724:
-------------------------------------

The fix is in mvel so I'll have to deploy a new release of it and make drools to use it. This will happen in drools 7.x but I think that drools 6.x will keep running on the old mvel. However when the new mvel release will be ready you could try to exclude the old one and add the new in your pom file (even if at the moment I cannot guarantee they will be 100% compatible),

> DRL compilation error on a generic type property
> ------------------------------------------------
>
>                 Key: DROOLS-1724
>                 URL: https://issues.jboss.org/browse/DROOLS-1724
>             Project: Drools
>          Issue Type: Bug
>    Affects Versions: 6.5.0.Final
>         Environment: drools 6.5.0.Final / java 1.8.0_131
>            Reporter: Ryo Murai
>            Assignee: Mario Fusco
>             Fix For: 7.3.1.Final
>
>
> I got a DRL compilation error on accessing through a generic type property. Minimized object definition is below.
> {code:borderStyle=solid}
> 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
> {code}
> DRL(snippet) is here
> {code:borderStyle=solid}
> when
>     $orderLine: OrderLine()
>     // compilation failed
>     Product(
>         id == $orderLine.product.id || category == $orderLine.product.category
>     ) from discountProducts
> {code}
> This causes below exception.
> {panel}
> 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 : {... Line.product.id || category == $orderLine.product.category ....}]
>                                                                ^
> [Line: 15, Column: 2]]]
> {panel}
> This is weird because it won't occur when the restriction has single condition like below. Drools could analyze this expression.
> {code:borderStyle=solid}
> when
>     $orderLine: OrderLine()
>     // this is compiled, even if `Product(id == $orderLine.product.id)`
>     Product(
>         category == $orderLine.product.category
>     ) from discountProducts
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list