Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1057550 - Drools invokes superclass static method
Summary: Drools invokes superclass static method
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER1
: 6.0.1
Assignee: Mario Fusco
QA Contact: Tomas Schlosser
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-24 10:33 UTC by Mario Fusco
Modified: 2014-08-06 19:59 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 19:59:07 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
JBoss Issue Tracker DROOLS-410 Major Resolved Drools invokes superclass static method 2015-06-04 08:39:46 UTC

Description Mario Fusco 2014-01-24 10:33:29 UTC
When a static method with the same signature is declared by a class and its superclass Drools mistakenly invokes the one of the superclass even when it shouldn't.

The original jira ticket reports this problem as a bug of the constraint jitting process. However I find a simpler use case (that I am pasting below) showing that in some cases this problem is present also before the constraints jitter kicks in.


    public static class ARef {
        public static int getSize(String s) {
            return 0;
        }
    }

    public static class BRef extends ARef {
        public static int getSize(String s) {
            return s.length();
        }
    }

    @Test
    public void testJittingConstraintInvokingStaticMethod() throws Exception {
        // DROOLS-410
        String str =
                "dialect \"mvel\"\n" +
                "import org.drools.compiler.integrationtests.Misc2Test.ARef\n" +
                "import org.drools.compiler.integrationtests.Misc2Test.BRef\n" +
                "\n" +
                "global java.util.List list;\n" +
                "\n" +
                "rule R when\n" +
                "    $s : String( length == BRef.getSize(this) )\n" +
                "then\n" +
                "    list.add($s);\n" +
                "end\n";

        KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        List<String> list = new ArrayList<String>();
        ksession.setGlobal("list", list);

        ksession.insert("1234");
        ksession.fireAllRules();

        assertEquals(1, list.size());
    }

Comment 1 JBoss JIRA Server 2014-01-24 10:39:53 UTC
Mario Fusco <mario.fusco@gmail.com> updated the status of jira DROOLS-410 to Resolved

Comment 3 Mario Fusco 2014-01-24 10:41:55 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/2778edbc6 and https://github.com/mvel/mvel/commit/921cf108526a29cb4b3fa5dcc108b3b96463ea5c

Since the solution for this issue also requires a fix made in mvel, the complete fix will be available when the next mvel release (2.1.9.Final) will be out.

Comment 4 Tomas Schlosser 2014-02-19 14:41:26 UTC
Verified in BRMS 6.0.1.ER1


Note You need to log in before you can comment on or make changes to this bug.