Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-7634

drools variable should be type RuleContext but is type Drools

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 8.42.0.Final
    • executable model
    • None
    • Hide

      Some Java method that expects RuleContext:

      import org.kie.api.runtime.rule.RuleContext;
      
      class Foo {
          public static void foo(RuleContext drools) {}
      } 

       

      Some rule that passes drools to the typed method:

      rule "Call Foo"
      when
      then
          Foo.foo(drools);
      end 

      Try to compile with executable model. And get an error similar to:

      the method foo(RuleContext) is not applicable for the arguments (Drools)
      Show
      Some Java method that expects RuleContext: import org.kie.api.runtime.rule.RuleContext; class Foo { public static void foo(RuleContext drools) {} }   Some rule that passes drools to the typed method: rule "Call Foo" when then     Foo.foo(drools); end Try to compile with executable model. And get an error similar to: the method foo(RuleContext) is not applicable for the arguments (Drools)
    • Hide

      Type method to expect org.drools.model.Drools and cast to org.kie.api.runtime.rule.RuleContext in the method body.

      Show
      Type method to expect org.drools.model.Drools and cast to org.kie.api.runtime.rule.RuleContext in the method body.
    • NEW
    • NEW
    • ---
    • ---

      The `drools` variable in DRL is documented to be of type org.kie.api.runtime.rule.RuleContext, but it declared 
      org.drools.model.Drools in the executable model, which prevents passing it to a method which expects RuleContext.
      https://docs.drools.org/8.44.0.Final/drools-docs/drools/language-reference/index.html#drl-rules-THEN-methods-variables-ref_drl-rules

              lmolteni@redhat.com Luca Molteni
              jstewmon Jonathan Stewmon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: