I think I’ve found the cause. I located the generated class files for the
rules using HSDB and found the corresponding source files through
decompilation. The design is really ingenious.
I believe I’ve only identified the problem, but I’m still figuring out how
it’s actually generated. This is crucial for in-depth research into Drools
source code and its underlying principles.
On 2026/03/18 08:42:20 zhihui lai wrote:
> I’m writing a technical book on Drools kernel source code analysis. While
> analyzing the rule execution process, I would like to discuss a core
> calling logic and appreciate your support.
> I traced the source with a minimal demo:
>
> kmodule.xml
>
> <kbase name="helloKieBase" packages="rules.ruleHello">
> <ksession name="testhelloworld" />
> </kbase>
>
> DRL
>
> package rules.ruleHello
> import com.test.drools.pojo.Person;
>
> rule "Identity equality Fact test"
> when
> $p:Person()
> then
> System.out.println("Identity and equality Fact Person");
> end
>
> Java
>
> public static void main(String[] args) {
> KieServices kieServices = KieServices.Factory.get();
> KieContainer kieContainer = kieServices.getKieClasspathContainer();
> KieSession kieSession = kieContainer.newKieSession("testhelloworld");
>
> Person person = new Person();
> person.setName("张三");
> person.setAge(10);
>
> kieSession.insert(person);
> kieSession.fireAllRules();
> kieSession.dispose();
> }
>
>
>
> When debugging the source code:
> In RuleExecutor.innerFireActivation:
> consequence.evaluate(knowledgeHelper, wm);
> But it actually goes into ConsequenceGenerator.generate()
>
> I would like to discuss:
> Why does consequence.evaluate lead to ConsequenceGenerator.generate()?
> What is the full class & method call chain between them?
>
>
> Your insights will greatly support my book. Thank you!
>