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()); }
Mario Fusco <mario.fusco> updated the status of jira DROOLS-410 to Resolved
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.
Verified in BRMS 6.0.1.ER1