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

compile error in exec model when setting BigDecimal variable to String type property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • executable model
    • None
    • 2021 Week 19-21 (from May 10)
    • Hide

      run attached reproducer by 'mvn clean compile".
      It works if it 's run by 'mvn clean compile exec:exec -DgenerateModel=NO"

      Show
      run attached reproducer by 'mvn clean compile". It works if it 's run by 'mvn clean compile exec:exec -DgenerateModel=NO"
    • Undefined
    • NEW
    • NEW

      Compile fails with the error in executable model when setting BigDecimal type variable to String type property in RHS.

      Here is example of rules.

      Example Rule 1

      rule "rule cannot find symbol 2"
          when
              $fact : Fact( $bd: bd )
          then
              $fact.text = $bd;
              System.out.println("***** $fact.text = "+$fact.text);
      end
      

      Compilation error :

      [ERROR] /path/to/reproducer_set_bigdecimal_to_string/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PDB/LambdaConsequenceDB86D1D027F981C570371BD3694D10F6.java:[25,14] cannot find symbol
      [ERROR]   symbol:   variable text
      [ERROR]   location: variable $fact of type com.example.reproducer.Fact
      

      In this example, problematic property 'text' is not real property name, but only setter/getter are defined like the following.

          public String getText() {
              return getStr();
          }
      
          public void setText(String str) {
              setStr(str);
          }
      

      Example Rule 2

      rule "rule_set_bd_to_str"
          no-loop true
          when
              $fact : Fact( $bd: bd )
          then
              $fact.str = $bd;
              System.out.println("***** $fact.str = "+$fact.str);
      end
      

      Compilation error :

      [ERROR] /path/to/reproducer_set_bigdecimal_to_string/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PFC/LambdaConsequenceFC4DFA1CB831E1940CE9B37A0C925678.java:[25,14] str has private access in com.example.reproducer.Fact
      [ERROR] /path/to/reproducer_set_bigdecimal_to_string/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PFC/LambdaConsequenceFC4DFA1CB831E1940CE9B37A0C925678.java:[25,21] incompatible types: java.math.BigDecimal cannot be converted to java.lang.String
      

            lmolteni@redhat.com Luca Molteni
            lmolteni@redhat.com Luca Molteni
            Daniel Rosa Daniel Rosa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: