[jboss-jira] [JBoss JIRA] (DROOLS-1078) Drools can incorrectly generate Java code to access a method on a wrong reference type for a covariant return
Juan Carlos Garcia (JIRA)
issues at jboss.org
Tue Mar 1 09:34:00 EST 2016
Juan Carlos Garcia created DROOLS-1078:
------------------------------------------
Summary: Drools can incorrectly generate Java code to access a method on a wrong reference type for a covariant return
Key: DROOLS-1078
URL: https://issues.jboss.org/browse/DROOLS-1078
Project: Drools
Issue Type: Bug
Affects Versions: 6.3.0.Final, 6.2.0.Final
Reporter: Juan Carlos Garcia
Assignee: Mark Proctor
Attachments: DroolsBugDemo.zip
Drools will incorrectly generate Java code to access a method on a wrong reference type, hence resulting in a rule compilation error.
Taking the following rule as example (which is also attached),
{code}
import bug.demo.Table;
import bug.demo.Constants;
import bug.demo.Player;
import bug.demo.event.GenericEvent;
import bug.demo.api.model.Card;
rule "BuggyRule"
when
$discardCardEvent : GenericEvent(eventName=="fooEvent",
$discardedCard : Card.fromMap(getEventProperty("fooCard")),
Constants.FOO_RANK.contains($discardedCard.getRank()),
$playerIndex : slotIndex) from entry-point "foo-stream"
$table : Table($currentPlayer : getCurrentPlayer())
then
$table.addToDiscardPile($discardedCard);
$table.reset();
$currentPlayer.removeCard($discardedCard);
end
{code}
In this case when compiling the following rule, we may end up (sometimes) with compilation error:
*The method removeCard(Card) is undefined for the type TurnbasedPlayer* , when a Player type should be used in first place.
Attached is sample project to reproduce the problem, be aware that you may need to do *mvn clean test* several times until you actually trigger the problem, if you are lucky enough it will get trigger the first time you execute it.
Environment:
{code}
>mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Maven home: /usr/share/maven
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk-7-oracle-x64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-77-generic", arch: "amd64", family: "unix"
{code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list