[JBoss JIRA] (DROOLS-5216) Rule compilation error when binding fields indexed with square brackets
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-5216?page=com.atlassian.jira.plug... ]
Mario Fusco updated DROOLS-5216:
--------------------------------
Sprint: 2020 Week 13-15 (from Mar 23)
> Rule compilation error when binding fields indexed with square brackets
> -----------------------------------------------------------------------
>
> Key: DROOLS-5216
> URL: https://issues.redhat.com/browse/DROOLS-5216
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.35.0.Final
> Reporter: Matteo Casalino
> Assignee: Mario Fusco
> Priority: Major
> Attachments: binding-field-indexed-with-square-brackets.zip
>
>
> Executable model rule compilation fails on patters that bind a collection field indexed with square brackets
> Example of DRL that fails to compile:
> {noformat}
> rule "binding field indexed with square brackets"
> when Pojo($firstItem : integerList[0])
> Pojo(integerList[this.integerList.size()-1] == $firstItem)
> then
> end
> {noformat}
> Error:
> {noformat}
> Message [id=1, level=ERROR, path=src/main/java/org/drools/reproducer/RulesE96881902F91EBF30C7D6404720A1A94RuleMethods0.java, line=29, column=138
> text=no suitable method found for bind(org.drools.model.Variable<java.util.Map>,(org.drool[...]et(0))
> method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>) is not applicable
> (inference variable A has incompatible bounds
> equality constraints: java.util.Map
> lower bounds: java.lang.Integer)
> method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>,org.drools.model.PatternDSL.ReactOn) is not applicable
> (cannot infer type-variable(s) A
> (actual and formal argument lists differ in length))
> method org.drools.model.PatternDSL.PatternDef.<A,U>bind(org.drools.model.Variable<A>,org.drools.model.Variable<U>,org.drools.model.functions.Function1<U,A>) is not applicable
> (cannot infer type-variable(s) A,U
> (actual and formal argument lists differ in length))
> {noformat}
> The example works fine when compiling without executable model.
> Furthermore, the same example expressed with OOPath fails to compile *both with and without executable model*:
> {noformat}
> rule "binding field indexed with square brackets in OOPath"
> when Pojo($firstItem : /integerList[0])
> Pojo(/integerList[this.integerList.size()-1] == $firstItem)
> then
> end
> {noformat}
> Error without executable model:
> {noformat}
> Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=4, column=0
> text=Unable to Analyse Expression /integerList[this.integerList.size()-1] == $firstItem:
> [Error: Missing left node]
> [Near : {... /integerList[this.integerList.size()-1] == $firstItem ....}]
> {noformat}
> Error with executable model:
> {noformat}
> Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=-1, column=0
> text=Unknown field integerList on class java.lang.Integer]
> {noformat}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 3 months
[JBoss JIRA] (DROOLS-5214) Executable model compilation fails with constraints containing static method calls
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-5214?page=com.atlassian.jira.plug... ]
Mario Fusco resolved DROOLS-5214.
---------------------------------
Resolution: Done
Fixed by https://github.com/kiegroup/drools/commit/37642f78b662288d28707e56b163220...
> Executable model compilation fails with constraints containing static method calls
> ----------------------------------------------------------------------------------
>
> Key: DROOLS-5214
> URL: https://issues.redhat.com/browse/DROOLS-5214
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.35.0.Final
> Reporter: Matteo Casalino
> Assignee: Mario Fusco
> Priority: Major
> Attachments: static-methods-in-contraint.zip
>
>
> Executable model rule compilation fails on patterns containing Java static method calls as constraints
> Example of DRL that fails to compile:
> {noformat}
> rule "Array asList"
> when Pojo(java.util.Arrays.asList(1,5,2,3).containsAll(integerList))
> then
> end
> {noformat}
> or
> {noformat}
> rule "collections disjoint"
> when $p : Pojo($boundList : integerList) Pojo(id > $p.id, !java.util.Collections.disjoint( integerList , $boundList ))
> then
> end
> {noformat}
> or
> {noformat}
> rule "containsAll"
> when Pojo(integerList.containsAll(java.util.Arrays.asList(1,3)), integerList.size() == 2)
> then
> end
> {noformat}
> All above examples work fine when compiling without executable model.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 3 months
[JBoss JIRA] (DROOLS-5216) Rule compilation error when binding fields indexed with square brackets
by Matteo Casalino (Jira)
Matteo Casalino created DROOLS-5216:
---------------------------------------
Summary: Rule compilation error when binding fields indexed with square brackets
Key: DROOLS-5216
URL: https://issues.redhat.com/browse/DROOLS-5216
Project: Drools
Issue Type: Bug
Components: core engine
Affects Versions: 7.35.0.Final
Reporter: Matteo Casalino
Assignee: Mario Fusco
Attachments: binding-field-indexed-with-square-brackets.zip
Executable model rule compilation fails on patters that bind a collection field indexed with square brackets
Example of DRL that fails to compile:
{noformat}
rule "binding field indexed with square brackets"
when Pojo($firstItem : integerList[0])
Pojo(integerList[this.integerList.size()-1] == $firstItem)
then
end
{noformat}
Error:
{noformat}
Message [id=1, level=ERROR, path=src/main/java/org/drools/reproducer/RulesE96881902F91EBF30C7D6404720A1A94RuleMethods0.java, line=29, column=138
text=no suitable method found for bind(org.drools.model.Variable<java.util.Map>,(org.drool[...]et(0))
method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>) is not applicable
(inference variable A has incompatible bounds
equality constraints: java.util.Map
lower bounds: java.lang.Integer)
method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>,org.drools.model.PatternDSL.ReactOn) is not applicable
(cannot infer type-variable(s) A
(actual and formal argument lists differ in length))
method org.drools.model.PatternDSL.PatternDef.<A,U>bind(org.drools.model.Variable<A>,org.drools.model.Variable<U>,org.drools.model.functions.Function1<U,A>) is not applicable
(cannot infer type-variable(s) A,U
(actual and formal argument lists differ in length))
{noformat}
The example works fine when compiling without executable model.
Furthermore, the same example expressed with OOPath fails to compile *both with and without executable model*:
{noformat}
rule "binding field indexed with square brackets in OOPath"
when Pojo($firstItem : /integerList[0])
Pojo(/integerList[this.integerList.size()-1] == $firstItem)
then
end
{noformat}
Error without executable model:
{noformat}
Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=4, column=0
text=Unable to Analyse Expression /integerList[this.integerList.size()-1] == $firstItem:
[Error: Missing left node]
[Near : {... /integerList[this.integerList.size()-1] == $firstItem ....}]
{noformat}
Error with executable model:
{noformat}
Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=-1, column=0
text=Unknown field integerList on class java.lang.Integer]
{noformat}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 3 months
[JBoss JIRA] (DROOLS-5214) Executable model compilation fails with constraints containing static method calls
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-5214?page=com.atlassian.jira.plug... ]
Mario Fusco commented on DROOLS-5214:
-------------------------------------
I reproduced the problem thanks a lot. As a side note I noticed that it happens only if you use the fully qualified name of the class on which you're calling the static method. As a temporary workaround (if necessary) you could import java.util.Arrays and use the simple name in the method invocation like in
{code}
import java.util.Arrays;
rule "Array asList"
when Pojo(Arrays.asList(1,5,2,3).containsAll(integerList))
then
end
{code}
> Executable model compilation fails with constraints containing static method calls
> ----------------------------------------------------------------------------------
>
> Key: DROOLS-5214
> URL: https://issues.redhat.com/browse/DROOLS-5214
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.35.0.Final
> Reporter: Matteo Casalino
> Assignee: Mario Fusco
> Priority: Major
> Attachments: static-methods-in-contraint.zip
>
>
> Executable model rule compilation fails on patterns containing Java static method calls as constraints
> Example of DRL that fails to compile:
> {noformat}
> rule "Array asList"
> when Pojo(java.util.Arrays.asList(1,5,2,3).containsAll(integerList))
> then
> end
> {noformat}
> or
> {noformat}
> rule "collections disjoint"
> when $p : Pojo($boundList : integerList) Pojo(id > $p.id, !java.util.Collections.disjoint( integerList , $boundList ))
> then
> end
> {noformat}
> or
> {noformat}
> rule "containsAll"
> when Pojo(integerList.containsAll(java.util.Arrays.asList(1,3)), integerList.size() == 2)
> then
> end
> {noformat}
> All above examples work fine when compiling without executable model.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 3 months