[jboss-jira] [JBoss JIRA] (DROOLS-5549) Drools model compilation fails when using object builders within method calls
Ciprian Chiru (Jira)
issues at jboss.org
Fri Jul 31 09:40:00 EDT 2020
[ https://issues.redhat.com/browse/DROOLS-5549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ciprian Chiru updated DROOLS-5549:
----------------------------------
Description:
Given the example rule below:
{code:java}
import org.example.drools.model.*;
import java.util.Map;
global java.util.Set controlSet;
function String dummyFunction(Map m) {
return "test";
}
rule "will execute per each Measurement having ID color"
no-loop
when
Measurement( id == "color", $colorVal : val )
$val: String() from dummyFunction(Map.of($colorVal))
then
controlSet.add($colorVal);
end{code}
compiling the rule with kie-maven-plugin, it throws the error:
{code:java}
...target/generated-sources/drools-model-compiler/main/java/rules/Rules57a04348fad44377b9eacd9bb5741999RuleMethods0.java:[30,117] cannot find symbol
[ERROR] symbol: variable $colorVal
[ERROR] location: class rules.Rules57a04348fad44377b9eacd9bb5741999RuleMethods0{code}
Same rule when not pre-compiled returns the error:
{code:java}
[org.example.drools.service.RulesSession] (main) Message [id=1, kieBase=defaultKieBase, level=ERROR, path=/home/vagrant/git/drools-rules-engine-prototypes/drools-kjar-project/rules/target/classes/rules/dummy-rule.drl, line=-1, column=0
text=Unable to Analyse Expression dummyFunction(Map.of($colorVal)):
[Error: unable to resolve method using strict-mode: java.util.Map.of(java.lang.String)]
[Near : {... dummyFunction(Map.of($colorVal)) ....}] {code}
was:
Given the example rule below:
{code:java}
import org.example.drools.model.*;
import java.util.Map;
global java.util.Set controlSet;
function String dummyFunction(Map m) {
return "test";
}
rule "will execute per each Measurement having ID color"
no-loop
when
Measurement( id == "color", $colorVal : val )
$val: String() from dummyFunction(Map.entry($colorVal))
then
controlSet.add($colorVal);
end{code}
compiling the rule with kie-maven-plugin, it throws the error:
{code:java}
...target/generated-sources/drools-model-compiler/main/java/rules/Rules57a04348fad44377b9eacd9bb5741999RuleMethods0.java:[30,117] cannot find symbol
[ERROR] symbol: variable $colorVal
[ERROR] location: class rules.Rules57a04348fad44377b9eacd9bb5741999RuleMethods0{code}
Same code works fine if the rules are not pre-compiled.
> Drools model compilation fails when using object builders within method calls
> -----------------------------------------------------------------------------
>
> Key: DROOLS-5549
> URL: https://issues.redhat.com/browse/DROOLS-5549
> Project: Drools
> Issue Type: Bug
> Affects Versions: 7.31.0.Final, 7.32.0.Final, 7.33.0.Final, 7.34.0.Final, 7.35.0.Final, 7.36.0.Final, 7.37.0.Final, 7.38.0.Final, 7.39.0.Final, 7.40.0.Final
> Reporter: Ciprian Chiru
> Assignee: Mario Fusco
> Priority: Major
>
> Given the example rule below:
> {code:java}
> import org.example.drools.model.*;
> import java.util.Map;
> global java.util.Set controlSet;
> function String dummyFunction(Map m) {
> return "test";
> }
> rule "will execute per each Measurement having ID color"
> no-loop
> when
> Measurement( id == "color", $colorVal : val )
> $val: String() from dummyFunction(Map.of($colorVal))
> then
> controlSet.add($colorVal);
> end{code}
>
> compiling the rule with kie-maven-plugin, it throws the error:
> {code:java}
> ...target/generated-sources/drools-model-compiler/main/java/rules/Rules57a04348fad44377b9eacd9bb5741999RuleMethods0.java:[30,117] cannot find symbol
> [ERROR] symbol: variable $colorVal
> [ERROR] location: class rules.Rules57a04348fad44377b9eacd9bb5741999RuleMethods0{code}
>
> Same rule when not pre-compiled returns the error:
> {code:java}
> [org.example.drools.service.RulesSession] (main) Message [id=1, kieBase=defaultKieBase, level=ERROR, path=/home/vagrant/git/drools-rules-engine-prototypes/drools-kjar-project/rules/target/classes/rules/dummy-rule.drl, line=-1, column=0
> text=Unable to Analyse Expression dummyFunction(Map.of($colorVal)):
> [Error: unable to resolve method using strict-mode: java.util.Map.of(java.lang.String)]
> [Near : {... dummyFunction(Map.of($colorVal)) ....}] {code}
>
>
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list