Bug 1057550
| Summary: | Drools invokes superclass static method | ||
|---|---|---|---|
| Product: | [Retired] JBoss BRMS Platform 6 | Reporter: | Mario Fusco <mfusco> |
| Component: | BRE | Assignee: | Mario Fusco <mfusco> |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Tomas Schlosser <tschloss> |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | 6.0.0 | CC: | etirelli, rrajasek |
| Target Milestone: | ER1 | ||
| Target Release: | 6.0.1 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2014-08-06 19:59:07 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
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 |
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()); }