5.1 and trunk permits you to write e.g.
Foo( $array: array )
Bar( this == $array[0] )
but this crashes druing compilation with
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1949)
at
org.drools.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:928)
It's OK by this syntax:
accessor_element ; ID square_chunk* ;
Processing in DescriptorFactory handles []:
createAccessorPath(List<BaseDescr> aeList) {
...
if (name.indexOf('.') > -1 || name.indexOf('[') > -1) {
evaluator = new QualifiedIdentifierRestrictionDescr();
Then in PatternBuilder, we end up in this variant of the overloaded method
buildRestriction:
private Restriction buildRestriction(final RuleBuildContext context,
final InternalReadAccessor
extractor,
final FieldConstraintDescr
fieldConstraintDescr,
final
QualifiedIdentifierRestrictionDescr qiRestrictionDescr)
and this is where it happens, lastDot being == -1.
{ final int lastDot = qiRestrictionDescr.getText().lastIndexOf( '.'
);
final String className = qiRestrictionDescr.getText().substring( 0,
lastDot );
If the syntax isn't too permissive, then this method would have to handle
x[y] in
addition to x.y, etc.
-W
Show replies by date