Describe the bug
The ANTLR4 DRL parser (DRL10ParserWrapper) cannot parse Java 8 functional syntax inside a function declaration's body, while the legacy parser accepts it. Rules using such functions compile today only because drools.drl.antlr4.parser.enabled defaults to false; they will stop compiling when the ANTLR4 parser becomes the default.
Measured directly against DRL10ParserWrapper from org.drools:drools-drl-parser:10.2.0, loaded in an isolated classloader over its own ANTLR 4.13.2 runtime, so no other parser could be in play. The same constructs parse cleanly in a rule consequence, which is handled as an island, and the legacy ANTLR3 parser accepts them in both positions.
Scope of the gap — everything else tried in a function body parses: diamond generics, explicit generics, var, enhanced for, try-with-resources, switch, casts, ternaries and anonymous inner classes. Only lambdas (expression-bodied, block-bodied and typed-parameter forms) and method references (obj::m, Type::m) fail, plus any stream chain containing one.
Likely cause — DRL10Parser.g4 does carry the alternatives:
| lambdaExpression // Java8
| switchExpression // Java17
| drlExpression COLONCOLON typeArguments? drlIdentifier
| typeType COLONCOLON (typeArguments? drlIdentifier | NEW)
| classType COLONCOLON typeArguments? NEW
but they hang off drlExpression, and a function body is drlBlock → drlBlockStatement, whose expression statements do not route through drlExpression. So the support appears to be present-but-unreachable from a block statement rather than absent by design — which matches the constructs working in every other position.
Expected behavior
The ANTLR4 parser supports patterns supported by the ANTLR3 parser, including functions in DRL
Actual behavior
Error: Line X:Y missing ';' at ''
How to Reproduce?
any of these as a DRL function body:
package org.example;
function void f( java.util.List xs, java.util.List out )
{
xs.forEach(e -> out.add(e)); // lambda
}
function void g( java.util.List xs, java.util.List out )
{
xs.forEach(out::add); // method reference
}
Output of uname -a or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)
10.2.0
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
No response
Describe the bug
The ANTLR4 DRL parser (
DRL10ParserWrapper) cannot parse Java 8 functional syntax inside afunctiondeclaration's body, while the legacy parser accepts it. Rules using such functions compile today only becausedrools.drl.antlr4.parser.enableddefaults tofalse; they will stop compiling when the ANTLR4 parser becomes the default.Measured directly against
DRL10ParserWrapperfromorg.drools:drools-drl-parser:10.2.0, loaded in an isolated classloader over its own ANTLR 4.13.2 runtime, so no other parser could be in play. The same constructs parse cleanly in a rule consequence, which is handled as an island, and the legacy ANTLR3 parser accepts them in both positions.Scope of the gap — everything else tried in a function body parses: diamond generics, explicit generics,
var, enhancedfor, try-with-resources,switch, casts, ternaries and anonymous inner classes. Only lambdas (expression-bodied, block-bodied and typed-parameter forms) and method references (obj::m,Type::m) fail, plus any stream chain containing one.Likely cause —
DRL10Parser.g4does carry the alternatives:but they hang off
drlExpression, and a function body isdrlBlock → drlBlockStatement, whose expression statements do not route throughdrlExpression. So the support appears to be present-but-unreachable from a block statement rather than absent by design — which matches the constructs working in every other position.Expected behavior
The ANTLR4 parser supports patterns supported by the ANTLR3 parser, including functions in DRL
Actual behavior
Error: Line X:Y missing ';' at ''
How to Reproduce?
any of these as a DRL function body:
Output of
uname -aorverNo response
Output of
java -versionNo response
GraalVM version (if different from Java)
No response
Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)
10.2.0
Build tool (ie. output of
mvnw --versionorgradlew --version)No response
Additional information
No response